public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glMatrixMode(GL10_GL_PROJECTION); float size = .01f * (float)java.lang.Math.tan(java.lang.Math.toRadians(45.0) / 2); float ratio = _width / _height; // perspective: gl.glFrustumf(-size, size, -size / ratio, size / ratio, 0.01f, 100.0f); // orthographic: //gl.glOrthof(-1, 1, -1 / ratio, 1 / ratio, 0.01f, 100.0f); gl.glViewport(0, 0, (int)_width, (int)_height); gl.glMatrixMode(GL10_GL_MODELVIEW); gl.glEnable(GL10_GL_DEPTH_TEST); // define the color we want to be displayed as the "clipping wall" gl.glClearColor(0f, 0f, 0f, 1.0f); // enable the differentiation of which side may be visible gl.glEnable(GL10_GL_CULL_FACE); // which is the front? the one which is drawn counter clockwise gl.glFrontFace(GL10_GL_CCW); // which one should NOT be drawn gl.glCullFace(GL10_GL_BACK); gl.glEnableClientState(GL10_GL_VERTEX_ARRAY); gl.glEnableClientState(GL10_GL_COLOR_ARRAY); initTriangle(); }
public void onSurfaceCreated(GL10 gl, EGLConfig config) { // preparation // enable the differentiation of which side may be visible gl.glEnable(GL10_GL_CULL_FACE); // which is the front? the one which is drawn counter clockwise gl.glFrontFace(GL10_GL_CCW); // which one should NOT be drawn gl.glCullFace(GL10_GL_BACK); gl.glEnableClientState(GL10_GL_VERTEX_ARRAY); gl.glEnableClientState(GL10_GL_COLOR_ARRAY); initTriangle(); }