Rhys
Rhys

Reputation: 2877

Android OpenGLES Scrolling Background

I have a scrolling background by making it dynamic and giving it a velocity to have it scrolling. I could have another image and loop them, but this seems a little messy and I am quite inexperienced with OpenGLES 1.1 and thought there may be a better way to do this.

What is the easiest/best way to have a scrolling background in OPenGLES 1 on android?

Upvotes: 2

Views: 931

Answers (1)

Trax
Trax

Reputation: 1910

The actual implementation may depend on which OpenGL version you are targeting. For any version you will need to specify texture parameters as follow:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

And in order to animate the texture coordinates you can either change your texture coordinates client side (send down updated texture coordinates) or use a texture matrix. For OpenGL ES 1.x you would change the matrix mode with glMatrixMode to GL_TEXTURE and translate it using glTranslate.

Sorry I don't have example for this, those are some guidelines.

EDIT: For an GLSL shader look here: GLSL shader that scroll texture

Upvotes: 2

Related Questions