O'Reilly logo

Android NDK Beginner's Guide - Second Edition by Sylvain Ratabouil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – initializing OpenGL ES

Let's now see how to implement a sprite batch in DroidBlaster:

  1. Modify jni/GraphicsManager.hpp. Create the class GraphicsComponent, which defines a common interface for all rendering techniques starting with sprite batches. Define a few new methods such as:
    • getProjectionMatrix() which provides an OpenGL matrix to project 2D graphics on screen
    • loadShaderProgram() to load a vertex and fragment shader and link them together into an OpenGL program
    • registerComponent() which records a list of GraphicsComponent to initialize and render

    Create the RenderVertex private structure representing the structure of an individual sprite vertex.

    Also, declare a few new member variables such as:

    • mProjectionMatrix to store an orthographic ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required