Sign in to follow this  

best way to deal with npot textures

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

Ok here is the problem, I have a 3D scene with models created with some external tool. For simplicity let's say there is only one quad in this scene. This quad was first created to be used with texture with starndard texture coords (0,0 0,1 1,1 1,0). Soon a problem came up, the textures that are to be applied to this polygon can be also NPOT textures. Changing tex coords for a vertices is rather impossible because there would have to be a set of tex coords for every mesh in the scene that is using given texture. I came up with idea and it is quite simple: first NPOT image is converted to POT image. Obviously not all of this texture pixels are wanted on polygon then so when NPOT's texture bind() method is called it calls glScalef on GL_TEXTURE matrix so when mesh renders itself and sets let's say 1.0f as tex coord it is scaled properly and it is properly filled with given region of this texture. This way no changes are made to model itself, no additional tex coords are calculated explicitly. It has a flaw ofcourse. Current implementation of mesh calls bind() method for texture assigned to it butis not calling any unbind() ofcourse so it is immposible to automatly restore texture matrix saved in bind(). Currently program uses glPopMatrix() for GL_TEXTURE after every call to meshe's draw() method which is quite ugly. Please share your ideas on dealing with NPOT textures in those kind of situations. Thanks, and sorry for my english. ps i forgot to add that plygon's texture is changing constantly from time to time so it is useless to set proper tex coords for that quad once for entire program execution time

Share this post


Link to post
Share on other sites
I take it you're using the GL_EXT_TEXTURE_RECTANGLE extension? And you're having to use texture coordinates relative to the actual texture size instead of 0..1? I don't have a solution for that per se, but if you use the NPOT textures in OpenGL 2.0+ then you can use normalised texture coordinates (0..1) as per usual and the problem goes away.

Share this post


Link to post
Share on other sites

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