OLD | NEW |
1 // | 1 // |
2 // Book: OpenGL(R) ES 2.0 Programming Guide | 2 // Book: OpenGL(R) ES 2.0 Programming Guide |
3 // Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner | 3 // Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner |
4 // ISBN-10: 0321502795 | 4 // ISBN-10: 0321502795 |
5 // ISBN-13: 9780321502797 | 5 // ISBN-13: 9780321502797 |
6 // Publisher: Addison-Wesley Professional | 6 // Publisher: Addison-Wesley Professional |
7 // URLs: http://safari.informit.com/9780321563835 | 7 // URLs: http://safari.informit.com/9780321563835 |
8 // http://www.opengles-book.com | 8 // http://www.opengles-book.com |
9 // | 9 // |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 GLushort *indices = NULL; | 90 GLushort *indices = NULL; |
91 GLbyte vShaderStr[] = | 91 GLbyte vShaderStr[] = |
92 "attribute vec4 a_position; \n" | 92 "attribute vec4 a_position; \n" |
93 "attribute vec3 a_normal; \n" | 93 "attribute vec3 a_normal; \n" |
94 "varying vec3 v_normal; \n" | 94 "varying vec3 v_normal; \n" |
95 "void main() \n" | 95 "void main() \n" |
96 "{ \n" | 96 "{ \n" |
97 " gl_Position = a_position; \n" | 97 " gl_Position = a_position; \n" |
98 " v_normal = a_normal; \n" | 98 " v_normal = a_normal; \n" |
99 "} \n"; | 99 "} \n"; |
100 | 100 |
| 101 // TODO(alokp): Shaders containing "precision" do not compile. |
101 GLbyte fShaderStr[] = | 102 GLbyte fShaderStr[] = |
102 "precision mediump float; \n" | 103 "//precision mediump float; \n" |
103 "varying vec3 v_normal; \n" | 104 "varying vec3 v_normal; \n" |
104 "uniform samplerCube s_texture; \n" | 105 "uniform samplerCube s_texture; \n" |
105 "void main() \n" | 106 "void main() \n" |
106 "{ \n" | 107 "{ \n" |
107 " gl_FragColor = textureCube( s_texture, v_normal );\n" | 108 " gl_FragColor = textureCube( s_texture, v_normal );\n" |
108 "} \n"; | 109 "} \n"; |
109 | 110 |
110 // Load the shaders and get a linked program object | 111 // Load the shaders and get a linked program object |
111 userData->programObject = esLoadProgram ( vShaderStr, fShaderStr ); | 112 userData->programObject = esLoadProgram ( vShaderStr, fShaderStr ); |
112 | 113 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 195 |
195 // Delete texture object | 196 // Delete texture object |
196 glDeleteTextures ( 1, &userData->textureId ); | 197 glDeleteTextures ( 1, &userData->textureId ); |
197 | 198 |
198 // Delete program object | 199 // Delete program object |
199 glDeleteProgram ( userData->programObject ); | 200 glDeleteProgram ( userData->programObject ); |
200 | 201 |
201 // Delete vertex buffer objects | 202 // Delete vertex buffer objects |
202 glDeleteBuffers ( 3, userData->vboIds ); | 203 glDeleteBuffers ( 3, userData->vboIds ); |
203 } | 204 } |
OLD | NEW |