Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to OpenGL2.0 in Android. How can I scroll the GLSurfaceView both horizontally and vertically?

share|improve this question

In the Android Developers Training site, you already have a way to do this:

You just need to modify this line:

// Set the camera position (View matrix)
Matrix.setLookAtM(mVMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);

to add the ScrollX and ScrollY respectively.

share|improve this answer
Thanks for the reply carlos. But i am developing in OpenGL 2.0 Using SDK not 1.0 or NDK and even in the documentation there is no equivalent function for glOrthof in 2.0. – deepu Jan 18 '13 at 20:21
I lost this detail! Updated solution for OpenGL 2.0 – Carlos Bautista Jan 18 '13 at 20:32
thanks again for the reply but i have already tried that adding the delta scrolled amount which is multiplied by a factor in all the ways like adding them to only eyex, eyey and also adding them to all the eyex, eyey, centerx, centery, upx and upy. I get a different kind of animation like the background goes into Z-axis and it rotates for some reason. – deepu Jan 18 '13 at 20:49
Can you update the question with the relevant code? – muhuk Jan 19 '13 at 1:02
up vote 0 down vote accepted

Turns Out that the vertex shader in the Android OpenGL example is wrong. Its correct in the docs but if you download the example it has wrong shader code. As suggested by tim in the following link:

Android OpenGL weirdness with the setLookAtM method

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.