Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Vertical and Horizontal Scrolling in OpenGLES 2.0
    text
    copied!<p>Can any one give me a example on how to add vertical and horizontal scroll till the end of the GLSurfaceview which is zoomed. I have tried using Matrix.Translate and Matrix.Rotate with 0deg angle none of it works.</p> <p>The ways i have used. In here dx and dy are the amount scrolled which i get from onTouch multiplied by a constant factor:</p> <p>way 1:</p> <p>@Override public void onDrawFrame(GL10 unused) {</p> <pre><code>mOffset = mPositionX + mPositionY; // Draw background color GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); // Set the camera position (View matrix) Matrix.setLookAtM(mVMatrix, 0, mOffset, mOffset, -3, mOffset, mOffset, 0f, 0.0f, 1.0f, 0.0f); // Calculate the projection and view transformation Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0); mGraph.draw(mMVPMatrix); mLine.draw(mMVPMatrix); </code></pre> <p>}</p> <p>way 2: </p> <p>@Override public void onDrawFrame(GL10 unused) {</p> <pre><code>mOffset = mPositionX + mPositionY; Matrix.frustumM(mProjMatrix, 0, mSurfaceRatio * zoomFactor, -mSurfaceRatio * zoomFactor, -1 * (zoomFactor + mOffset), zoomFactor + mOffset, 3, 7); // Draw background color GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); // Set the camera position (View matrix) Matrix.setLookAtM(mVMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0.0f, 1.0f, 0.0f); // Calculate the projection and view transformation Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0); mGraph.draw(mMVPMatrix); mLine.draw(mMVPMatrix); </code></pre> <p>}</p> <p>way 3: </p> <p>@Override public void onDrawFrame(GL10 unused) {</p> <pre><code>mOffset = mPositionX + mPositionY; // Draw background color GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); Matrix.rotateM(mRotationMatrix, 0, 0, 0, mOffset, 0); Matrix.multiplyMM(mProjMatrix, 0, mProjMatrix, 0, mRotationMatrix, 0); // Set the camera position (View matrix) Matrix.setLookAtM(mVMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0.0f, 1.0f, 0.0f); // Calculate the projection and view transformation Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0); mGraph.draw(mMVPMatrix); mLine.draw(mMVPMatrix); </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload