If you think the Android project model-explorer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.etaoin.myopengltest.core.main.renderers;
//www.java2s.comimport android.opengl.GLSurfaceView;
import com.etaoin.myopengltest.core.main.context.ContextManager;
import com.etaoin.myopengltest.util.camera.Camera;
import com.etaoin.myopengltest.util.gl.MyGLES20;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
/**
* GL Renderer for the main activity.
*/publicclass MainGLRenderer implements GLSurfaceView.Renderer {
private ContextManager contextManager;
private MyGLES20 gles20;
public MainGLRenderer(ContextManager contextManager, MyGLES20 gles20) {
this.contextManager = contextManager;
this.gles20 = gles20;
}
@Override
publicvoid onSurfaceCreated(GL10 gl10, EGLConfig config) {
contextManager.initialize();
}
@Override
publicvoid onSurfaceChanged(GL10 gl10, int width, int height) {
gles20.glViewport(0, 0, width, height);
float ratio = (float) width / height;
// TODO Send camera change through EventBus when ready
Camera camera = contextManager.getCurrentContext().getCamera();
camera.setProjectionMatrix(-ratio, ratio, -1f, 1f, 1f, 10f);
}
@Override
publicvoid onDrawFrame(GL10 gl10) {
contextManager.draw();
}
public ContextManager getContextManager() {
return contextManager;
}
}