Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: gpu/command_buffer/client/gles2_demo_cc.cc

Issue 5254006: Initialize destinations variables before calling GL functions... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 167
168 } // anonymous namespace. 168 } // anonymous namespace.
169 169
170 void GLFromCPPInit() { 170 void GLFromCPPInit() {
171 CheckGLError("GLFromCPPInit", __LINE__); 171 CheckGLError("GLFromCPPInit", __LINE__);
172 glClearColor(0.f, 0.f, .7f, 1.f); 172 glClearColor(0.f, 0.f, .7f, 1.f);
173 g_texture = CreateCheckerboardTexture(); 173 g_texture = CreateCheckerboardTexture();
174 InitShaders(); 174 InitShaders();
175 CheckGLError("GLFromCPPInit", __LINE__); 175 CheckGLError("GLFromCPPInit", __LINE__);
176
177 char buf[128];
178 glReadPixels(0, 0, 1, 1, 0, 0, buf);
179 CheckGLError("GLFromCPPInit:ReadPixels", __LINE__);
176 } 180 }
177 181
178 void GLFromCPPDraw() { 182 void GLFromCPPDraw() {
179 const float kPi = 3.1415926535897932384626433832795f; 183 const float kPi = 3.1415926535897932384626433832795f;
180 184
181 CheckGLError("GLFromCPPDraw", __LINE__); 185 CheckGLError("GLFromCPPDraw", __LINE__);
182 // TODO(kbr): base the angle on time rather than on ticks 186 // TODO(kbr): base the angle on time rather than on ticks
183 g_angle = (g_angle + 1) % 360; 187 g_angle = (g_angle + 1) % 360;
184 // Rotate about the Z axis 188 // Rotate about the Z axis
185 GLfloat rot_matrix[16]; 189 GLfloat rot_matrix[16];
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // Bind the texture to texture unit 0 231 // Bind the texture to texture unit 0
228 glBindTexture(GL_TEXTURE_2D, g_texture); 232 glBindTexture(GL_TEXTURE_2D, g_texture);
229 CheckGLError("GLFromCPPDraw", __LINE__); 233 CheckGLError("GLFromCPPDraw", __LINE__);
230 // Point the uniform sampler to texture unit 0 234 // Point the uniform sampler to texture unit 0
231 glUniform1i(g_textureLoc, 0); 235 glUniform1i(g_textureLoc, 0);
232 CheckGLError("GLFromCPPDraw", __LINE__); 236 CheckGLError("GLFromCPPDraw", __LINE__);
233 glDrawArrays(GL_TRIANGLES, 0, 6); 237 glDrawArrays(GL_TRIANGLES, 0, 6);
234 CheckGLError("GLFromCPPDraw", __LINE__); 238 CheckGLError("GLFromCPPDraw", __LINE__);
235 glFlush(); 239 glFlush();
236 } 240 }
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_c_lib_autogen.h ('k') | media/tools/player_x11/gl_video_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698