Jump to content
  • Advertisement
Sign in to follow this  
kbranch

OpenGL Power of 2 Limitation Workaround?

This topic is 4873 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know I've seen at least one thread about this before, but I haven't had much luck finding it since the search is down right now. I'm sorry if this is frequently asked, but I've done my best to find an answer on my own. I was wondering what I could do to get around the power of 2 limitation for texture sizes. So far I've just added some extra transparency to bring the dimensions up the the closest power of 2, but that seems horribly inefficient. I wouldn't worry about it too much if I were just using OpenGL, but I'm also using SDL for people that don't have a 3D card. If a computer is old enough not to have a 3D card, chances are that the extra data being drawn will have a huge impact on performance. If it helps, I'm writing a 2D RTS. You can find the latest version at http://kbranch.no-ip.com.

Share this post


Link to post
Share on other sites
Advertisement
Hmm, I believe there's an extension for this, but you're trying to avoid I guess.

I believe that "padding" data in some form or another is probably the only real solution for this, but maybe you could break down the larger textures into smaller, more managable pieces? Might cut down on the extra pixels a bit, if you're willing to work it out.

Share this post


Link to post
Share on other sites
glubui;ldimipmaps also needs power of 2 sized textures (it just resizes them first)
for a 2d game the best bet is
* pack a lot of smaller textures into a larger powof2 texture eg 1024x1024, and just change texture coords when u draw the stuff,
* there is also ARB_texture_non_power_of_two

Share this post


Link to post
Share on other sites
GL_NV_texture_rectange
GL_EXT_texture_rectange
GL_ARB_texture_rectange
(All the same)

Rectangle textures does not support mipmapping and texture coordinates are not normalized, [0-1, 0-1], but rather, [0-w, 0-h]. Which make them very handy as screen-size render targets. Widely supported.

GL_ARB_texture_non_power_of_two is only supported by Geforce 6.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sunray
GL_NV_texture_rectange
GL_EXT_texture_rectange
GL_ARB_texture_rectange
(All the same)

Rectangle textures does not support mipmapping and texture coordinates are not normalized, [0-1, 0-1], but rather, [0-w, 0-h]. Which make them very handy as screen-size render targets. Widely supported.

GL_ARB_texture_non_power_of_two is only supported by Geforce 6.


Thanks, that worked perfectly.

Are those all just different names for the exact same thing, or are they implemented differently?

Share this post


Link to post
Share on other sites
Quote:
Original post by kbranch
Quote:
Original post by Sunray
GL_NV_texture_rectange
GL_EXT_texture_rectange
GL_ARB_texture_rectange
(All the same)

Rectangle textures does not support mipmapping and texture coordinates are not normalized, [0-1, 0-1], but rather, [0-w, 0-h]. Which make them very handy as screen-size render targets. Widely supported.

GL_ARB_texture_non_power_of_two is only supported by Geforce 6.


Thanks, that worked perfectly.

Are those all just different names for the exact same thing, or are they implemented differently?

GL_NV_texture_rectangle → custom vendor specific extension by NVIDIA corp. (also present on some other vendor's drivers)
GL_EXT_texture_rectangle → vendor-independant optional extension to OGL
GL_ARB_texture_rectangle → function introduced and certified by the OpenGL ARB (a board of hardware vendors and opengl implementors that agree on additions that extend OpenGL)

The implementation details and behavior of each function might differ so basically you choose the one that's supported by the driver. Also note hat there are certain usage restrictions on textures created using these functions.
In general and for maximum compliance you should stick with power-of-two sized textures and merge a set of rectangular images into a single texture. This has the advatage of saving texture memory (note that some implementations do not guarantee that only width x height x bpp bytes of video memory are allocated by the driver) and minimising texture state changes (e.g. pack all ground tiles of a certain landscape set into one texture). Since packing textures is a preprocessing step it doesn't have any influence on the runtime performance, e.g. during load (another advatage → less textures to be loaded at startup).

For further details, refer to the ARB specs

Share this post


Link to post
Share on other sites
Everything worked fine in Linux, but it now has problems compiling in Windows. I managed to find out that Windows only had headers and libraries for GL 1.1 and that I'll need to use an extension.

So what exactly do I have to do to use an extension? I found this page, but it only seems to tell you how to use an extension that's already on your system. It seems to me like I'd have to download something (headers and libraries?) to be able to compile my game and something else to use at runtime, but I haven't found any information on what I might need or where to find it.

All I know about OpenGL is what I've taught myself about displaying some basic 2D graphics, so I'm sorry if this is a bit of a stupid question.

On a side note, does anybody know why the search feature has been disabled? Things would be easier for all parties involved if I could just use the search.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!