blob: 591ab8c2e536f5c7a4390ffe5d33cc513bd42628 [file] [log] [blame]
twiz@google.com59a190b2011-03-14 21:23:01 +00001/*
2 Copyright 2011 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 GrGLInterface_DEFINED
19#define GrGLInterface_DEFINED
20
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000021#include "GrGLConfig.h"
bsalomon@google.combf2a4692011-05-04 12:35:39 +000022#include "GrTypes.h"
twiz@google.com59a190b2011-03-14 21:23:01 +000023
24#if !defined(GR_GL_FUNCTION_TYPE)
25 #define GR_GL_FUNCTION_TYPE
26#endif
27
28////////////////////////////////////////////////////////////////////////////////
29
30/**
31 * Helpers for glGetString()
32 */
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000033
34void gl_version_from_string(int* major, int* minor,
35 const char* versionString);
36bool has_gl_extension_from_string(const char* ext,
37 const char* extensionString);
38
twiz@google.com59a190b2011-03-14 21:23:01 +000039bool has_gl_extension(const char* ext);
40void gl_version(int* major, int* minor);
41
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000042
twiz@google.com59a190b2011-03-14 21:23:01 +000043////////////////////////////////////////////////////////////////////////////////
44
45/*
46 * Routines managing the global interface used to invoke OpenGL calls.
47 */
48struct GrGLInterface;
bsalomon@google.com91826102011-03-21 19:51:57 +000049GR_API GrGLInterface* GrGLGetGLInterface();
50GR_API void GrGLSetGLInterface(GrGLInterface* gl_interface);
twiz@google.com59a190b2011-03-14 21:23:01 +000051
52/*
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000053 * This is called when GrGLSetGLInterface() hasn't been called before creating a
54 * GrGpuGL object. It provides a default implementation. The actual implementation
55 * depends on which GrGLDefaultInterface_*.cpp has been linked. There are some
56 * platform-specific implementations provided as well as
57 * GrGLDefaultInterface_none.cpp which does nothing (effectively requiring an
58 * explicit GrGLSetGLInterface call by the host).
twiz@google.com59a190b2011-03-14 21:23:01 +000059 */
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000060void GrGLSetDefaultGLInterface();
twiz@google.com59a190b2011-03-14 21:23:01 +000061
twiz@google.com0f31ca72011-03-18 17:38:11 +000062typedef unsigned int GrGLenum;
63typedef unsigned char GrGLboolean;
64typedef unsigned int GrGLbitfield;
65typedef signed char GrGLbyte;
66typedef short GrGLshort;
67typedef int GrGLint;
68typedef int GrGLsizei;
69typedef unsigned char GrGLubyte;
70typedef unsigned short GrGLushort;
71typedef unsigned int GrGLuint;
72typedef float GrGLfloat;
73typedef float GrGLclampf;
74typedef double GrGLdouble;
75typedef double GrGLclampd;
76typedef void GrGLvoid;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000077typedef long GrGLintptr;
78typedef long GrGLsizeiptr;
twiz@google.com0f31ca72011-03-18 17:38:11 +000079
twiz@google.comb65e0cb2011-03-18 20:41:44 +000080enum GrGLBinding {
81 kDesktop_GrGLBinding = 0x01,
82 kES1_GrGLBinding = 0x02,
83 kES2_GrGLBinding = 0x04
84};
85
twiz@google.com59a190b2011-03-14 21:23:01 +000086extern "C" {
twiz@google.com0f31ca72011-03-18 17:38:11 +000087 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLActiveTextureProc)(GrGLenum texture);
88 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLAttachShaderProc)(GrGLuint program, GrGLuint shader);
89 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindAttribLocationProc)(GrGLuint program, GrGLuint index, const char* name);
90 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindBufferProc)(GrGLenum target, GrGLuint buffer);
91 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindTextureProc)(GrGLenum target, GrGLuint texture);
92 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
93 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor);
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000094 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage);
95 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferSubDataProc)(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const GrGLvoid* data);
twiz@google.com0f31ca72011-03-18 17:38:11 +000096 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearProc)(GrGLbitfield mask);
97 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
98 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearStencilProc)(GrGLint s);
99 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClientActiveTextureProc)(GrGLenum texture);
100 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColor4ubProc)(GrGLubyte red, GrGLubyte green, GrGLubyte blue, GrGLubyte alpha);
101 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorMaskProc)(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha);
102 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
103 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompileShaderProc)(GrGLuint shader);
104 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompressedTexImage2DProc)(GrGLenum target, GrGLint level, GrGLenum internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLsizei imageSize, const GrGLvoid* data);
105 typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateProgramProc)(void);
106 typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateShaderProc)(GrGLenum type);
107 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCullFaceProc)(GrGLenum mode);
108 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteBuffersProc)(GrGLsizei n, const GrGLuint* buffers);
109 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteProgramProc)(GrGLuint program);
110 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteShaderProc)(GrGLuint shader);
111 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteTexturesProc)(GrGLsizei n, const GrGLuint* textures);
112 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDepthMaskProc)(GrGLboolean flag);
113 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableProc)(GrGLenum cap);
114 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableClientStateProc)(GrGLenum array);
115 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableVertexAttribArrayProc)(GrGLuint index);
116 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawArraysProc)(GrGLenum mode, GrGLint first, GrGLsizei count);
117 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices);
118 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableProc)(GrGLenum cap);
119 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableClientStateProc)(GrGLenum cap);
120 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableVertexAttribArrayProc)(GrGLuint index);
121 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFrontFaceProc)(GrGLenum mode);
122 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenBuffersProc)(GrGLsizei n, GrGLuint* buffers);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000123 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures);
124 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000125 typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLGetErrorProc)(void);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000126 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetIntegervProc)(GrGLenum pname, GrGLint* params);
127 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramInfoLogProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
128 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramivProc)(GrGLuint program, GrGLenum pname, GrGLint* params);
129 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderInfoLogProc)(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
130 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderivProc)(GrGLuint shader, GrGLenum pname, GrGLint* params);
131 typedef const GrGLubyte* (GR_GL_FUNCTION_TYPE *GrGLGetStringProc)(GrGLenum name);
132 typedef GrGLint (GR_GL_FUNCTION_TYPE *GrGLGetUniformLocationProc)(GrGLuint program, const char* name);
133 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLineWidthProc)(GrGLfloat width);
134 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLinkProgramProc)(GrGLuint program);
135 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLoadMatrixfProc)(const GrGLfloat* m);
136 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLMatrixModeProc)(GrGLenum mode);
137 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPixelStoreiProc)(GrGLenum pname, GrGLint param);
138 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPointSizeProc)(GrGLfloat size);
139 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLReadPixelsProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels);
140 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
141 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShadeModelProc)(GrGLenum mode);
142 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShaderSourceProc)(GrGLuint shader, GrGLsizei count, const char** str, const GrGLint* length);
143 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncProc)(GrGLenum func, GrGLint ref, GrGLuint mask);
144 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncSeparateProc)(GrGLenum face, GrGLenum func, GrGLint ref, GrGLuint mask);
145 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskProc)(GrGLuint mask);
146 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskSeparateProc)(GrGLenum face, GrGLuint mask);
147 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpProc)(GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
148 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpSeparateProc)(GrGLenum face, GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
149 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexCoordPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
150 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexEnviProc)(GrGLenum target, GrGLenum pname, GrGLint param);
151 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexImage2DProc)(GrGLenum target, GrGLint level, GrGLint internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLenum format, GrGLenum type, const GrGLvoid* pixels);
152 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexParameteriProc)(GrGLenum target, GrGLenum pname, GrGLint param);
153 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexSubImage2DProc)(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, const GrGLvoid* pixels);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000154 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fProc)(GrGLint location, GrGLfloat v0);
155 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1iProc)(GrGLint location, GrGLint v0);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000156 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000157 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
158 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1);
159 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2iProc)(GrGLint location, GrGLint v0, GrGLint v1);
160 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
161 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
162 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2);
163 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2);
164 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
165 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
166 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2, GrGLfloat v3);
167 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2, GrGLint v3);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000168 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000169 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
170 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix2fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000171 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix3fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000172 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix4fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000173 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUseProgramProc)(GrGLuint program);
174 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttrib4fvProc)(GrGLuint indx, const GrGLfloat* values);
175 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttribPointerProc)(GrGLuint indx, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const GrGLvoid* ptr);
176 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
177 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLViewportProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
twiz@google.com59a190b2011-03-14 21:23:01 +0000178
179 // FBO Extension Functions
twiz@google.com0f31ca72011-03-18 17:38:11 +0000180 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFramebufferProc)(GrGLenum target, GrGLuint framebuffer);
181 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindRenderbufferProc)(GrGLenum target, GrGLuint renderbuffer);
182 typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLCheckFramebufferStatusProc)(GrGLenum target);
183 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteFramebuffersProc)(GrGLsizei n, const GrGLuint *framebuffers);
184 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteRenderbuffersProc)(GrGLsizei n, const GrGLuint *renderbuffers);
185 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferRenderbufferProc)(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer);
186 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferTexture2DProc)(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level);
187 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenFramebuffersProc)(GrGLsizei n, GrGLuint *framebuffers);
188 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenRenderbuffersProc)(GrGLsizei n, GrGLuint *renderbuffers);
189 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
twiz@google.com59a190b2011-03-14 21:23:01 +0000190
191 // Multisampling Extension Functions
192 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
twiz@google.com0f31ca72011-03-18 17:38:11 +0000193 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageMultisampleProc)(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
twiz@google.com59a190b2011-03-14 21:23:01 +0000194 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
twiz@google.com0f31ca72011-03-18 17:38:11 +0000195 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlitFramebufferProc)(GrGLint srcX0, GrGLint srcY0, GrGLint srcX1, GrGLint srcY1, GrGLint dstX0, GrGLint dstY0, GrGLint dstX1, GrGLint dstY1, GrGLbitfield mask, GrGLenum filter);
twiz@google.com59a190b2011-03-14 21:23:01 +0000196 // apple's es extension
twiz@google.com0f31ca72011-03-18 17:38:11 +0000197 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLResolveMultisampleFramebufferProc)();
twiz@google.com59a190b2011-03-14 21:23:01 +0000198
twiz@google.com59a190b2011-03-14 21:23:01 +0000199 // Buffer mapping (extension in ES).
twiz@google.com0f31ca72011-03-18 17:38:11 +0000200 typedef GrGLvoid* (GR_GL_FUNCTION_TYPE *GrGLMapBufferProc)(GrGLenum target, GrGLenum access);
201 typedef GrGLboolean (GR_GL_FUNCTION_TYPE *GrGLUnmapBufferProc)(GrGLenum target);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000202} // extern "C"
203
204/*
205 * The following interface exports the OpenGL entry points used by the system.
206 * Use of OpenGL calls is disallowed. All calls should be invoked through
207 * the global instance of this struct, defined above.
208 *
209 * IMPORTANT NOTE: The OpenGL entry points exposed here include both core GL
210 * functions, and extensions. The system assumes that the address of the
211 * extension pointer will be valid across contexts.
212 */
213struct GrGLInterface {
214 bool validate(GrEngine engine) const;
twiz@google.com59a190b2011-03-14 21:23:01 +0000215
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000216 // Indicator variable specifying the type of GL implementation
217 // exported: GLES{1|2} or Desktop.
218 GrGLBinding fBindingsExported;
219
twiz@google.com59a190b2011-03-14 21:23:01 +0000220 GrGLActiveTextureProc fActiveTexture;
221 GrGLAttachShaderProc fAttachShader;
222 GrGLBindAttribLocationProc fBindAttribLocation;
223 GrGLBindBufferProc fBindBuffer;
224 GrGLBindTextureProc fBindTexture;
bsalomon@google.com080773c2011-03-15 19:09:25 +0000225 GrGLBlendColorProc fBlendColor;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000226 GrGLBlendFuncProc fBlendFunc;
twiz@google.com59a190b2011-03-14 21:23:01 +0000227 GrGLBufferDataProc fBufferData;
228 GrGLBufferSubDataProc fBufferSubData;
229 GrGLClearProc fClear;
230 GrGLClearColorProc fClearColor;
231 GrGLClearStencilProc fClearStencil;
232 GrGLClientActiveTextureProc fClientActiveTexture;
233 GrGLColor4ubProc fColor4ub;
234 GrGLColorMaskProc fColorMask;
235 GrGLColorPointerProc fColorPointer;
236 GrGLCompileShaderProc fCompileShader;
237 GrGLCompressedTexImage2DProc fCompressedTexImage2D;
238 GrGLCreateProgramProc fCreateProgram;
239 GrGLCreateShaderProc fCreateShader;
240 GrGLCullFaceProc fCullFace;
241 GrGLDeleteBuffersProc fDeleteBuffers;
242 GrGLDeleteProgramProc fDeleteProgram;
243 GrGLDeleteShaderProc fDeleteShader;
244 GrGLDeleteTexturesProc fDeleteTextures;
245 GrGLDepthMaskProc fDepthMask;
246 GrGLDisableProc fDisable;
247 GrGLDisableClientStateProc fDisableClientState;
248 GrGLDisableVertexAttribArrayProc fDisableVertexAttribArray;
249 GrGLDrawArraysProc fDrawArrays;
250 GrGLDrawElementsProc fDrawElements;
251 GrGLEnableProc fEnable;
252 GrGLEnableClientStateProc fEnableClientState;
253 GrGLEnableVertexAttribArrayProc fEnableVertexAttribArray;
254 GrGLFrontFaceProc fFrontFace;
255 GrGLGenBuffersProc fGenBuffers;
256 GrGLGenTexturesProc fGenTextures;
257 GrGLGetBufferParameterivProc fGetBufferParameteriv;
258 GrGLGetErrorProc fGetError;
259 GrGLGetIntegervProc fGetIntegerv;
260 GrGLGetProgramInfoLogProc fGetProgramInfoLog;
261 GrGLGetProgramivProc fGetProgramiv;
262 GrGLGetShaderInfoLogProc fGetShaderInfoLog;
263 GrGLGetShaderivProc fGetShaderiv;
264 GrGLGetStringProc fGetString;
265 GrGLGetUniformLocationProc fGetUniformLocation;
266 GrGLLineWidthProc fLineWidth;
267 GrGLLinkProgramProc fLinkProgram;
268 GrGLLoadMatrixfProc fLoadMatrixf;
269 GrGLMatrixModeProc fMatrixMode;
270 GrGLPixelStoreiProc fPixelStorei;
271 GrGLPointSizeProc fPointSize;
272 GrGLReadPixelsProc fReadPixels;
273 GrGLScissorProc fScissor;
274 GrGLShadeModelProc fShadeModel;
275 GrGLShaderSourceProc fShaderSource;
276 GrGLStencilFuncProc fStencilFunc;
277 GrGLStencilFuncSeparateProc fStencilFuncSeparate;
278 GrGLStencilMaskProc fStencilMask;
279 GrGLStencilMaskSeparateProc fStencilMaskSeparate;
280 GrGLStencilOpProc fStencilOp;
281 GrGLStencilOpSeparateProc fStencilOpSeparate;
282 GrGLTexCoordPointerProc fTexCoordPointer;
283 GrGLTexEnviProc fTexEnvi;
284 GrGLTexImage2DProc fTexImage2D;
285 GrGLTexParameteriProc fTexParameteri;
286 GrGLTexSubImage2DProc fTexSubImage2D;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000287 GrGLUniform1fProc fUniform1f;
twiz@google.com59a190b2011-03-14 21:23:01 +0000288 GrGLUniform1iProc fUniform1i;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000289 GrGLUniform1fvProc fUniform1fv;
290 GrGLUniform1ivProc fUniform1iv;
291 GrGLUniform2fProc fUniform2f;
292 GrGLUniform2iProc fUniform2i;
293 GrGLUniform2fvProc fUniform2fv;
294 GrGLUniform2ivProc fUniform2iv;
295 GrGLUniform3fProc fUniform3f;
296 GrGLUniform3iProc fUniform3i;
297 GrGLUniform3fvProc fUniform3fv;
298 GrGLUniform3ivProc fUniform3iv;
299 GrGLUniform4fProc fUniform4f;
300 GrGLUniform4iProc fUniform4i;
twiz@google.com59a190b2011-03-14 21:23:01 +0000301 GrGLUniform4fvProc fUniform4fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000302 GrGLUniform4ivProc fUniform4iv;
303 GrGLUniformMatrix2fvProc fUniformMatrix2fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000304 GrGLUniformMatrix3fvProc fUniformMatrix3fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000305 GrGLUniformMatrix4fvProc fUniformMatrix4fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000306 GrGLUseProgramProc fUseProgram;
307 GrGLVertexAttrib4fvProc fVertexAttrib4fv;
308 GrGLVertexAttribPointerProc fVertexAttribPointer;
309 GrGLVertexPointerProc fVertexPointer;
310 GrGLViewportProc fViewport;
311
312 // FBO Extension Functions
313 GrGLBindFramebufferProc fBindFramebuffer;
314 GrGLBindRenderbufferProc fBindRenderbuffer;
315 GrGLCheckFramebufferStatusProc fCheckFramebufferStatus;
316 GrGLDeleteFramebuffersProc fDeleteFramebuffers;
317 GrGLDeleteRenderbuffersProc fDeleteRenderbuffers;
318 GrGLFramebufferRenderbufferProc fFramebufferRenderbuffer;
319 GrGLFramebufferTexture2DProc fFramebufferTexture2D;
320 GrGLGenFramebuffersProc fGenFramebuffers;
321 GrGLGenRenderbuffersProc fGenRenderbuffers;
322 GrGLRenderbufferStorageProc fRenderbufferStorage;
323
324 // Multisampling Extension Functions
325 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
326 GrGLRenderbufferStorageMultisampleProc fRenderbufferStorageMultisample;
327 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
328 GrGLBlitFramebufferProc fBlitFramebuffer;
329 // apple's es extension
330 GrGLResolveMultisampleFramebufferProc fResolveMultisampleFramebuffer;
331
twiz@google.com59a190b2011-03-14 21:23:01 +0000332 // Buffer mapping (extension in ES).
333 GrGLMapBufferProc fMapBuffer;
334 GrGLUnmapBufferProc fUnmapBuffer;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000335
336 // Code that initializes this struct using a static initializer should
337 // make this the last entry in the static initializer. It can help to guard
338 // against failing to initialize newly-added members of this struct.
339 enum { kStaticInitEndGuard } fStaticInitEndGuard;
twiz@google.com59a190b2011-03-14 21:23:01 +0000340
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000341private:
342 bool validateShaderFunctions() const;
343 bool validateFixedFunctions() const;
344};
twiz@google.com59a190b2011-03-14 21:23:01 +0000345
346#endif