June 2013
Intermediate to advanced
346 pages
8h 42m
English
Now that we’ve read in the shader source from our files, the next step is to compile each shader. We’ll create a new helper class that is going to create a new OpenGL shader object, compile our shader code, and return the shader object for that shader code. Once we have this boilerplate code in place, we’ll be able to reuse it in our future projects.
To begin, create a new class, ShaderHelper, and add the following code inside the class:
| AirHockey1/src/com/airhockey/android/util/ShaderHelper.java | |
| | private static final String TAG = "ShaderHelper"; |
| | |
| | public static int compileVertexShader(String shaderCode) { |
| | return compileShader(GL_VERTEX_SHADER, shaderCode); |
| | } |
| | |
| | public static int compileFragmentShader( ... |
Read now
Unlock full access