Moving the triangle with rotation

What we've demonstrated so far with OpenGL would probably be easier using the traditional canvas or drawable objects. This recipe will show a bit of the power of OpenGL by rotating the triangle. Not that we can't create movement with the other drawing methods, but how easily we can do this with OpenGL!

This recipe will demonstrate how to rotate the triangle, as this screenshot shows:

Moving the triangle with rotation

Getting ready

Create a new project in Android Studio and call it: CreatingMovement. Use the default Phone & Tablet options and select Empty Activity when prompted for Activity Type.

This recipe builds on the previous recipe Applying Projection ...

Get Android Application Development Cookbook - Second Edition 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.