How to load a non power-of-2 3D texture

How to …
Need I manually expend it to be power of 2 for each dimension?

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).

Jan

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?

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.

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.

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 .

Use SubImage is a good idea. Thanks!