Getting started with OpenGL ES in Android

It's very easy to create a 3D-enabled custom view. We can do it by simply extending GLSurfaceView instead of just extending from the View class. The complexity comes in the rendering part, but let's go step by step. First, we'll create a class named GLDrawer and add it to our project:

package com.packt.rrafols.draw; 
 
import android.content.Context; 
import android.opengl.GLSurfaceView; 
import android.util.AttributeSet; 
 
public class GLDrawer extends GLSurfaceView { 
    private GLRenderer glRenderer; 
 
    public GLDrawer(Context context, AttributeSet attributeSet) { 
        super(context, attributeSet); 
    } 
} 

Like our previous examples, we created the constructor with the AttributeSet, so we can inflate it and set parameters, ...

Get Building Android UIs with Custom Views now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.