In our previous chapter, we created a class for our Triangle object; however, if you run your game, it will still show a blank screen since we have not used our render class to display it. We need to create an object for our newly defined class, and then using our GL reference, we will draw/render it on our screen. Open up your MyGLRenderer.java file and let's start by declaring a variable of our triangle. We won't be altering any of our code that we wrote in onSurfaceCreated() or onSurfaceChanged() methods.
In order to draw our object on screen, we will simply follow these steps:
- Define a variable of our Triangle class.
- Assign a reference to it in our constructor.
- Using gl, access the draw() method in our ...