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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/wayland/demos/util.h ('k') | ui/wayland/wayland.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/wayland/demos/util.cc
diff --git a/ui/wayland/demos/util.cc b/ui/wayland/demos/util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9dfe72adf4325c69bf060a1ea42808e7921b5ff1
--- /dev/null
+++ b/ui/wayland/demos/util.cc
@@ -0,0 +1,86 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/wayland/demos/util.h"
+
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/gl/gl_bindings.h"
+
+namespace {
+
+void PrintFBOStatus(GLenum status) {
+ switch (status) {
+ case GL_FRAMEBUFFER_COMPLETE:
+ LOG(ERROR) << "Complete attachment";
+ break;
+ case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
+ LOG(ERROR) << "Incomplete attachment";
+ break;
+ case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
+ LOG(ERROR) << "Incomplete missing attachment";
+ break;
+ case GL_FRAMEBUFFER_UNSUPPORTED:
+ LOG(ERROR) << "Unsupported";
+ break;
+ }
+}
+
+} // namespace
+
+namespace util {
+
+GLuint CompileShader(GLenum type, const GLchar* source) {
+ GLuint shader = glCreateShader(type);
+ if (!shader)
+ return 0;
+
+ glShaderSource(shader, 1, &source, 0);
+ glCompileShader(shader);
+
+ GLint compiled;
+ glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
+ if (!compiled) {
+ GLint info_len = 0;
+ glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_len);
+
+ if (info_len > 0) {
+// scoped_array<char> info_log(new char[info_len]);
+// glGetShaderInfoLog(shader, info_len, NULL, info_log.get());
+// LOG(ERROR) << "Compile error: " << info_log.get();
+ return 0;
+ }
+ }
+ return shader;
+}
+
+// Create a FBO bound to the output texture as a color buffer.
+void CreateFBO(GLuint width, GLuint height, GLuint* fbo, GLuint color_texture) {
+ // Generate depth render buffer for FBO.
+ GLuint depth_buffer;
+
+ glGenRenderbuffersEXT(1, &depth_buffer);
+ glBindRenderbufferEXT(GL_RENDERBUFFER, depth_buffer);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
+ width, height);
+ glBindRenderbufferEXT(GL_RENDERBUFFER, 0);
+
+ // Generate the FBO.
+ glGenFramebuffersEXT(1, fbo);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, *fbo);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D,
+ color_texture,
+ 0);
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER,
+ GL_DEPTH_ATTACHMENT,
+ GL_RENDERBUFFER,
+ depth_buffer);
+
+ PrintFBOStatus(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER));
+ glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
+}
+
+} // namespace util
« 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