In my 2D game I need textures that may be arbitrarily large, can be NPOT and nonsquare.
They are only ever mapped to one kind of primitive: rectangles via GL_QUADS (the four QUAD corners are mapped to the four texture corners). Sometimes the texture matrix has been scaled before drawing.
I want my game to work everywhere, even on old/cheap videocards that only allow small and/or POT textures.
What solution should I use? It should…
- Be easy to implement
- Have very good performance.
Currently I know of the following options:
-
Use an extension like
GL_TEXTURE_RECTANGLE_{EXT,NV,ARB}so NPOT works on cards that don’t support OGL2.0 native NPOT textures.- this doesn’t solve the “big texture” problem.
- does it work on a maximal number of PCs? do videocards that support native OGL2.0 NPOT support those extensions as well?
- which of the three variants EXT/NV/ARB to use?
-
Implement BigTextures as a bunch of small, POT texture slices, which are them carefully drawn on several adjacent QUADs. This both provides “big textures” and NPOT but it’s a bit difficult and limiting.
- Implement my NPOT textures as POT textures padded with transparency to the right and bottom. Will waste memory and make texture tiling a bit more difficult, and it doesn’t solve the “big texture” problem.
- Use some premade solution.
An example of a problematic videocard is the Mobile Intel® 945GM Express Chipset which doesn’t seem to support native NPOT.
Update: I ended up using the third option. The cool thing is, I was able to use glTexSubImage2D, rather than padding the texture manually. This is crazy fast. Yeah, it doesn’t provide “big texture” support, but I realized my target GPUs support up to 2048×2048 which is good enough for me. Oh, and GL_TEXTURE_RECTANGLE_EXT wasn’t even supported on the Mobile Intel® 945GM Express Chipset.
If all your UV-coordinates are in the [0, 1] range you could pack your NPOT textures into a texture atlas.
Since your textures can be arbitrarily large I would probably go with the suggestion to split up the NPOT textures (and corresponding quads) into POT pieces no larger than the hardware can handle. If you chose this solution remember to set the wrap mode to GL_CLAMP_TO_EDGE to minimize rendering artifacts at the edge (if you need minification, you’ll still get some).
If a card doesn’t support OpenGL 2.0 NPOT textures, it’s unlikely that they will support
GL_TEXTURE_RECTANGLE_{EXT,NV,ARB}.