Texture dimensions

Ok, I know when loading a texture from a tga or bmp the width and length have to be powers of 2. But, can you create your own texture with the dimensions 640x480, etc?

Like could you do…

MyTexture [640][480][3]…?

you can create any sized image you want. The tga & bmp formats will obviously deal with them, and you can obviously load them. It’s doubtful a graphics card would be able to handle it as a texture though. For example, some graphics cards require a texture where both width and height must be the same and be a power of 2,

ie 256x256

some newer cards allow you to specify dimensions of varying size, eg 64x256, 128x8 etc.

I wouldn’t use non power of two textures purely for compatibility reasons, and varying dimensions isn’t something I do either for the same reason.

You can use glDrawPixels to draw non standard image sizes to the framebuffer, but thats obviously not a texture…

The power of two thing is mandated by the OpenGL spec. I doubt any driver allows textures with non-power of two dimensions … except of course if you use the NV_texture_rectangle extension, which is of course only available on newer NVidia hardware.

Two convert images to different sizes, the gluScaleImage function might be useful to you. See the glu spec for details, it’s pretty straightforward.