| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file is here so other GLES2 related files can have a common set of | 5 // This file is here so other GLES2 related files can have a common set of |
| 6 // includes where appropriate. | 6 // includes where appropriate. |
| 7 | 7 |
| 8 #include "../client/gles2_demo_cc.h" | 8 #include "../client/gles2_demo_cc.h" |
| 9 #include "../common/logging.h" | 9 #include "../common/logging.h" |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 CheckGLError("LoadShader", __LINE__); | 40 CheckGLError("LoadShader", __LINE__); |
| 41 GLuint shader = glCreateShader(type); | 41 GLuint shader = glCreateShader(type); |
| 42 if (shader == 0) { | 42 if (shader == 0) { |
| 43 return 0; | 43 return 0; |
| 44 } | 44 } |
| 45 // Load the shader source | 45 // Load the shader source |
| 46 glShaderSource(shader, 1, &shaderSrc, NULL); | 46 glShaderSource(shader, 1, &shaderSrc, NULL); |
| 47 // Compile the shader | 47 // Compile the shader |
| 48 glCompileShader(shader); | 48 glCompileShader(shader); |
| 49 // Check the compile status | 49 // Check the compile status |
| 50 GLint value; | 50 GLint value = 0; |
| 51 glGetShaderiv(shader, GL_COMPILE_STATUS, &value); | 51 glGetShaderiv(shader, GL_COMPILE_STATUS, &value); |
| 52 if (value == 0) { | 52 if (value == 0) { |
| 53 char buffer[1024]; | 53 char buffer[1024]; |
| 54 GLsizei length = 0; | 54 GLsizei length = 0; |
| 55 glGetShaderInfoLog(shader, sizeof(buffer), &length, buffer); | 55 glGetShaderInfoLog(shader, sizeof(buffer), &length, buffer); |
| 56 std::string log(buffer, length); | 56 std::string log(buffer, length); |
| 57 GPU_DLOG(gpu::ERROR) << "Error compiling shader:" << log; | 57 GPU_DLOG(gpu::ERROR) << "Error compiling shader:" << log; |
| 58 glDeleteShader(shader); | 58 glDeleteShader(shader); |
| 59 return 0; | 59 return 0; |
| 60 } | 60 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 glAttachShader(programObject, vertexShader); | 94 glAttachShader(programObject, vertexShader); |
| 95 glAttachShader(programObject, fragmentShader); | 95 glAttachShader(programObject, fragmentShader); |
| 96 // Bind g_Position to attribute 0 | 96 // Bind g_Position to attribute 0 |
| 97 // Bind g_TexCoord0 to attribute 1 | 97 // Bind g_TexCoord0 to attribute 1 |
| 98 glBindAttribLocation(programObject, 0, "g_Position"); | 98 glBindAttribLocation(programObject, 0, "g_Position"); |
| 99 glBindAttribLocation(programObject, 1, "g_TexCoord0"); | 99 glBindAttribLocation(programObject, 1, "g_TexCoord0"); |
| 100 // Link the program | 100 // Link the program |
| 101 glLinkProgram(programObject); | 101 glLinkProgram(programObject); |
| 102 // Check the link status | 102 // Check the link status |
| 103 GLint linked; | 103 GLint linked = 0; |
| 104 glGetProgramiv(programObject, GL_LINK_STATUS, &linked); | 104 glGetProgramiv(programObject, GL_LINK_STATUS, &linked); |
| 105 if (linked == 0) { | 105 if (linked == 0) { |
| 106 char buffer[1024]; | 106 char buffer[1024]; |
| 107 GLsizei length = 0; | 107 GLsizei length = 0; |
| 108 glGetProgramInfoLog(programObject, sizeof(buffer), &length, buffer); | 108 glGetProgramInfoLog(programObject, sizeof(buffer), &length, buffer); |
| 109 std::string log(buffer, length); | 109 std::string log(buffer, length); |
| 110 GPU_DLOG(gpu::ERROR) << "Error linking program:" << log; | 110 GPU_DLOG(gpu::ERROR) << "Error linking program:" << log; |
| 111 glDeleteProgram(programObject); | 111 glDeleteProgram(programObject); |
| 112 return; | 112 return; |
| 113 } | 113 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // Bind the texture to texture unit 0 | 227 // Bind the texture to texture unit 0 |
| 228 glBindTexture(GL_TEXTURE_2D, g_texture); | 228 glBindTexture(GL_TEXTURE_2D, g_texture); |
| 229 CheckGLError("GLFromCPPDraw", __LINE__); | 229 CheckGLError("GLFromCPPDraw", __LINE__); |
| 230 // Point the uniform sampler to texture unit 0 | 230 // Point the uniform sampler to texture unit 0 |
| 231 glUniform1i(g_textureLoc, 0); | 231 glUniform1i(g_textureLoc, 0); |
| 232 CheckGLError("GLFromCPPDraw", __LINE__); | 232 CheckGLError("GLFromCPPDraw", __LINE__); |
| 233 glDrawArrays(GL_TRIANGLES, 0, 6); | 233 glDrawArrays(GL_TRIANGLES, 0, 6); |
| 234 CheckGLError("GLFromCPPDraw", __LINE__); | 234 CheckGLError("GLFromCPPDraw", __LINE__); |
| 235 glFlush(); | 235 glFlush(); |
| 236 } | 236 } |
| OLD | NEW |