The problems you describe do exist. There is a way to see whether a
texture is “resident” (stored in gfx mem) in OpenGL:
GLboolean glAreTexturesResident ( GLsizei n, GLuint *textures,
GLboolean *residences ) ;
… which return true if all textures you ask about (with n/textures)
are stored in gfx mem.
Note that it only checks if they are stored in gfx mem right now ;
– it does not ask whether they could be stored in gfx mem. In order
to increase the chance that a texture will be stored in gfx mem from
the beginning, set its priority to 1:
GLvoid glPrioritizeTextures ( GLsizei n, GLuint *textures,
GLclampf *priorities ) ;
As you noted, it may become a bit more complex than SDL_Surface handling
What you would do in your application is:
- Create and set parameters for all GL texture objects
- Set all priorities to 1
- Upload all SDL_Surfaces to them
- Check whether all texture objects are resident, if not,
either decrease the quality of them (bits, remove alpha channel,
resolution …) or their number. Note that you have to change the
target format of the texture object, not the SDL_Surface’s
quality. Then redo step 3,4.
Here’s a reference page about texture objects:
http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node87.html
… and here’s more detail on step 4, changing the “internal format” of
a texture:
http://www.berkelium.com/OpenGL/GDC99/internalformat.html
Good luck!
/OlofOn Thu, 09 Dec 2004 02:16:13 +0100, Johannes Bauer wrote:
Hi list,
I’m using SDL with OpenGL in a game of mine because OpenGL gives great
HW-accelerated performance. Now in order to reuse my old style blitting
methods, I wrote a wrapper which converts SDL_Surface* to GL-Textures
and then blits them.
After the conversion of a SDL_Surface* to a GLuint texture handle, the
original surface can be discarded.
This I fear, very much. Because it means the texture needs to be stored
somewhere. I guess the graphics’ card memory, right? Now what if it
fills up? Will the application crash? Now be able to create any more
textures? Or is it so “smart” that it can temporarily "swap-out"
textures and swap them in on demand? What about thrashing?
SDL_Surfaces are just sooooo much easier
Greetings,
Johannes
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl