Time for action – initializing OpenGL ES
Let's now see how to implement a sprite batch in DroidBlaster:
Modify
jni/GraphicsManager.hpp
. Create the classGraphicsComponent
, 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 screenloadShaderProgram()
to load a vertex and fragment shader and link them together into an OpenGL programregisterComponent()
which records a list ofGraphicsComponent
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 projection (as opposed to a perspective projection used in 3D games).mShaders
,mShaderCount
,mComponents
, andmComponentCount
to keep trace of all resources.
Finally, get rid of all the
GraphicsElement
stuff used in the previous chapter...