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 22 matching lines...) Expand all Loading... |
33 // | 33 // |
34 // | 34 // |
35 | 35 |
36 // | 36 // |
37 /// | 37 /// |
38 /// \brief Load a shader, check for compile errors, print error messages to outp
ut log | 38 /// \brief Load a shader, check for compile errors, print error messages to outp
ut log |
39 /// \param type Type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER) | 39 /// \param type Type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER) |
40 /// \param shaderSrc Shader source string | 40 /// \param shaderSrc Shader source string |
41 /// \return A new shader object on success, 0 on failure | 41 /// \return A new shader object on success, 0 on failure |
42 // | 42 // |
43 GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc ) | 43 GLuint esLoadShader ( GLenum type, const char *shaderSrc ) |
44 { | 44 { |
45 GLuint shader; | 45 GLuint shader; |
46 GLint compiled; | 46 GLint compiled; |
47 | 47 |
48 // Create the shader object | 48 // Create the shader object |
49 shader = glCreateShader ( type ); | 49 shader = glCreateShader ( type ); |
50 | 50 |
51 if ( shader == 0 ) | 51 if ( shader == 0 ) |
52 return 0; | 52 return 0; |
53 | 53 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 | 87 |
88 // | 88 // |
89 /// | 89 /// |
90 /// \brief Load a vertex and fragment shader, create a program object, link prog
ram. | 90 /// \brief Load a vertex and fragment shader, create a program object, link prog
ram. |
91 // Errors output to log. | 91 // Errors output to log. |
92 /// \param vertShaderSrc Vertex shader source code | 92 /// \param vertShaderSrc Vertex shader source code |
93 /// \param fragShaderSrc Fragment shader source code | 93 /// \param fragShaderSrc Fragment shader source code |
94 /// \return A new program object linked with the vertex/fragment shader pair, 0
on failure | 94 /// \return A new program object linked with the vertex/fragment shader pair, 0
on failure |
95 // | 95 // |
96 GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragSha
derSrc ) | 96 GLuint esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc ) |
97 { | 97 { |
98 GLuint vertexShader; | 98 GLuint vertexShader; |
99 GLuint fragmentShader; | 99 GLuint fragmentShader; |
100 GLuint programObject; | 100 GLuint programObject; |
101 GLint linked; | 101 GLint linked; |
102 | 102 |
103 // Load the vertex/fragment shaders | 103 // Load the vertex/fragment shaders |
104 vertexShader = esLoadShader ( GL_VERTEX_SHADER, vertShaderSrc ); | 104 vertexShader = esLoadShader ( GL_VERTEX_SHADER, vertShaderSrc ); |
105 if ( vertexShader == 0 ) | 105 if ( vertexShader == 0 ) |
106 return 0; | 106 return 0; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 glDeleteProgram ( programObject ); | 146 glDeleteProgram ( programObject ); |
147 return 0; | 147 return 0; |
148 } | 148 } |
149 | 149 |
150 // Free up no longer needed shader resources | 150 // Free up no longer needed shader resources |
151 glDeleteShader ( vertexShader ); | 151 glDeleteShader ( vertexShader ); |
152 glDeleteShader ( fragmentShader ); | 152 glDeleteShader ( fragmentShader ); |
153 | 153 |
154 return programObject; | 154 return programObject; |
155 } | 155 } |
OLD | NEW |