Best way to draw a background image


I have an image with size 1024x640 that I want to draw as a static background image. I’ve been trying to figure out the best way to do this. The best solution I could find was splitting the image into smaller parts and draw each part as a texture on a quad. If I split the image into sizes of 128x128, I have to use 40(!) textures to draw one image.

Is this really the best way to do this? Or are there any better or faster ways?

why not split to 512x512? if you have relatively new graphics card you can use non_power_of_two or rectangle textures and draw it with one quad. if you use 1024x1024 you need to adjust texture coords below 1.0f in y direction to correctly map the texture image.

Thank you very much for your reply!

I thought that max texture size was 256x256. The following is from a NeHe Tutorial(Lesson 06): “The width and height must be at least 64 pixels, and for compatability reasons, shouldn’t be more than 256 pixels.”

But maybe the tutorial is a bit old and the max texture size doesn’t apply anymore?

the tut is way to old yes. :slight_smile:
the max size you get retrieve runtime with glGetIntegerv(GL_MAX_TEXTURE_SIZE), something similar, look at the glGet function. the size varies from GPU to GPU, its wise to check the max supported size on startup. you can query also if NPOT textures are supported thruogh glGet(GL_EXTENSIONS).
all info you will locate on google, just give it a go.

p.s. current hardware supports max texture size of 8192x8192.

All non-ridiculous cards (read: non-Intel) support NPOT and rectangles, and textures of 2048x2048. Those cards are: R9550 and GF5xxxFX and onward. If you try to feed NPOT texture-data via gluBuildMipmaps (which you must avoid), that texture will be resized in software, so really avoid.