1
\$\begingroup\$

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

\$\endgroup\$
0

2 Answers 2

1
\$\begingroup\$

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

http://developer.android.com/training/graphics/opengl/projection.html

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.

\$\endgroup\$
4
  • \$\begingroup\$ 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. \$\endgroup\$
    – deepu
    Commented Jan 18, 2013 at 20:21
  • \$\begingroup\$ I lost this detail! Updated solution for OpenGL 2.0 \$\endgroup\$ Commented Jan 18, 2013 at 20:32
  • \$\begingroup\$ 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. \$\endgroup\$
    – deepu
    Commented Jan 18, 2013 at 20:49
  • \$\begingroup\$ Can you update the question with the relevant code? \$\endgroup\$
    – muhuk
    Commented Jan 19, 2013 at 1:02
0
\$\begingroup\$

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

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .