[email protected] | 328ce55f | 2012-04-07 00:33:04 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 5 | #ifndef UI_GL_GL_BINDINGS_H_ |
6 | #define UI_GL_GL_BINDINGS_H_ | ||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 7 | |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 8 | // Includes the platform independent and platform dependent GL headers. |
9 | // Only include this in cc files. It pulls in system headers, including | ||||
10 | // the X11 headers on linux, which define all kinds of macros that are | ||||
11 | // liable to cause conflicts. | ||||
12 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 13 | #include <GL/gl.h> |
14 | #include <GL/glext.h> | ||||
[email protected] | b040f9d | 2013-01-19 04:27:00 | [diff] [blame^] | 15 | #include <EGL/egl.h> |
16 | #include <EGL/eglext.h> | ||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 17 | |
[email protected] | 218a5a2 | 2010-11-04 19:27:49 | [diff] [blame] | 18 | #include "base/logging.h" |
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 19 | #include "build/build_config.h" |
20 | #include "ui/gl/gl_export.h" | ||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 21 | |
22 | // The standard OpenGL native extension headers are also included. | ||||
23 | #if defined(OS_WIN) | ||||
24 | #include <GL/wglext.h> | ||||
[email protected] | 2ec8df5 | 2011-05-25 23:44:58 | [diff] [blame] | 25 | #elif defined(OS_MACOSX) |
26 | #include <OpenGL/OpenGL.h> | ||||
27 | #elif defined(USE_X11) | ||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 28 | #include <GL/glx.h> |
29 | #include <GL/glxext.h> | ||||
[email protected] | 31c31b2b | 2011-09-27 18:58:29 | [diff] [blame] | 30 | |
31 | // Undefine some macros defined by X headers. This is why this file should only | ||||
32 | // be included in .cc files. | ||||
33 | #undef Bool | ||||
34 | #undef None | ||||
35 | #undef Status | ||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 36 | #endif |
37 | |||||
38 | #if defined(OS_WIN) | ||||
39 | #define GL_BINDING_CALL WINAPI | ||||
40 | #else | ||||
41 | #define GL_BINDING_CALL | ||||
42 | #endif | ||||
43 | |||||
[email protected] | 218a5a2 | 2010-11-04 19:27:49 | [diff] [blame] | 44 | #define GL_SERVICE_LOG(args) DLOG(INFO) << args; |
[email protected] | 5a83fca | 2012-04-22 02:05:08 | [diff] [blame] | 45 | #if defined(NDEBUG) |
[email protected] | 92afb77 | 2011-12-09 01:49:56 | [diff] [blame] | 46 | #define GL_SERVICE_LOG_CODE_BLOCK(code) |
47 | #else | ||||
48 | #define GL_SERVICE_LOG_CODE_BLOCK(code) code | ||||
49 | #endif | ||||
[email protected] | 218a5a2 | 2010-11-04 19:27:49 | [diff] [blame] | 50 | |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 51 | // Forward declare OSMesa types. |
52 | typedef struct osmesa_context *OSMesaContext; | ||||
53 | typedef void (*OSMESAproc)(); | ||||
54 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 55 | // Forward declare EGL types. |
[email protected] | 83f48ae | 2013-01-14 14:12:53 | [diff] [blame] | 56 | typedef uint64 EGLuint64CHROMIUM; |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 57 | |
58 | #include "gl_bindings_autogen_gl.h" | ||||
59 | #include "gl_bindings_autogen_osmesa.h" | ||||
60 | |||||
61 | #if defined(OS_WIN) | ||||
62 | #include "gl_bindings_autogen_egl.h" | ||||
63 | #include "gl_bindings_autogen_wgl.h" | ||||
[email protected] | 2ec8df5 | 2011-05-25 23:44:58 | [diff] [blame] | 64 | #elif defined(USE_X11) |
[email protected] | 0bec8e2 | 2010-06-21 22:20:02 | [diff] [blame] | 65 | #include "gl_bindings_autogen_egl.h" |
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 66 | #include "gl_bindings_autogen_glx.h" |
[email protected] | c8e295b | 2011-11-21 21:24:14 | [diff] [blame] | 67 | #elif defined(OS_ANDROID) |
68 | #include "gl_bindings_autogen_egl.h" | ||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 69 | #endif |
70 | |||||
71 | namespace gfx { | ||||
72 | |||||
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 73 | GL_EXPORT extern GLApi* g_current_gl_context; |
74 | GL_EXPORT extern OSMESAApi* g_current_osmesa_context; | ||||
75 | GL_EXPORT extern DriverGL g_driver_gl; | ||||
76 | GL_EXPORT extern DriverOSMESA g_driver_osmesa; | ||||
77 | |||||
78 | #if defined(OS_WIN) | ||||
79 | |||||
80 | GL_EXPORT extern EGLApi* g_current_egl_context; | ||||
81 | GL_EXPORT extern WGLApi* g_current_wgl_context; | ||||
82 | GL_EXPORT extern DriverEGL g_driver_egl; | ||||
83 | GL_EXPORT extern DriverWGL g_driver_wgl; | ||||
84 | |||||
85 | #elif defined(USE_X11) | ||||
86 | |||||
87 | GL_EXPORT extern EGLApi* g_current_egl_context; | ||||
88 | GL_EXPORT extern GLXApi* g_current_glx_context; | ||||
89 | GL_EXPORT extern DriverEGL g_driver_egl; | ||||
90 | GL_EXPORT extern DriverGLX g_driver_glx; | ||||
91 | |||||
92 | #elif defined(OS_ANDROID) | ||||
93 | |||||
94 | GL_EXPORT extern EGLApi* g_current_egl_context; | ||||
95 | GL_EXPORT extern DriverEGL g_driver_egl; | ||||
96 | |||||
97 | #endif | ||||
98 | |||||
[email protected] | b9363b2 | 2010-06-09 22:06:15 | [diff] [blame] | 99 | // Find an entry point to the mock GL implementation. |
100 | void* GL_BINDING_CALL GetMockGLProcAddress(const char* name); | ||||
101 | |||||
102 | } // namespace gfx | ||||
103 | |||||
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 104 | #endif // UI_GL_GL_BINDINGS_H_ |