Sign in to follow this  

non-square image loading in OpenGL

This topic is 4391 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

You've got a few options: pad the image to a POT size and then use texture co-ordinates to chop out the bit that you want, use the gluBuild2DMipmaps function which will take a non-POT texture or you could use the non_power_of_two extension.

I've not used the extension route myself and so I can't speak for how well it's supported but either of the two first options are fine. Probably using gluBuild2DMipmaps would be the easiest way.

Hope that helps!

Share this post


Link to post
Share on other sites
Thanks guys. I think DevIL is going to do the trick, if I can figure out how to get it to work with Visual Studio .NET. If anyone knows how, I'd appreciate the help.

Share this post


Link to post
Share on other sites
Hi,

i assume that you are already able to load and use textures in opengl?

If you do, it's really easy to use non power of two textures:

1. check for the GL_ARB_texture_non_power_of_two extension.

2. if its supported, load textures as normal (glTexImage2D) - no code has to change, you dont have to add anything. Just set a non power of 2 width and height in glTexImage2D and use the texture as normal. This is the easiest extension ever!

If the extension is not supported, then you can either pad the image to the larger size, or use the NV_tex_rectangle extension - which is pretty well supported.


Share this post


Link to post
Share on other sites
Well, NV_tex_rect (and EXT_tex_rect for the same issue) are very widely supported but they're quite cumbersome to use unless you're writing a very small application.
In case this is your issue, you'll be very happy with them. I believe it's supported by everything after NV1x but I'm not sure. It is supported by sure means by NV2x and later.

Don't even think however using texture_rect for more advanced issues. The lack of wrapping modes, the different texture target and texture coordinate scheme will make you scream. Well, this actually won't happen until you start building up something complicated.
If you do, you'll find that for example, you need to retassellate geometry to accomodate simil-wrap modes, you'll have to have rect and POTD shaders and the machinery involved will rapidly pile up.
For more advanced applications, ARB_npotd (or GL2 for that matter) is a must.

Share this post


Link to post
Share on other sites

This topic is 4391 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this