views:

122

answers:

2

I'm developing a game, a big part of this game, is about scrolling a "circular" background ( the right end of the Background Image can connect with the left start of the Background image ).

Should be something like this: ( Entity moving and arrow to show where the background should start to repeat )

alt text

This happens in order to allow to have an Entity walking, and the background repeating itself over and over again.

I'm not working with tile-maps, the background is a simple Texture (400x300 px).

Could anyone point me to a link , or tell me the best way I could accomplish this ?

Thanks a lot.

+2  A: 

I don't know how different it is on the iPhone (OpenGL ES, I believe?), but in normal OpenGL, you'd set the texture tiling to repeat and then simply change the UV coordinates by the distance that the player moved. The texture tiling is set using:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
Max Shawabkeh
Could you add a code example for this ? or link me to one ? , thanks !
Mr.Gando
+1  A: 

Alternatively you can translate the texture using an appropriate texture matrix. This saves you from having to recalculate/upload your UV coordinates each frame.

genpfault