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

Side by Side Diff: ui/wayland/demos/util.cc

Issue 17265006: wayland patch for inspection Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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
« no previous file with comments | « ui/wayland/demos/util.h ('k') | ui/wayland/wayland.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/wayland/demos/util.h"
6
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/gl/gl_bindings.h"
10
11 namespace {
12
13 void PrintFBOStatus(GLenum status) {
14 switch (status) {
15 case GL_FRAMEBUFFER_COMPLETE:
16 LOG(ERROR) << "Complete attachment";
17 break;
18 case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
19 LOG(ERROR) << "Incomplete attachment";
20 break;
21 case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
22 LOG(ERROR) << "Incomplete missing attachment";
23 break;
24 case GL_FRAMEBUFFER_UNSUPPORTED:
25 LOG(ERROR) << "Unsupported";
26 break;
27 }
28 }
29
30 } // namespace
31
32 namespace util {
33
34 GLuint CompileShader(GLenum type, const GLchar* source) {
35 GLuint shader = glCreateShader(type);
36 if (!shader)
37 return 0;
38
39 glShaderSource(shader, 1, &source, 0);
40 glCompileShader(shader);
41
42 GLint compiled;
43 glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
44 if (!compiled) {
45 GLint info_len = 0;
46 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_len);
47
48 if (info_len > 0) {
49 // scoped_array<char> info_log(new char[info_len]);
50 // glGetShaderInfoLog(shader, info_len, NULL, info_log.get());
51 // LOG(ERROR) << "Compile error: " << info_log.get();
52 return 0;
53 }
54 }
55 return shader;
56 }
57
58 // Create a FBO bound to the output texture as a color buffer.
59 void CreateFBO(GLuint width, GLuint height, GLuint* fbo, GLuint color_texture) {
60 // Generate depth render buffer for FBO.
61 GLuint depth_buffer;
62
63 glGenRenderbuffersEXT(1, &depth_buffer);
64 glBindRenderbufferEXT(GL_RENDERBUFFER, depth_buffer);
65 glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
66 width, height);
67 glBindRenderbufferEXT(GL_RENDERBUFFER, 0);
68
69 // Generate the FBO.
70 glGenFramebuffersEXT(1, fbo);
71 glBindFramebufferEXT(GL_FRAMEBUFFER, *fbo);
72 glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
73 GL_COLOR_ATTACHMENT0,
74 GL_TEXTURE_2D,
75 color_texture,
76 0);
77 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER,
78 GL_DEPTH_ATTACHMENT,
79 GL_RENDERBUFFER,
80 depth_buffer);
81
82 PrintFBOStatus(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER));
83 glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
84 }
85
86 } // namespace util
OLDNEW
« no previous file with comments | « ui/wayland/demos/util.h ('k') | ui/wayland/wayland.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698