blob: c467f99c67ccc870684c102c48232416e4e5340f [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
2 Copyright 2010 Google Inc.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17
18#ifndef GrGLConfig_DEFINED
19#define GrGLConfig_DEFINED
20
21#include "GrTypes.h"
22
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +000023#if !defined(GR_GL_CUSTOM_SETUP)
24 #define GR_GL_CUSTOM_SETUP 0
25#endif
26/**
27 * We need to pull in the right GL headers and determine whether we are
28 * compiling for ES1, ES2, or desktop GL. (We allow ES1 and ES2 to both be
29 * supported in the same build but not ESx and desktop). We also need to know
30 * the platform-specific way to get extension function pointers (e.g.
31 * eglGetProcAddress). The port specifies this info explicitly or we will infer
32 * it from the GR_*_BUILD flag.
33 *
34 * To specify GL setup directly define GR_GL_CUSTOM_SETUP to 1 and define:
35 * GR_SUPPORT_GLDESKTOP or (GR_SUPPORT_GLES1 and/or GR_SUPPORT_GLES2) to 1
36 *
37 * if GR_SUPPORT_GLDESKTOP is 1 then provide:
38 * 1. The name of your GL header in GR_INCLUDE_GLDESKTOP
39 * 2. If necessary, the name of a file that includes extension
40 * definitions in GR_INCLUDE_GLDESKTOPext.
41 * if GR_SUPPORT_GLES1 is 1 then provide:
42 * 1. The name of your GL header in GR_INCLUDE_GLES1
43 * 2. If necessary, the name of a file that includes extension
44 * definitions in GR_INCLUDE_GLES1ext.
45 * if GR_SUPPORT_GLES2 is 1 then provide:
46 * 1. The name of your GL header in GR_INCLUDE_GLES2
47 * 2. If necessary, the name of a file that includes extension
48 * definitions in GR_INCLUDE_GLES2ext.
49 *
50 * Optionally, define GR_GL_FUNC to any qualifier needed on GL function
51 * pointer declarations (e.g. __stdcall).
52 *
53 * Define GR_GL_PROC_ADDRESS to take a gl function and produce a
54 * function pointer. Two examples:
55 * 1. Your platform doesn't require a proc address function, just take
56 * the address of the function:
57 * #define GR_GL_PROC_ADDRESS(X) &X
58 * 2. Your platform uses eglGetProcAddress:
59 * #define GR_GL_PROC_ADDRESS eglGetProcAddress(#X)
60 *
61 * Optionally define GR_GL_PROC_ADDRESS_HEADER to include any additional
62 * header necessary to use GR_GL_PROC_ADDRESS (e.g. <EGL/egl.h>)
63 *
64 * Alternatively, define GR_GL_CUSTOM_SETUP_HEADER (and not GR_GL_CUSTOM_SETUP)
65 * to a header that can be included. This file should:
66 * 1. Define the approprate GR_SUPPORT_GL* macro(s) to 1
67 * 2. Includes all necessary GL headers.
68 * 3. Optionally define GR_GL_FUNC.
69 * 4. Define GR_GL_PROC_ADDRESS.
70 * 5. Optionally define GR_GL_PROC_ADDRESS_HEADER
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +000071 *
bsalomon@google.com1c13c962011-02-14 16:51:21 +000072 *------------------------------------------------------------------------------
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +000073 *
bsalomon@google.com3723a482011-02-17 21:47:25 +000074 * The following are optional defines that can be enabled at the compiler
75 * command line, in a IDE project, in a GrUserConfig.h file, or in a GL custom
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +000076 * file (if one is in use). They don't require GR_GL_CUSTOM_SETUP or
bsalomon@google.com3723a482011-02-17 21:47:25 +000077 * setup GR_GL_CUSTOM_SETUP_HEADER to be enabled:
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +000078 *
bsalomon@google.com3723a482011-02-17 21:47:25 +000079 * GR_GL_LOG_CALLS: if 1 Gr can print every GL call using GrPrintf. Defaults to
reed@google.com27a1e772011-03-08 15:34:06 +000080 * 0. Logging can be enabled and disabled at runtime using a debugger via to
bsalomon@google.com3723a482011-02-17 21:47:25 +000081 * global gLogCallsGL. The initial value of gLogCallsGL is controlled by
82 * GR_GL_LOG_CALLS_START.
83 *
84 * GR_GL_LOG_CALLS_START: controls the initial value of gLogCallsGL when
85 * GR_GL_LOG_CALLS is 1. Defaults to 0.
86 *
87 * GR_GL_CHECK_ERROR: if enabled Gr can do a glGetError() after every GL call.
reed@google.com27a1e772011-03-08 15:34:06 +000088 * Defaults to 1 if GR_DEBUG is set, otherwise 0. When GR_GL_CHECK_ERROR is 1
bsalomon@google.com3723a482011-02-17 21:47:25 +000089 * this can be toggled in a debugger using the gCheckErrorGL global. The initial
90 * value of gCheckErrorGL is controlled by by GR_GL_CHECK_ERROR_START.
91 *
92 * GR_GL_CHECK_ERROR_START: controls the initial value of gCheckErrorGL
93 * when GR_GL_CHECK_ERROR is 1. Defaults to 1.
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +000094 */
95
96#if GR_GL_CUSTOM_SETUP
97
98 #ifdef GR_SUPPORT_GLES1
99 #include GR_INCLUDE_GLES1
100 #if defined(GR_INCLUDE_GLES1ext)
101 #include GR_INCLUDE_GLES1ext
102 #endif
reed@google.comac10a2d2010-12-22 21:39:39 +0000103 #endif
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000104
105 #ifdef GR_SUPPORT_GLES2
106 #include GR_INCLUDE_GLES2
107 #if defined(GR_INCLUDE_GLES2ext)
108 #include GR_INCLUDE_GLES2ext
109 #endif
reed@google.comac10a2d2010-12-22 21:39:39 +0000110 #endif
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000111
112 #ifdef GR_SUPPORT_GLDESKTOP
113 #include GR_INCLUDE_GLDESKTOP
114 #if defined(GR_INCLUDE_GLDESKTOPext)
115 #include GR_INCLUDE_GLDESKTOPext
116 #endif
reed@google.comac10a2d2010-12-22 21:39:39 +0000117 #endif
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000118
119#elif defined(GR_GL_CUSTOM_SETUP_HEADER)
120
121 #include GR_GL_CUSTOM_SETUP_HEADER
122
reed@google.comac10a2d2010-12-22 21:39:39 +0000123#else
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000124 #undef GR_GL_FUNC
125 #undef GR_GL_PROC_ADDRESS
126 #undef GR_GL_PROC_ADDRESS_HEADER
reed@google.comac10a2d2010-12-22 21:39:39 +0000127
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000128 #if GR_WIN32_BUILD
129 #define GR_SUPPORT_GLDESKTOP 1
130 // glew has to be included before gl
131 #include <GL/glew.h>
132 #include <GL/gl.h>
133 // remove stupid windows defines
134 #undef near
135 #undef far
136 #define GR_GL_FUNC __stdcall
137 #define GR_GL_PROC_ADDRESS(X) wglGetProcAddress(#X)
138 #define GR_GL_PROC_ADDRESS_HEADER <windows.h>
139 #elif GR_MAC_BUILD
140 #define GR_SUPPORT_GLDESKTOP 1
141 #include <OpenGL/gl.h>
142 #include <OpenGL/glext.h>
143 #define GR_GL_PROC_ADDRESS(X) &X
144 #elif GR_IOS_BUILD
145 #define GR_SUPPORT_GLES1 1
146 #include <OpenGLES/ES1/gl.h>
147 #include <OpenGLES/ES1/glext.h>
148 #define GR_SUPPORT_GLES2 1
149 #include <OpenGLES/ES2/gl.h>
150 #include <OpenGLES/ES2/glext.h>
151 #define GR_GL_PROC_ADDRESS(X) &X
152 #elif GR_ANDROID_BUILD
153 #ifndef GL_GLEXT_PROTOTYPES
154 #define GL_GLEXT_PROTOTYPES
155 #endif
156 #define GR_SUPPORT_GLES2 1
157 #include <GLES2/gl2.h>
158 #include <GLES2/gl2ext.h>
159 #define GR_GL_PROC_ADDRESS(X) eglGetProcAddress(#X)
160 #define GR_GL_PROC_ADDRESS_HEADER <EGL/egl.h>
161 #elif GR_QNX_BUILD
162 #ifndef GL_GLEXT_PROTOTYPES
163 #define GL_GLEXT_PROTOTYPES
164 #endif
165 #define GR_SUPPORT_GLES2 1
166 // This is needed by the QNX GLES2 headers
167 #define GL_API_EXT
168 #include <GLES2/gl2.h>
169 #include <GLES2/gl2ext.h>
170 #define GR_GL_PROC_ADDRESS(X) eglGetProcAddress(#X)
171 #define GR_GL_PROC_ADDRESS_HEADER <EGL/egl.h>
172 #elif GR_LINUX_BUILD
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000173 #ifndef GL_GLEXT_PROTOTYPES
174 #define GL_GLEXT_PROTOTYPES
reed@google.com9341bb62011-01-26 17:11:51 +0000175 #endif
reed@google.come42e8452011-01-26 17:20:51 +0000176 #define GL_EXT_framebuffer_blit 0
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000177 #include <GL/gl.h>
178 #include <GL/glext.h>
reed@google.com9341bb62011-01-26 17:11:51 +0000179 #define GR_GL_PROC_ADDRESS(X) &X
reed@google.come42e8452011-01-26 17:20:51 +0000180 #define GR_SUPPORT_GLDESKTOP 1
reed@google.comac10a2d2010-12-22 21:39:39 +0000181 #else
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000182 #error "unsupported GR_???_BUILD"
reed@google.comac10a2d2010-12-22 21:39:39 +0000183 #endif
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000184
reed@google.comac10a2d2010-12-22 21:39:39 +0000185#endif
186
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000187#if !defined(GR_SUPPORT_GLDESKTOP)
188 #define GR_SUPPORT_GLDESKTOP 0
189#endif
190#if !defined(GR_SUPPORT_GLES1)
191 #define GR_SUPPORT_GLES1 0
192#endif
193#if !defined(GR_SUPPORT_GLES2)
194 #define GR_SUPPORT_GLES2 0
reed@google.comac10a2d2010-12-22 21:39:39 +0000195#endif
196
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000197#define GR_SUPPORT_GLES ((GR_SUPPORT_GLES1) || (GR_SUPPORT_GLES2))
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000198
reed@google.combf858b72011-01-19 19:04:04 +0000199#if !GR_SUPPORT_GLES && !GR_SUPPORT_GLDESKTOP
200 #error "Either desktop or ES GL must be supported"
201#elif GR_SUPPORT_GLES && GR_SUPPORT_GLDESKTOP
202 #error "Cannot support both desktop and ES GL"
reed@google.comac10a2d2010-12-22 21:39:39 +0000203#endif
204
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000205#if !defined(GR_GL_FUNC)
206 #define GR_GL_FUNC
reed@google.comac10a2d2010-12-22 21:39:39 +0000207#endif
208
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000209#if !defined(GR_GL_PROC_ADDRESS)
210 #error "Must define GR_GL_PROC_ADDRESS"
reed@google.comac10a2d2010-12-22 21:39:39 +0000211#endif
212
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000213#if !defined(GR_GL_LOG_CALLS)
bsalomon@google.com3723a482011-02-17 21:47:25 +0000214 #define GR_GL_LOG_CALLS 0
215#endif
216
217#if !defined(GR_GL_LOG_CALLS_START)
218 #define GR_GL_LOG_CALLS_START 0
219#endif
220
reed@google.com27a1e772011-03-08 15:34:06 +0000221#if !defined(GR_GL_CHECK_ERROR)
bsalomon@google.com3723a482011-02-17 21:47:25 +0000222 #define GR_GL_CHECK_ERROR GR_DEBUG
223#endif
224
225#if !defined(GR_GL_CHECK_ERROR_START)
226 #define GR_GL_CHECK_ERROR_START 1
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000227#endif
228
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000229////////////////////////////////////////////////////////////////////////////////
reed@google.comac10a2d2010-12-22 21:39:39 +0000230
reed@google.comac10a2d2010-12-22 21:39:39 +0000231#if GR_SCALAR_IS_FIXED
232 #define GrGLType GL_FIXED
233#elif GR_SCALAR_IS_FLOAT
234 #define GrGLType GL_FLOAT
235#else
236 #error "unknown GR_SCALAR type"
237#endif
238
239#if GR_TEXT_SCALAR_IS_USHORT
240 #define GrGLTextType GL_UNSIGNED_SHORT
241 #define GR_GL_TEXT_TEXTURE_NORMALIZED 1
242#elif GR_TEXT_SCALAR_IS_FLOAT
243 #define GrGLTextType GL_FLOAT
244 #define GR_GL_TEXT_TEXTURE_NORMALIZED 0
245#elif GR_TEXT_SCALAR_IS_FIXED
246 #define GrGLTextType GL_FIXED
247 #define GR_GL_TEXT_TEXTURE_NORMALIZED 0
reed@google.com63100f92011-01-18 21:32:14 +0000248#else
reed@google.comac10a2d2010-12-22 21:39:39 +0000249 #error "unknown GR_TEXT_SCALAR type"
250#endif
251
bsalomon@google.com2fbc7fa2011-01-05 16:34:41 +0000252// Pick a pixel config for 32bit bitmaps. Our default is GL_RGBA (expect on
253// Windows where we match GDI's order).
254#ifndef GR_GL_32BPP_COLOR_FORMAT
255 #if GR_WIN32_BUILD
bsalomon@google.comed3a0682011-01-18 16:54:04 +0000256 #define GR_GL_32BPP_COLOR_FORMAT GR_BGRA //use GR prefix because this
257 #else //may be an extension.
bsalomon@google.com2fbc7fa2011-01-05 16:34:41 +0000258 #define GR_GL_32BPP_COLOR_FORMAT GL_RGBA
259 #endif
reed@google.comac10a2d2010-12-22 21:39:39 +0000260#endif
261
262////////////////////////////////////////////////////////////////////////////////
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000263// Setup for opengl ES/desktop extensions
264// We make a struct of function pointers so that each GL context
reed@google.com63100f92011-01-18 21:32:14 +0000265// can have it's own struct. (Some environments may have different proc
reed@google.comac10a2d2010-12-22 21:39:39 +0000266// addresses for different contexts).
267
268extern "C" {
269struct GrGLExts {
270// FBO
271 GLvoid (GR_GL_FUNC *GenFramebuffers)(GLsizei n, GLuint *framebuffers);
272 GLvoid (GR_GL_FUNC *BindFramebuffer)(GLenum target, GLuint framebuffer);
273 GLvoid (GR_GL_FUNC *FramebufferTexture2D)(GLenum target, GLenum attachment,
reed@google.com63100f92011-01-18 21:32:14 +0000274 GLenum textarget, GLuint texture,
reed@google.comac10a2d2010-12-22 21:39:39 +0000275 GLint level);
276 GLenum (GR_GL_FUNC *CheckFramebufferStatus)(GLenum target);
reed@google.com63100f92011-01-18 21:32:14 +0000277 GLvoid (GR_GL_FUNC *DeleteFramebuffers)(GLsizei n, const
reed@google.comac10a2d2010-12-22 21:39:39 +0000278 GLuint *framebuffers);
reed@google.com63100f92011-01-18 21:32:14 +0000279 GLvoid (GR_GL_FUNC *RenderbufferStorage)(GLenum target,
reed@google.comac10a2d2010-12-22 21:39:39 +0000280 GLenum internalformat,
281 GLsizei width, GLsizei height);
282 GLvoid (GR_GL_FUNC *GenRenderbuffers)(GLsizei n, GLuint *renderbuffers);
reed@google.com63100f92011-01-18 21:32:14 +0000283 GLvoid (GR_GL_FUNC *DeleteRenderbuffers)(GLsizei n,
reed@google.comac10a2d2010-12-22 21:39:39 +0000284 const GLuint *renderbuffers);
reed@google.com63100f92011-01-18 21:32:14 +0000285 GLvoid (GR_GL_FUNC *FramebufferRenderbuffer)(GLenum target,
reed@google.comac10a2d2010-12-22 21:39:39 +0000286 GLenum attachment,
reed@google.com63100f92011-01-18 21:32:14 +0000287 GLenum renderbuffertarget,
reed@google.comac10a2d2010-12-22 21:39:39 +0000288 GLuint renderbuffer);
289 GLvoid (GR_GL_FUNC *BindRenderbuffer)(GLenum target, GLuint renderbuffer);
290
291// Multisampling
292 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
reed@google.com63100f92011-01-18 21:32:14 +0000293 GLvoid (GR_GL_FUNC *RenderbufferStorageMultisample)(GLenum target,
reed@google.comac10a2d2010-12-22 21:39:39 +0000294 GLsizei samples,
295 GLenum internalformat,
reed@google.com63100f92011-01-18 21:32:14 +0000296 GLsizei width,
reed@google.comac10a2d2010-12-22 21:39:39 +0000297 GLsizei height);
298 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
reed@google.com63100f92011-01-18 21:32:14 +0000299 GLvoid (GR_GL_FUNC *BlitFramebuffer)(GLint srcX0, GLint srcY0,
reed@google.comac10a2d2010-12-22 21:39:39 +0000300 GLint srcX1, GLint srcY1,
reed@google.com63100f92011-01-18 21:32:14 +0000301 GLint dstX0, GLint dstY0,
reed@google.comac10a2d2010-12-22 21:39:39 +0000302 GLint dstX1, GLint dstY1,
303 GLbitfield mask, GLenum filter);
304 // apple's es extension
305 GLvoid (GR_GL_FUNC *ResolveMultisampleFramebuffer)();
306
307 // IMG'e es extension
reed@google.com63100f92011-01-18 21:32:14 +0000308 GLvoid (GR_GL_FUNC *FramebufferTexture2DMultisample)(GLenum target,
reed@google.comac10a2d2010-12-22 21:39:39 +0000309 GLenum attachment,
reed@google.com63100f92011-01-18 21:32:14 +0000310 GLenum textarget,
311 GLuint texture,
312 GLint level,
reed@google.comac10a2d2010-12-22 21:39:39 +0000313 GLsizei samples);
314
315// Buffer mapping (extension in ES).
316 GLvoid* (GR_GL_FUNC *MapBuffer)(GLenum target, GLenum access);
317 GLboolean (GR_GL_FUNC *UnmapBuffer)(GLenum target);
318};
319}
320
bsalomon@google.comed3a0682011-01-18 16:54:04 +0000321// BGRA format
322
323#define GR_BGRA 0x80E1
324
bsalomon@google.com3f3ffd62011-01-18 17:14:52 +0000325// FBO / stencil formats
reed@google.comac10a2d2010-12-22 21:39:39 +0000326#define GR_FRAMEBUFFER 0x8D40
327#define GR_FRAMEBUFFER_COMPLETE 0x8CD5
328#define GR_COLOR_ATTACHMENT0 0x8CE0
reed@google.com63100f92011-01-18 21:32:14 +0000329#define GR_FRAMEBUFFER_BINDING 0x8CA6
reed@google.comac10a2d2010-12-22 21:39:39 +0000330#define GR_RENDERBUFFER 0x8D41
331#define GR_STENCIL_ATTACHMENT 0x8D20
bsalomon@google.com3f3ffd62011-01-18 17:14:52 +0000332#define GR_STENCIL_INDEX4 0x8D47
reed@google.comac10a2d2010-12-22 21:39:39 +0000333#define GR_STENCIL_INDEX8 0x8D48
334#define GR_STENCIL_INDEX16 0x8D49
bsalomon@google.com3f3ffd62011-01-18 17:14:52 +0000335#define GR_DEPTH24_STENCIL8 0x88F0
reed@google.comac10a2d2010-12-22 21:39:39 +0000336#define GR_MAX_RENDERBUFFER_SIZE 0x84E8
337#define GR_DEPTH_STENCIL_ATTACHMENT 0x821A
reed@google.comac10a2d2010-12-22 21:39:39 +0000338#define GR_DEPTH_STENCIL 0x84F9
339#define GR_RGBA8 0x8058
340#define GR_RGB565 0x8D62
341
342
343// Multisampling
344
345// IMG MAX_SAMPLES uses a different value than desktop, Apple ES extension.
346#define GR_MAX_SAMPLES 0x8D57
347#define GR_MAX_SAMPLES_IMG 0x9135
348#define GR_READ_FRAMEBUFFER 0x8CA8
349#define GR_DRAW_FRAMEBUFFER 0x8CA9
350
351// Buffer mapping
352#define GR_WRITE_ONLY 0x88B9
353#define GR_BUFFER_MAPPED 0x88BC
354
355// Palette texture
356#define GR_PALETTE8_RGBA8 0x8B91
357
358extern void GrGLInitExtensions(GrGLExts* exts);
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +0000359
reed@google.comac10a2d2010-12-22 21:39:39 +0000360////////////////////////////////////////////////////////////////////////////////
reed@google.com63100f92011-01-18 21:32:14 +0000361
reed@google.comac10a2d2010-12-22 21:39:39 +0000362extern void GrGLCheckErr(const char* location, const char* call);
363
364static inline void GrGLClearErr() {
reed@google.com63100f92011-01-18 21:32:14 +0000365 while (GL_NO_ERROR != glGetError()) {}
reed@google.comac10a2d2010-12-22 21:39:39 +0000366}
367
bsalomon@google.com3723a482011-02-17 21:47:25 +0000368#if GR_GL_CHECK_ERROR
369 extern bool gCheckErrorGL;
370 #define GR_GL_CHECK_ERROR_IMPL(X) if (gCheckErrorGL) GrGLCheckErr(GR_FILE_AND_LINE_STR, #X)
reed@google.comac10a2d2010-12-22 21:39:39 +0000371#else
bsalomon@google.com3723a482011-02-17 21:47:25 +0000372 #define GR_GL_CHECK_ERROR_IMPL(X)
reed@google.comac10a2d2010-12-22 21:39:39 +0000373#endif
reed@google.comac10a2d2010-12-22 21:39:39 +0000374
375#if GR_GL_LOG_CALLS
bsalomon@google.com3723a482011-02-17 21:47:25 +0000376 extern bool gLogCallsGL;
377 #define GR_GL_LOG_CALLS_IMPL(X) if (gLogCallsGL) GrPrintf(GR_FILE_AND_LINE_STR "GL: " #X "\n")
reed@google.comac10a2d2010-12-22 21:39:39 +0000378#else
bsalomon@google.com3723a482011-02-17 21:47:25 +0000379 #define GR_GL_LOG_CALLS_IMPL(X)
reed@google.comac10a2d2010-12-22 21:39:39 +0000380#endif
381
bsalomon@google.com3723a482011-02-17 21:47:25 +0000382#define GR_GL(X) gl ## X; GR_GL_LOG_CALLS_IMPL(X); GR_GL_CHECK_ERROR_IMPL(X);
383#define GR_GL_NO_ERR(X) GrGLClearErr(); gl ## X; GR_GL_LOG_CALLS_IMPL(X); GR_GL_CHECK_ERROR_IMPL(X);
384#define GR_GLEXT(exts, X) exts. X; GR_GL_LOG_CALLS_IMPL(X); GR_GL_CHECK_ERROR_IMPL(X);
385#define GR_GLEXT_NO_ERR(exts, X) GrGLClearErr(); exts. X; GR_GL_LOG_CALLS_IMPL(X); GR_GL_CHECK_ERROR_IMPL(X);
386
bsalomon@google.com8895a7a2011-02-18 16:09:55 +0000387////////////////////////////////////////////////////////////////////////////////
388
389/**
390 * Helpers for glGetString()
391 */
392bool has_gl_extension(const char* ext);
393void gl_version(int* major, int* minor);
394
395////////////////////////////////////////////////////////////////////////////////
396
397/**
398 * GrGL_RestoreResetRowLength() will reset GL_UNPACK_ROW_LENGTH to 0. We write
399 * this wrapper, since GL_UNPACK_ROW_LENGTH is not available on all GL versions
400 */
401#if GR_SUPPORT_GLDESKTOP
402 static inline void GrGL_RestoreResetRowLength() {
403 GR_GL(PixelStorei(GL_UNPACK_ROW_LENGTH, 0));
404 }
405#else
406 #define GrGL_RestoreResetRowLength()
407#endif
408
409////////////////////////////////////////////////////////////////////////////////
410
411/**
412 * Some drivers want the var-int arg to be zero-initialized on input.
413 */
414#define GR_GL_INIT_ZERO 0
415#define GR_GL_GetIntegerv(e, p) \
416 do { \
417 *(p) = GR_GL_INIT_ZERO; \
418 GR_GL(GetIntegerv(e, p)); \
419 } while (0)
420
421////////////////////////////////////////////////////////////////////////////////
422
reed@google.com27a1e772011-03-08 15:34:06 +0000423#endif