Code example for GL10

Methods: glClear, glClearColor, glColor4f, glLoadIdentity, glRotatef, glTranslatef

0
        super(context);
    } 
 
    public void onDrawFrame(GL10 gl) {
        handleClearColor(gl);
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
        gl.glLoadIdentity();    // Reset The Current Modelview Matrix
         
        gl.glTranslatef(0.0f, 0.0f, -6.0f);
        gl.glRotatef(rotx, 1, 0, 0);
        gl.glRotatef(roty, 0, 1, 0);
         
        gl.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
        //shape.glutSolidCube(gl, 2.0f); 
        //shape.glutSolidBox(gl, 1.0f, 1.0f, 2.0f); 
        //shape.glutWireCube(gl, 2.0f); 
        shape.glutWireBox(gl, 1.0f, 3.0f, 2.0f);
 
        rotx += 2.0f;
        roty += 3.0f;        
    } 
 
    public void onSurfaceChanged(GL10 gl, int width, int height) {
        gl.glViewport(0, 0, width, height); // Reset The Current Viewport
 
        gl.glMatrixMode(GL10.GL_PROJECTION); // Select The Projection Matrix
        gl.glLoadIdentity(); // Reset The Projection Matrix
 
        // Calculate The Aspect Ratio Of The Window 
        GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f);
 
        gl.glMatrixMode(GL10.GL_MODELVIEW); // Select The Modelview Matrix
        gl.glLoadIdentity(); // Reset The Modelview Matrix
    } 
 
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        gl.glShadeModel(GL10.GL_SMOOTH); // Enable Smooth Shading
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
        gl.glClearDepthf(1.0f); // Depth Buffer Setup
        gl.glEnable(GL10.GL_DEPTH_TEST); // Enables Depth Testing
        gl.glDepthFunc(GL10.GL_LEQUAL);// The Type Of Depth Testing To Do
        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);  // Really Nice Perspective Calculations
    } 
 
    public boolean handleTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            if (mColorType < 6) {
                mColorType++;
            } else { 
                mColorType = 0;
            } 
            return true; 
        } 
        return false; 
    } 
 
    private void handleClearColor(GL10 gl) {
        switch (mColorType) {
        case 0: 
            gl.glClearColor(0, 1, 1, 1);
            break; 
        case 1: 
            gl.glClearColor(1, 0, 1, 1);
            break; 
        case 2: 
            gl.glClearColor(1, 1, 0, 1);
            break; 
        case 3: 
            gl.glClearColor(0, 0, 1, 1);
            break; 
        case 4: