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

Adding an Orthographic Projection

Let’s update our code to add in an orthographic projection and fix that squashed table.

Updating the Shader

The first thing we need to do is update the shader so that it uses our matrix to transform our positions. If you don’t yet have the AirHockeyOrtho project open (we created this project back at the beginning of this chapter), go ahead and open it up. Open simple_vertex_shader.glsl and update it as follows:

AirHockeyOrtho/res/raw/simple_vertex_shader.glsl
 
uniform mat4 u_Matrix;
 
 
attribute vec4 a_Position;
 
attribute vec4 a_Color;
 
 
varying vec4 v_Color;
 
 
void​ main()
 
{
 
v_Color = a_Color;
 
 
gl_Position = u_Matrix * a_Position;
 
gl_PointSize = 10.0;
 
}

We’ve added a new uniform definition, u_Matrix ...

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