Another question along the lines of my first question: A lot of the C++ tutorials have code to deal with the pixel format and bit depth of surfaces loaded from files [1]. For example,
surface->format->BytesPerPixel might be used to get the bit depth, or surface->format->Rmask might be used to get the position of the red byte in the pixel format (to determine if the image is RGB or BGR). The lisp equivalent (that I found) seems to be: (cffi:foreign-slot-value (sdl-base::pixel-format (sdl:fp surface)) 'sdl-cffi::sdl-pixel-format 'sdl-cffi::bytesperpixel) (cffi:foreign-slot-value (sdl-base::pixel-format (sdl:fp surface)) 'sdl-cffi::sdl-pixel-format 'sdl-cffi::rmask) Is there (rather, _isn't_ there) a better way to do this? Thanks. [1] http://gpwiki.org/index.php/C:SDL_OGL On Sat, Jul 11, 2009 at 9:59 PM, Elliott Slaughter < elliottslaugh...@gmail.com> wrote: > Hi, > > I'm trying to use lispbuilder with cl-opengl. Specifically, I'm trying to > convert a texture example from C++ into lisp [1]. > > I ran into a little trouble when the example got the pixels from the > surface: > > surface->pixels > > What I eventually got working in lisp is: > > (sdl-base::with-pixels (pixels (sdl:fp surface)) > (sdl-base::pixel-data pixels)) > > Which seems to work ok. (But I'd still like confirmation that this is the > best way to do it. It seems like too much code to do something so simple.) > > > My second question is about how to free the texture after I'm done. I know > this isn't really an SDL thing, but I figured you dealt with this when you > created lisp wrappers around SDL surfaces. > > My intuition would be to create a finalizer for the wrapper, and free the > texture then. But according to trivial-garbage [2], in some lisps it isn't > safe to use an object when the finalizer is called. (Or does CFFI do this > automatically for me?) > > > Thanks. Any advice would be appreciated. > > [1] http://anomtech.uuuq.com/glTextures.php > [2] http://www.cliki.net/trivial-garbage > > -- > Elliott Slaughter > > "Don't worry about what anybody else is going to do. The best way to > predict the future is to invent it." - Alan Kay > -- Elliott Slaughter "Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." - Alan Kay
_______________________________________________ application-builder mailing list application-builder@lispniks.com http://www.lispniks.com/mailman/listinfo/application-builder