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, ...