[SDL] Using OpenGL for image transformations

Jonathan Dearborn grimfang4 at hotmail.com
Thu Sep 18 09:06:17 PDT 2008


Okay, I found it.  Pretty simple, but if you're new to OpenGL, you might not have seen it.

glMatrixMode(GL_TEXTURE);

This sets the rendering destination to the currently bound texture.
I also (re)found this, which is neat:

/* Take snapshot of frame buffer, and store in texture object 1.
* Take snapshot of center 400 by 400 pixels of frame buffer,
* assuming center is at 600, 400.
*/
glBindTexture( GL_TEXTURE_2D, 1 );
glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 400, 200, 512, 512, 0);
glBindTexture( GL_TEXTURE_2D, 0 );

The comment is a little off because I changed the values, but you can figure it out.  With this, you can copy the current screen to another texture.  I used it for a little video screen in-game. 

Jonny D

_________________________________________________________________
See how Windows Mobile brings your life together—at home, work, or on the go.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/


More information about the SDL mailing list