Rotating our object

By now, you must have understood that any changes in the rendering of an object have to be done in the MyGLRenderer, whereas any properties that are local to our object are to be done in the respective object's file. So, we will write our rotation code in our file because rotating an object is a part of the rendering process.

Here's our logic to rotate our triangle:

  • We take our rotation angle
  • We rotate our object in a specified rotation angle
  • We increment our rotation angle

Let's do it; we will simply declare two variables at the start for our rotational angle and speed; then in our onDrawFrame() method, implement our rotation logic, as follows:

//Import statements as beforepublic class MyGLRenderer ...

Get Learning Android Game Development now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.