O'Reilly logo

OpenGL ES 2 for Android by Kevin Brothaler

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

Drawing Our Texture

Now that we’ve divided our vertex data and shader programs into different classes, let’s update our renderer class to draw using our texture. Open up AirHockeyRenderer, and delete everything except onSurfaceChanged, as that’s the only method we won’t change. Add the following members and constructor:

AirHockeyTextured/src/com/airhockey/android/AirHockeyRenderer.java
 
private​ ​final​ ​Context​ context;
 
 
private​ ​final​ ​float​​[]​ projectionMatrix = ​new​ ​float​[16];
 
private​ ​final​ ​float​​[]​ modelMatrix = ​new​ ​float​[16];
 
 
private​ Table table;
 
private​ Mallet mallet;
 
 
private​ TextureShaderProgram textureProgram;
 
private​ ColorShaderProgram colorProgram;
 
 
private​ ​int​ texture;
 
 
public​ AirHockeyRenderer(​ ...

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