views:

1979

answers:

1

Hi, i have a 1024 x 1024 image I use for a texture in my game for the background.

Im wondering if their is a proper way to handle drawing a large background texture.

How I am doing it currently:

texCoord { 0,0,1,0,0,1,1,1 }
vertice { 0,0,0,height,width,0,width,height }
texCoordPointer(texCoord)
vertexPointer(vertice)

bind the texture
enable client (texCoordArr, vertexCoordArr)
drawArray
disable client (texCoordArr, vertexCoordArr)
+2  A: 

That's fine...

I don't know if the GL|ES on the iPhone supports the glDrawTexOES extension, but if it does you may safe some lines of code. It won't make drawing any faster though.

Also some additional hints:

  • try to make the texture exactly as large as the screen. There is no need to store the image in 1024*1024 if the real resolution is more around 480*320. If you zoom or pan the image it's another thing of course.

  • You may save quite a bit of memory if you don't upload mipmaps for the backdrop.

Nils Pipenbrinck
Textures are required to be the power of two (64x64, 256x256 etc) up until 2.2.1, not sure about 3.0 (it does show variable-sized textures in the 3.0 simulator, can't test it on the device yet as I'm still on 2.2.1).
melfar
Yep. It's mandatory to either pad the images to a power of two or split them into smaller chunks.
Nils Pipenbrinck