blob: 150e8e469af20976cc969fd33684b3bd02cefbee [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;
bsalomon@google.com271cffc2011-05-20 14:13:56 +000066typedef char GrGLchar;
twiz@google.com0f31ca72011-03-18 17:38:11 +000067typedef short GrGLshort;
68typedef int GrGLint;
69typedef int GrGLsizei;
70typedef unsigned char GrGLubyte;
71typedef unsigned short GrGLushort;
72typedef unsigned int GrGLuint;
73typedef float GrGLfloat;
74typedef float GrGLclampf;
75typedef double GrGLdouble;
76typedef double GrGLclampd;
77typedef void GrGLvoid;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000078typedef long GrGLintptr;
79typedef long GrGLsizeiptr;
twiz@google.com0f31ca72011-03-18 17:38:11 +000080
twiz@google.comb65e0cb2011-03-18 20:41:44 +000081enum GrGLBinding {
82 kDesktop_GrGLBinding = 0x01,
83 kES1_GrGLBinding = 0x02,
84 kES2_GrGLBinding = 0x04
85};
86
twiz@google.com59a190b2011-03-14 21:23:01 +000087extern "C" {
twiz@google.com0f31ca72011-03-18 17:38:11 +000088 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLActiveTextureProc)(GrGLenum texture);
89 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLAttachShaderProc)(GrGLuint program, GrGLuint shader);
90 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindAttribLocationProc)(GrGLuint program, GrGLuint index, const char* name);
91 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindBufferProc)(GrGLenum target, GrGLuint buffer);
92 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindTextureProc)(GrGLenum target, GrGLuint texture);
93 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
94 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor);
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000095 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage);
96 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferSubDataProc)(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const GrGLvoid* data);
twiz@google.com0f31ca72011-03-18 17:38:11 +000097 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearProc)(GrGLbitfield mask);
98 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
99 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearStencilProc)(GrGLint s);
100 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClientActiveTextureProc)(GrGLenum texture);
101 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColor4ubProc)(GrGLubyte red, GrGLubyte green, GrGLubyte blue, GrGLubyte alpha);
102 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorMaskProc)(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha);
103 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
104 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompileShaderProc)(GrGLuint shader);
105 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompressedTexImage2DProc)(GrGLenum target, GrGLint level, GrGLenum internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLsizei imageSize, const GrGLvoid* data);
106 typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateProgramProc)(void);
107 typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateShaderProc)(GrGLenum type);
108 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCullFaceProc)(GrGLenum mode);
109 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteBuffersProc)(GrGLsizei n, const GrGLuint* buffers);
110 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteProgramProc)(GrGLuint program);
111 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteShaderProc)(GrGLuint shader);
112 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteTexturesProc)(GrGLsizei n, const GrGLuint* textures);
113 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDepthMaskProc)(GrGLboolean flag);
114 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableProc)(GrGLenum cap);
115 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableClientStateProc)(GrGLenum array);
116 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableVertexAttribArrayProc)(GrGLuint index);
117 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawArraysProc)(GrGLenum mode, GrGLint first, GrGLsizei count);
118 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices);
119 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableProc)(GrGLenum cap);
120 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableClientStateProc)(GrGLenum cap);
121 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableVertexAttribArrayProc)(GrGLuint index);
122 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFrontFaceProc)(GrGLenum mode);
123 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenBuffersProc)(GrGLsizei n, GrGLuint* buffers);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000124 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures);
125 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000126 typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLGetErrorProc)(void);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000127 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetIntegervProc)(GrGLenum pname, GrGLint* params);
128 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramInfoLogProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
129 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramivProc)(GrGLuint program, GrGLenum pname, GrGLint* params);
130 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderInfoLogProc)(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
131 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderivProc)(GrGLuint shader, GrGLenum pname, GrGLint* params);
132 typedef const GrGLubyte* (GR_GL_FUNCTION_TYPE *GrGLGetStringProc)(GrGLenum name);
133 typedef GrGLint (GR_GL_FUNCTION_TYPE *GrGLGetUniformLocationProc)(GrGLuint program, const char* name);
134 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLineWidthProc)(GrGLfloat width);
135 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLinkProgramProc)(GrGLuint program);
136 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLoadMatrixfProc)(const GrGLfloat* m);
137 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLMatrixModeProc)(GrGLenum mode);
138 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPixelStoreiProc)(GrGLenum pname, GrGLint param);
139 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPointSizeProc)(GrGLfloat size);
140 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLReadPixelsProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels);
141 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
142 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShadeModelProc)(GrGLenum mode);
143 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShaderSourceProc)(GrGLuint shader, GrGLsizei count, const char** str, const GrGLint* length);
144 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncProc)(GrGLenum func, GrGLint ref, GrGLuint mask);
145 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncSeparateProc)(GrGLenum face, GrGLenum func, GrGLint ref, GrGLuint mask);
146 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskProc)(GrGLuint mask);
147 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskSeparateProc)(GrGLenum face, GrGLuint mask);
148 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpProc)(GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
149 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpSeparateProc)(GrGLenum face, GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
150 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexCoordPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
151 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexEnviProc)(GrGLenum target, GrGLenum pname, GrGLint param);
152 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);
153 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexParameteriProc)(GrGLenum target, GrGLenum pname, GrGLint param);
154 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 +0000155 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fProc)(GrGLint location, GrGLfloat v0);
156 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1iProc)(GrGLint location, GrGLint v0);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000157 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000158 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
159 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1);
160 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2iProc)(GrGLint location, GrGLint v0, GrGLint v1);
161 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
162 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
163 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2);
164 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2);
165 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
166 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
167 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2, GrGLfloat v3);
168 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 +0000169 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000170 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
171 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix2fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000172 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix3fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000173 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix4fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000174 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUseProgramProc)(GrGLuint program);
175 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttrib4fvProc)(GrGLuint indx, const GrGLfloat* values);
176 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttribPointerProc)(GrGLuint indx, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const GrGLvoid* ptr);
177 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
178 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLViewportProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
twiz@google.com59a190b2011-03-14 21:23:01 +0000179
180 // FBO Extension Functions
twiz@google.com0f31ca72011-03-18 17:38:11 +0000181 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFramebufferProc)(GrGLenum target, GrGLuint framebuffer);
182 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindRenderbufferProc)(GrGLenum target, GrGLuint renderbuffer);
183 typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLCheckFramebufferStatusProc)(GrGLenum target);
184 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteFramebuffersProc)(GrGLsizei n, const GrGLuint *framebuffers);
185 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteRenderbuffersProc)(GrGLsizei n, const GrGLuint *renderbuffers);
186 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferRenderbufferProc)(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer);
187 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferTexture2DProc)(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level);
188 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenFramebuffersProc)(GrGLsizei n, GrGLuint *framebuffers);
189 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenRenderbuffersProc)(GrGLsizei n, GrGLuint *renderbuffers);
190 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
twiz@google.com59a190b2011-03-14 21:23:01 +0000191
192 // Multisampling Extension Functions
193 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
twiz@google.com0f31ca72011-03-18 17:38:11 +0000194 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 +0000195 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
twiz@google.com0f31ca72011-03-18 17:38:11 +0000196 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 +0000197 // apple's es extension
twiz@google.com0f31ca72011-03-18 17:38:11 +0000198 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLResolveMultisampleFramebufferProc)();
twiz@google.com59a190b2011-03-14 21:23:01 +0000199
twiz@google.com59a190b2011-03-14 21:23:01 +0000200 // Buffer mapping (extension in ES).
twiz@google.com0f31ca72011-03-18 17:38:11 +0000201 typedef GrGLvoid* (GR_GL_FUNCTION_TYPE *GrGLMapBufferProc)(GrGLenum target, GrGLenum access);
202 typedef GrGLboolean (GR_GL_FUNCTION_TYPE *GrGLUnmapBufferProc)(GrGLenum target);
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000203
204 // Dual source blending
205 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000206} // extern "C"
207
208/*
209 * The following interface exports the OpenGL entry points used by the system.
210 * Use of OpenGL calls is disallowed. All calls should be invoked through
211 * the global instance of this struct, defined above.
212 *
213 * IMPORTANT NOTE: The OpenGL entry points exposed here include both core GL
214 * functions, and extensions. The system assumes that the address of the
215 * extension pointer will be valid across contexts.
216 */
217struct GrGLInterface {
218 bool validate(GrEngine engine) const;
twiz@google.com59a190b2011-03-14 21:23:01 +0000219
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000220 // Indicator variable specifying the type of GL implementation
221 // exported: GLES{1|2} or Desktop.
222 GrGLBinding fBindingsExported;
223
twiz@google.com59a190b2011-03-14 21:23:01 +0000224 GrGLActiveTextureProc fActiveTexture;
225 GrGLAttachShaderProc fAttachShader;
226 GrGLBindAttribLocationProc fBindAttribLocation;
227 GrGLBindBufferProc fBindBuffer;
228 GrGLBindTextureProc fBindTexture;
bsalomon@google.com080773c2011-03-15 19:09:25 +0000229 GrGLBlendColorProc fBlendColor;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000230 GrGLBlendFuncProc fBlendFunc;
twiz@google.com59a190b2011-03-14 21:23:01 +0000231 GrGLBufferDataProc fBufferData;
232 GrGLBufferSubDataProc fBufferSubData;
233 GrGLClearProc fClear;
234 GrGLClearColorProc fClearColor;
235 GrGLClearStencilProc fClearStencil;
236 GrGLClientActiveTextureProc fClientActiveTexture;
237 GrGLColor4ubProc fColor4ub;
238 GrGLColorMaskProc fColorMask;
239 GrGLColorPointerProc fColorPointer;
240 GrGLCompileShaderProc fCompileShader;
241 GrGLCompressedTexImage2DProc fCompressedTexImage2D;
242 GrGLCreateProgramProc fCreateProgram;
243 GrGLCreateShaderProc fCreateShader;
244 GrGLCullFaceProc fCullFace;
245 GrGLDeleteBuffersProc fDeleteBuffers;
246 GrGLDeleteProgramProc fDeleteProgram;
247 GrGLDeleteShaderProc fDeleteShader;
248 GrGLDeleteTexturesProc fDeleteTextures;
249 GrGLDepthMaskProc fDepthMask;
250 GrGLDisableProc fDisable;
251 GrGLDisableClientStateProc fDisableClientState;
252 GrGLDisableVertexAttribArrayProc fDisableVertexAttribArray;
253 GrGLDrawArraysProc fDrawArrays;
254 GrGLDrawElementsProc fDrawElements;
255 GrGLEnableProc fEnable;
256 GrGLEnableClientStateProc fEnableClientState;
257 GrGLEnableVertexAttribArrayProc fEnableVertexAttribArray;
258 GrGLFrontFaceProc fFrontFace;
259 GrGLGenBuffersProc fGenBuffers;
260 GrGLGenTexturesProc fGenTextures;
261 GrGLGetBufferParameterivProc fGetBufferParameteriv;
262 GrGLGetErrorProc fGetError;
263 GrGLGetIntegervProc fGetIntegerv;
264 GrGLGetProgramInfoLogProc fGetProgramInfoLog;
265 GrGLGetProgramivProc fGetProgramiv;
266 GrGLGetShaderInfoLogProc fGetShaderInfoLog;
267 GrGLGetShaderivProc fGetShaderiv;
268 GrGLGetStringProc fGetString;
269 GrGLGetUniformLocationProc fGetUniformLocation;
270 GrGLLineWidthProc fLineWidth;
271 GrGLLinkProgramProc fLinkProgram;
272 GrGLLoadMatrixfProc fLoadMatrixf;
273 GrGLMatrixModeProc fMatrixMode;
274 GrGLPixelStoreiProc fPixelStorei;
275 GrGLPointSizeProc fPointSize;
276 GrGLReadPixelsProc fReadPixels;
277 GrGLScissorProc fScissor;
278 GrGLShadeModelProc fShadeModel;
279 GrGLShaderSourceProc fShaderSource;
280 GrGLStencilFuncProc fStencilFunc;
281 GrGLStencilFuncSeparateProc fStencilFuncSeparate;
282 GrGLStencilMaskProc fStencilMask;
283 GrGLStencilMaskSeparateProc fStencilMaskSeparate;
284 GrGLStencilOpProc fStencilOp;
285 GrGLStencilOpSeparateProc fStencilOpSeparate;
286 GrGLTexCoordPointerProc fTexCoordPointer;
287 GrGLTexEnviProc fTexEnvi;
288 GrGLTexImage2DProc fTexImage2D;
289 GrGLTexParameteriProc fTexParameteri;
290 GrGLTexSubImage2DProc fTexSubImage2D;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000291 GrGLUniform1fProc fUniform1f;
twiz@google.com59a190b2011-03-14 21:23:01 +0000292 GrGLUniform1iProc fUniform1i;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000293 GrGLUniform1fvProc fUniform1fv;
294 GrGLUniform1ivProc fUniform1iv;
295 GrGLUniform2fProc fUniform2f;
296 GrGLUniform2iProc fUniform2i;
297 GrGLUniform2fvProc fUniform2fv;
298 GrGLUniform2ivProc fUniform2iv;
299 GrGLUniform3fProc fUniform3f;
300 GrGLUniform3iProc fUniform3i;
301 GrGLUniform3fvProc fUniform3fv;
302 GrGLUniform3ivProc fUniform3iv;
303 GrGLUniform4fProc fUniform4f;
304 GrGLUniform4iProc fUniform4i;
twiz@google.com59a190b2011-03-14 21:23:01 +0000305 GrGLUniform4fvProc fUniform4fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000306 GrGLUniform4ivProc fUniform4iv;
307 GrGLUniformMatrix2fvProc fUniformMatrix2fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000308 GrGLUniformMatrix3fvProc fUniformMatrix3fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000309 GrGLUniformMatrix4fvProc fUniformMatrix4fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000310 GrGLUseProgramProc fUseProgram;
311 GrGLVertexAttrib4fvProc fVertexAttrib4fv;
312 GrGLVertexAttribPointerProc fVertexAttribPointer;
313 GrGLVertexPointerProc fVertexPointer;
314 GrGLViewportProc fViewport;
315
316 // FBO Extension Functions
317 GrGLBindFramebufferProc fBindFramebuffer;
318 GrGLBindRenderbufferProc fBindRenderbuffer;
319 GrGLCheckFramebufferStatusProc fCheckFramebufferStatus;
320 GrGLDeleteFramebuffersProc fDeleteFramebuffers;
321 GrGLDeleteRenderbuffersProc fDeleteRenderbuffers;
322 GrGLFramebufferRenderbufferProc fFramebufferRenderbuffer;
323 GrGLFramebufferTexture2DProc fFramebufferTexture2D;
324 GrGLGenFramebuffersProc fGenFramebuffers;
325 GrGLGenRenderbuffersProc fGenRenderbuffers;
326 GrGLRenderbufferStorageProc fRenderbufferStorage;
327
328 // Multisampling Extension Functions
329 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
330 GrGLRenderbufferStorageMultisampleProc fRenderbufferStorageMultisample;
331 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
332 GrGLBlitFramebufferProc fBlitFramebuffer;
333 // apple's es extension
334 GrGLResolveMultisampleFramebufferProc fResolveMultisampleFramebuffer;
335
twiz@google.com59a190b2011-03-14 21:23:01 +0000336 // Buffer mapping (extension in ES).
337 GrGLMapBufferProc fMapBuffer;
338 GrGLUnmapBufferProc fUnmapBuffer;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000339
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000340 // Dual Source Blending
341 GrGLBindFragDataLocationIndexedProc fBindFragDataLocationIndexed;
342
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000343 // Code that initializes this struct using a static initializer should
344 // make this the last entry in the static initializer. It can help to guard
345 // against failing to initialize newly-added members of this struct.
346 enum { kStaticInitEndGuard } fStaticInitEndGuard;
twiz@google.com59a190b2011-03-14 21:23:01 +0000347
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000348private:
349 bool validateShaderFunctions() const;
350 bool validateFixedFunctions() const;
351};
twiz@google.com59a190b2011-03-14 21:23:01 +0000352
353#endif