Back to project page OpenGlDraw_Android.
The source code is released under:
GNU General Public License
If you think the Android project OpenGlDraw_Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.opengldraw.gl; /* w w w. ja v a 2 s. c o m*/ import android.content.Context; import android.opengl.GLSurfaceView; import android.view.MotionEvent; public class GLSurfaceViewDraw extends GLSurfaceView { private RendererDraw myRenderer; private float touchX; private float touchY; private final float rotationFactorX = 180.0f / 320; private final float rotationFactorY = 180.0f / 320; public GLSurfaceViewDraw(Context context) { super(context); //setEGLContextClientVersion(1); myRenderer = new RendererDraw(context); setRenderer(myRenderer); /* Draw only when told to with requestRender. This is used for touch enabled interaction. */ //setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); } @Override public boolean onTouchEvent(MotionEvent e) { float tx = e.getX(); float ty = e.getY(); if(e.getAction() == MotionEvent.ACTION_MOVE) { float dx = tx - touchX; float dy = ty - touchY; myRenderer.myAngleY += dx * rotationFactorX; //180.0f / 320; myRenderer.myAngleX += dy * rotationFactorY; //180.0f / 320; requestRender(); } touchX = tx; touchY = ty; return true; }; }