OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 implements the ViewGLContext and PbufferGLContext classes. | 5 // This file implements the ViewGLContext and PbufferGLContext classes. |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <GL/glew.h> | 8 #include <GL/glew.h> |
9 #include <GL/glxew.h> | 9 #include <GL/glxew.h> |
10 #include <GL/glx.h> | 10 #include <GL/glx.h> |
11 #include <GL/osmew.h> | 11 #include <GL/osmew.h> |
| 12 #include <unistd.h> |
12 #include <X11/Xlib.h> | 13 #include <X11/Xlib.h> |
13 #include <X11/Xutil.h> | 14 #include <X11/Xutil.h> |
14 | 15 |
15 #include "app/x11_util.h" | 16 #include "app/x11_util.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/process_util.h" |
17 #include "base/scoped_ptr.h" | 19 #include "base/scoped_ptr.h" |
18 #include "app/gfx/gl/gl_context.h" | 20 #include "app/gfx/gl/gl_context.h" |
19 #include "app/gfx/gl/gl_context_osmesa.h" | 21 #include "app/gfx/gl/gl_context_osmesa.h" |
20 | 22 |
21 namespace gfx { | 23 namespace gfx { |
22 | 24 |
23 typedef GLXContext GLContextHandle; | 25 typedef GLXContext GLContextHandle; |
24 typedef GLXPbuffer PbufferHandle; | 26 typedef GLXPbuffer PbufferHandle; |
25 | 27 |
26 // This class is a wrapper around a GL context that renders directly to a | 28 // This class is a wrapper around a GL context that renders directly to a |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 144 } |
143 // glxewContextInit really only needs a display connection to | 145 // glxewContextInit really only needs a display connection to |
144 // complete, and we don't want to have to create an OpenGL context | 146 // complete, and we don't want to have to create an OpenGL context |
145 // just to get access to GLX 1.3 entry points to create pbuffers. | 147 // just to get access to GLX 1.3 entry points to create pbuffers. |
146 // We therefore added a glxewContextInitWithDisplay entry point. | 148 // We therefore added a glxewContextInitWithDisplay entry point. |
147 Display* display = x11_util::GetXDisplay(); | 149 Display* display = x11_util::GetXDisplay(); |
148 if (glxewContextInitWithDisplay(display) != GLEW_OK) { | 150 if (glxewContextInitWithDisplay(display) != GLEW_OK) { |
149 LOG(ERROR) << "glxewContextInit failed"; | 151 LOG(ERROR) << "glxewContextInit failed"; |
150 return false; | 152 return false; |
151 } | 153 } |
| 154 |
| 155 int major, minor; |
| 156 if (!glXQueryVersion(display, &major, &minor)) { |
| 157 LOG(ERROR) << "glxQueryVersion failed"; |
| 158 return false; |
| 159 } |
| 160 |
| 161 if (major == 1 && minor < 3) { |
| 162 LOG(WARNING) << "GLX 1.3 or later is recommended."; |
| 163 } |
152 } | 164 } |
153 | 165 |
154 initialized = true; | 166 initialized = true; |
155 return true; | 167 return true; |
156 } | 168 } |
157 | 169 |
158 bool ViewGLContext::Initialize(bool multisampled) { | 170 bool ViewGLContext::Initialize(bool multisampled) { |
159 if (multisampled) { | 171 if (multisampled) { |
160 LOG(WARNING) << "Multisampling not implemented."; | 172 LOG(WARNING) << "Multisampling not implemented."; |
161 } | 173 } |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 | 561 |
550 scoped_ptr<PixmapGLContext> context_pixmap(new PixmapGLContext); | 562 scoped_ptr<PixmapGLContext> context_pixmap(new PixmapGLContext); |
551 if (context_pixmap->Initialize(shared_handle)) | 563 if (context_pixmap->Initialize(shared_handle)) |
552 return context_pixmap.release(); | 564 return context_pixmap.release(); |
553 | 565 |
554 return NULL; | 566 return NULL; |
555 } | 567 } |
556 } | 568 } |
557 | 569 |
558 } // namespace gfx | 570 } // namespace gfx |
OLD | NEW |