View Full Version : How to load a non power-of-2 3D texture
07-26-2003, 12:45 PM
How to ...
Need I manually expend it to be power of 2 for each dimension?
07-26-2003, 03:22 PM
you can use gluBuild2DMipmaps, this does the rescaling for you, or, if you don't want to do this, you have to rescale them yourself (which is not that complicated either).
07-26-2003, 03:34 PM
So, that command will do the scaling.
If I just want to pad to the nearest power-of-2, I have to do it by myself?
07-26-2003, 06:38 PM
gluBuild2DMipmaps will resize the input texture to the nearest power of 2 for you. If you require more control of the texture than that (i.e. the nearest power of 2 is not the texture size you want) then you must use a image program to size it to the power of 2 your prefer...
While rescaling is probably the best thing you can do, also take a look at rectangular textures. There's NV_texture_rectangle and an upcoming ARB extension.
07-28-2003, 05:16 AM
don't forget that the "dimensioned-by-a-power-of-2"-factor is a speed related thing;
apart from that i'm doing scaling for myself within my 3DSMAX exporter; using float-values it's very simple to "create" each arbitrary size of a texture, by using only 10 lines of code.
i prefer not to use such "non-power-of-2-dimensioned"-texture extensions.
07-28-2003, 08:46 AM
another option would be to create a dummy texture with power of 2 dimensions, memset it to 0, and then put the actual texture using glTexSubImage (which doesnt need power of 2 dimensions). this uses more mem, but it might be faster (its pretty fast for me, but i havent done any serious testing with it, and im using it in a pretty non standard application). youll also need to use different values for glTextCoord*, since the actual texture is still the power of 2 dimensions, but you only have meaningful data in a part of the texture.
Or, just wait till OpenGL 1.5 compliant drivers ship, which supports non-power of 2 sized textures per: todays announcement (http://www.sgi.com/newsroom/press_releases/2003/july/opengl15.html) .
07-28-2003, 11:53 AM
Use SubImage is a good idea. Thanks!
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.