display images in opengl

Is there a method to let me display a image whose size is 800X600 in opengl? and how?

I know that the image size for opengl texture is restricted to 2powern.

Dose that mean I can’t display 800X600 pixel size image as texture image without cutting it off to 512X512?

thanks lot,

Jerry

You have four options options: over-sizing the texture to contain it and only drawing the part you need, chunking, compression, or making use of the wasted space. Chunking is much more difficult, but it is good for textures that would waste a lot of space (a 257x256 texture, for example, would then require it be 512x512, wasting nearly 75% of the memory used on it) otherwise. It often won’t save you much, but if the texture width/height is under 50% of the oversize, then it can get you some serious savings. If you suck at advanced math as badly as I do, then you can try texture compression, which will virtually eliminate the extra data introduced by the unused area. Stuffing more textures into the wasted space is not as hard as the previous two (imo), but you have to play with texture coordinates a lot more, and you can’t repeat the trextures that are treated in this manner w/o clipping polygons, which requires a lot of 3D math that I will never see in school. It’s not like you’d need to repeat an 800x600 image anyway, but if there’s other crap you don’t need to repeat, stuff it into the same texture. Oh, and if you use any form of linear filtering, you’ll have to offset your texture coordinates by 1/4th of a texel to keep the video card from interpolating other, undesired texels into the displayed image.

blah blah blah, don’t mind me :stuck_out_tongue:

>>(a 257x256 texture, for example, would then require it be 512x512, wasting nearly 75% of the memory used on it)

A 257x256 image would fit into a 512x256 texture, wasting only 50%.

There’s also an extension, NV_texture_rectangle, that allows textures of any size, so no memory is wasted. It’s a NV-extensions, so I believe not many other than NVIDIA support them.

Could you expand…

“Oh, and if you use any form of linear filtering, you’ll have to offset your texture coordinates by 1/4th of a texel to keep the video card from interpolating other, undesired texels into the displayed image.”