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 ...
Get OpenGL ES 2 for Android 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.