Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

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.

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
add comment

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
add comment

Your Answer

 
discard

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.