Building an OpenGL-friendly, GameObject super class

Let's dive straight into the code. As we will see, this GameObject will have a lot in common with the GameObject class from the previous project. The most significant difference will be that this latest GameObject will of course draw itself using a handle to the GL program, primitive (vertex) data from a child class, and the viewport matrix contained in viewportMatrix.

Create a new class, call it GameObject, and enter these import statements, noting again that that some of them are static:

import android.graphics.PointF; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import static android.opengl.GLES20.GL_FLOAT; import static android.opengl.GLES20.GL_LINES; ...

Get Android Game Programming: A Developer’s Guide 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.