OpenGL ES Scrolling Background

Apprentice
Posts: 5
Joined: 2008.10
Post: #1
Hi,

I'm trying to make a scrolling background using the Texture2D class. I assuming the best way to do this is to create an image that is like 4800 pixels and then just use coordinates to just load part of the picture and keep shifting the coordinates every x time period to shift the image. Is there a better way?

The Texture2D class seems to be limiting the file to 1024 pixels (kMaxTextureSize), can you change that? When I load my file of 4800 it ends up really blurry.

Thanks
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #2
The best way to do this depends on what you want to do.

Is your background one giant unique image, or built out of tiles?
Will the background only scroll in integral pixel amounts, or do you want to support rotating/zooming/subpixel scrolling?

Whatever you want to do, you need to work within the hardware limits.
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2008.10
Post: #3
The background is currently one big image, do I need to chop it up?

Thanks
Quote this message in a reply
Member
Posts: 269
Joined: 2005.04
Post: #4
Assuming "glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);" is accurate, the max texture size on the iPhone is 1024x1024. If you want larger than that you'll need multiple textures, or a tiling/repeating texture.
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2008.10
Post: #5
Thanks for the reply, so I've cut it up into multiple textures, but now I'm having a tough time getting them lined up. Can someone help me understand the following two methods:

glTexCoordPointer;
glDrawArrays;

I'm trying to find some picture that will help me understand what the coordinates should be. I'm using GL_TRIANGLE_STRIP

Thanks
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #6
Bachus Wrote:... the max texture size on the iPhone is 1024x1024.

Yes, it actually says that in the iPhone programming guide.

@abdm436: glTexCoordPointer is used to tell OpenGL where to find the array of texture coordinates for the object you are about to draw. You will also need at least glVertexPointer specified as well which does the same thing for your array of vertex coordinates. Plus you'll need to make sure you've glEnableClientState(GL_VERTEX_ARRAY); and glEnableClientState(GL_TEXTURE_COORD_ARRAY); once before drawing. Plus you need to glBindTexture to specify which texture to use, and glEnable(GL_TEXTURE_2D) to turn on texturing. Then you can do your transforms and call glDrawArrays, which takes the vertex and texCoord arrays you specified with glVertexPointer and glTexCoordPointer, and draws an object with them.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Scrolling content but not background omriykl 1 5,361 Jun 14, 2009 01:45 PM
Last Post: uripo
  OpenGL ES: Doing a background distortion soulstorm 2 3,377 May 14, 2009 04:00 PM
Last Post: soulstorm
  OpenGL - how to draw background image? SDyer777 1 7,438 Mar 9, 2009 11:17 AM
Last Post: AnotherJake