Defining shapes

In order to draw something on the screen, we first need to define its shape and then render it. So we won't define our shape in our render class. We will create a new class in order to define our shape. As discussed, we will first create a basic triangle.

In order to create our triangle, we need to first define its vertices. So, let's create a new class named Triangle.java and start writing our logic to define the shape of our 3D triangle. Before we start writing our code, let's try to understand what we are actually going to do.

We will take vertices and plot them on our screen. Also, as you saw previously how OpenGL coordinates work, we will plot our vertices in all three directions. For our triangle, we require three points ...

Get Learning Android Game Development 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.