blob: 42ff0c8a2ce720e783e444bacadf7f377a2df51b [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
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +000034// these variants assume caller already has a string from glGetString()
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000035void gl_version_from_string(int* major, int* minor,
36 const char* versionString);
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +000037float gl_version_as_float_from_string(const char* versionString);
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000038bool has_gl_extension_from_string(const char* ext,
39 const char* extensionString);
40
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +000041// these variants call glGetString()
twiz@google.com59a190b2011-03-14 21:23:01 +000042bool has_gl_extension(const char* ext);
43void gl_version(int* major, int* minor);
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +000044float gl_version_as_float();
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000045
twiz@google.com59a190b2011-03-14 21:23:01 +000046////////////////////////////////////////////////////////////////////////////////
47
48/*
49 * Routines managing the global interface used to invoke OpenGL calls.
50 */
51struct GrGLInterface;
bsalomon@google.com91826102011-03-21 19:51:57 +000052GR_API GrGLInterface* GrGLGetGLInterface();
53GR_API void GrGLSetGLInterface(GrGLInterface* gl_interface);
twiz@google.com59a190b2011-03-14 21:23:01 +000054
55/*
tomhudson@google.com747bf292011-06-14 18:16:52 +000056 * This is called when GrGLSetGLInterface() hasn't been called before creating
57 * a GrGpuGL object. It provides a default implementation. The actual
58 * implementation depends on which GrGLDefaultInterface_*.cpp has been linked.
59 * There are some platform-specific implementations provided as well as
60 * GrGLDefaultInterface_none.cpp which does nothing (effectively requiring an
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000061 * explicit GrGLSetGLInterface call by the host).
twiz@google.com59a190b2011-03-14 21:23:01 +000062 */
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000063void GrGLSetDefaultGLInterface();
twiz@google.com59a190b2011-03-14 21:23:01 +000064
twiz@google.com0f31ca72011-03-18 17:38:11 +000065typedef unsigned int GrGLenum;
66typedef unsigned char GrGLboolean;
67typedef unsigned int GrGLbitfield;
68typedef signed char GrGLbyte;
bsalomon@google.com271cffc2011-05-20 14:13:56 +000069typedef char GrGLchar;
twiz@google.com0f31ca72011-03-18 17:38:11 +000070typedef short GrGLshort;
71typedef int GrGLint;
72typedef int GrGLsizei;
73typedef unsigned char GrGLubyte;
74typedef unsigned short GrGLushort;
75typedef unsigned int GrGLuint;
76typedef float GrGLfloat;
77typedef float GrGLclampf;
78typedef double GrGLdouble;
79typedef double GrGLclampd;
80typedef void GrGLvoid;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000081typedef long GrGLintptr;
82typedef long GrGLsizeiptr;
twiz@google.com0f31ca72011-03-18 17:38:11 +000083
twiz@google.comb65e0cb2011-03-18 20:41:44 +000084enum GrGLBinding {
85 kDesktop_GrGLBinding = 0x01,
86 kES1_GrGLBinding = 0x02,
87 kES2_GrGLBinding = 0x04
88};
89
twiz@google.com59a190b2011-03-14 21:23:01 +000090extern "C" {
twiz@google.com0f31ca72011-03-18 17:38:11 +000091 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLActiveTextureProc)(GrGLenum texture);
92 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLAttachShaderProc)(GrGLuint program, GrGLuint shader);
93 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindAttribLocationProc)(GrGLuint program, GrGLuint index, const char* name);
94 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindBufferProc)(GrGLenum target, GrGLuint buffer);
95 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindTextureProc)(GrGLenum target, GrGLuint texture);
96 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
97 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor);
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000098 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage);
99 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferSubDataProc)(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const GrGLvoid* data);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000100 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearProc)(GrGLbitfield mask);
101 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
102 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearStencilProc)(GrGLint s);
103 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClientActiveTextureProc)(GrGLenum texture);
104 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColor4ubProc)(GrGLubyte red, GrGLubyte green, GrGLubyte blue, GrGLubyte alpha);
105 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorMaskProc)(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha);
106 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
107 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompileShaderProc)(GrGLuint shader);
108 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompressedTexImage2DProc)(GrGLenum target, GrGLint level, GrGLenum internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLsizei imageSize, const GrGLvoid* data);
109 typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateProgramProc)(void);
110 typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateShaderProc)(GrGLenum type);
111 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCullFaceProc)(GrGLenum mode);
112 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteBuffersProc)(GrGLsizei n, const GrGLuint* buffers);
113 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteProgramProc)(GrGLuint program);
114 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteShaderProc)(GrGLuint shader);
115 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteTexturesProc)(GrGLsizei n, const GrGLuint* textures);
116 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDepthMaskProc)(GrGLboolean flag);
117 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableProc)(GrGLenum cap);
118 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableClientStateProc)(GrGLenum array);
119 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableVertexAttribArrayProc)(GrGLuint index);
120 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawArraysProc)(GrGLenum mode, GrGLint first, GrGLsizei count);
121 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices);
122 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableProc)(GrGLenum cap);
123 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableClientStateProc)(GrGLenum cap);
124 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableVertexAttribArrayProc)(GrGLuint index);
125 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFrontFaceProc)(GrGLenum mode);
126 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenBuffersProc)(GrGLsizei n, GrGLuint* buffers);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000127 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures);
128 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000129 typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLGetErrorProc)(void);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000130 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetIntegervProc)(GrGLenum pname, GrGLint* params);
131 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramInfoLogProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
132 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramivProc)(GrGLuint program, GrGLenum pname, GrGLint* params);
133 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderInfoLogProc)(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
134 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderivProc)(GrGLuint shader, GrGLenum pname, GrGLint* params);
135 typedef const GrGLubyte* (GR_GL_FUNCTION_TYPE *GrGLGetStringProc)(GrGLenum name);
136 typedef GrGLint (GR_GL_FUNCTION_TYPE *GrGLGetUniformLocationProc)(GrGLuint program, const char* name);
137 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLineWidthProc)(GrGLfloat width);
138 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLinkProgramProc)(GrGLuint program);
139 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLoadMatrixfProc)(const GrGLfloat* m);
140 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLMatrixModeProc)(GrGLenum mode);
141 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPixelStoreiProc)(GrGLenum pname, GrGLint param);
142 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPointSizeProc)(GrGLfloat size);
143 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLReadPixelsProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels);
144 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
145 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShadeModelProc)(GrGLenum mode);
146 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShaderSourceProc)(GrGLuint shader, GrGLsizei count, const char** str, const GrGLint* length);
147 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncProc)(GrGLenum func, GrGLint ref, GrGLuint mask);
148 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncSeparateProc)(GrGLenum face, GrGLenum func, GrGLint ref, GrGLuint mask);
149 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskProc)(GrGLuint mask);
150 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskSeparateProc)(GrGLenum face, GrGLuint mask);
151 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpProc)(GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
152 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpSeparateProc)(GrGLenum face, GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
153 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexCoordPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
154 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexEnviProc)(GrGLenum target, GrGLenum pname, GrGLint param);
155 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);
156 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexParameteriProc)(GrGLenum target, GrGLenum pname, GrGLint param);
157 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 +0000158 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fProc)(GrGLint location, GrGLfloat v0);
159 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1iProc)(GrGLint location, GrGLint v0);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000160 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000161 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
162 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1);
163 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2iProc)(GrGLint location, GrGLint v0, GrGLint v1);
164 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
165 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
166 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2);
167 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2);
168 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
169 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
170 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2, GrGLfloat v3);
171 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 +0000172 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000173 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
174 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix2fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000175 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix3fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000176 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix4fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000177 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUseProgramProc)(GrGLuint program);
178 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttrib4fvProc)(GrGLuint indx, const GrGLfloat* values);
179 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttribPointerProc)(GrGLuint indx, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const GrGLvoid* ptr);
180 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
181 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLViewportProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
twiz@google.com59a190b2011-03-14 21:23:01 +0000182
183 // FBO Extension Functions
twiz@google.com0f31ca72011-03-18 17:38:11 +0000184 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFramebufferProc)(GrGLenum target, GrGLuint framebuffer);
185 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindRenderbufferProc)(GrGLenum target, GrGLuint renderbuffer);
186 typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLCheckFramebufferStatusProc)(GrGLenum target);
187 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteFramebuffersProc)(GrGLsizei n, const GrGLuint *framebuffers);
188 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteRenderbuffersProc)(GrGLsizei n, const GrGLuint *renderbuffers);
189 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferRenderbufferProc)(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer);
190 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferTexture2DProc)(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level);
191 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenFramebuffersProc)(GrGLsizei n, GrGLuint *framebuffers);
192 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenRenderbuffersProc)(GrGLsizei n, GrGLuint *renderbuffers);
193 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
twiz@google.com59a190b2011-03-14 21:23:01 +0000194
195 // Multisampling Extension Functions
196 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
twiz@google.com0f31ca72011-03-18 17:38:11 +0000197 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 +0000198 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
twiz@google.com0f31ca72011-03-18 17:38:11 +0000199 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 +0000200 // apple's es extension
twiz@google.com0f31ca72011-03-18 17:38:11 +0000201 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLResolveMultisampleFramebufferProc)();
twiz@google.com59a190b2011-03-14 21:23:01 +0000202
twiz@google.com59a190b2011-03-14 21:23:01 +0000203 // Buffer mapping (extension in ES).
twiz@google.com0f31ca72011-03-18 17:38:11 +0000204 typedef GrGLvoid* (GR_GL_FUNCTION_TYPE *GrGLMapBufferProc)(GrGLenum target, GrGLenum access);
205 typedef GrGLboolean (GR_GL_FUNCTION_TYPE *GrGLUnmapBufferProc)(GrGLenum target);
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000206
207 // Dual source blending
208 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000209} // extern "C"
210
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000211enum GrGLCapability {
212 kProbe_GrGLCapability = -1
tomhudson@google.com30e4bb62011-06-15 19:41:46 +0000213};
214
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000215/*
216 * The following interface exports the OpenGL entry points used by the system.
217 * Use of OpenGL calls is disallowed. All calls should be invoked through
218 * the global instance of this struct, defined above.
219 *
220 * IMPORTANT NOTE: The OpenGL entry points exposed here include both core GL
221 * functions, and extensions. The system assumes that the address of the
222 * extension pointer will be valid across contexts.
223 */
224struct GrGLInterface {
225 bool validate(GrEngine engine) const;
twiz@google.com59a190b2011-03-14 21:23:01 +0000226
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000227 // Indicator variable specifying the type of GL implementation
228 // exported: GLES{1|2} or Desktop.
229 GrGLBinding fBindingsExported;
230
tomhudson@google.com747bf292011-06-14 18:16:52 +0000231 /// Does this GL support NPOT textures on FBOs?
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000232 /// boolean value, or kProbe_GrGLCapability to probe (slowly) at context creation.
tomhudson@google.com747bf292011-06-14 18:16:52 +0000233 int fNPOTRenderTargetSupport;
234
235 /// Some GL implementations (PowerVR SGX devices like the iPhone 4)
236 /// have restrictions on the size of small render targets.
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000237 /// kProbe_GrGLCapability to probe (slowly) at context creation.
tomhudson@google.com747bf292011-06-14 18:16:52 +0000238 int fMinRenderTargetHeight;
239 int fMinRenderTargetWidth;
240
twiz@google.com59a190b2011-03-14 21:23:01 +0000241 GrGLActiveTextureProc fActiveTexture;
242 GrGLAttachShaderProc fAttachShader;
243 GrGLBindAttribLocationProc fBindAttribLocation;
244 GrGLBindBufferProc fBindBuffer;
245 GrGLBindTextureProc fBindTexture;
bsalomon@google.com080773c2011-03-15 19:09:25 +0000246 GrGLBlendColorProc fBlendColor;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000247 GrGLBlendFuncProc fBlendFunc;
twiz@google.com59a190b2011-03-14 21:23:01 +0000248 GrGLBufferDataProc fBufferData;
249 GrGLBufferSubDataProc fBufferSubData;
250 GrGLClearProc fClear;
251 GrGLClearColorProc fClearColor;
252 GrGLClearStencilProc fClearStencil;
253 GrGLClientActiveTextureProc fClientActiveTexture;
254 GrGLColor4ubProc fColor4ub;
255 GrGLColorMaskProc fColorMask;
256 GrGLColorPointerProc fColorPointer;
257 GrGLCompileShaderProc fCompileShader;
258 GrGLCompressedTexImage2DProc fCompressedTexImage2D;
259 GrGLCreateProgramProc fCreateProgram;
260 GrGLCreateShaderProc fCreateShader;
261 GrGLCullFaceProc fCullFace;
262 GrGLDeleteBuffersProc fDeleteBuffers;
263 GrGLDeleteProgramProc fDeleteProgram;
264 GrGLDeleteShaderProc fDeleteShader;
265 GrGLDeleteTexturesProc fDeleteTextures;
266 GrGLDepthMaskProc fDepthMask;
267 GrGLDisableProc fDisable;
268 GrGLDisableClientStateProc fDisableClientState;
269 GrGLDisableVertexAttribArrayProc fDisableVertexAttribArray;
270 GrGLDrawArraysProc fDrawArrays;
271 GrGLDrawElementsProc fDrawElements;
272 GrGLEnableProc fEnable;
273 GrGLEnableClientStateProc fEnableClientState;
274 GrGLEnableVertexAttribArrayProc fEnableVertexAttribArray;
275 GrGLFrontFaceProc fFrontFace;
276 GrGLGenBuffersProc fGenBuffers;
277 GrGLGenTexturesProc fGenTextures;
278 GrGLGetBufferParameterivProc fGetBufferParameteriv;
279 GrGLGetErrorProc fGetError;
280 GrGLGetIntegervProc fGetIntegerv;
281 GrGLGetProgramInfoLogProc fGetProgramInfoLog;
282 GrGLGetProgramivProc fGetProgramiv;
283 GrGLGetShaderInfoLogProc fGetShaderInfoLog;
284 GrGLGetShaderivProc fGetShaderiv;
285 GrGLGetStringProc fGetString;
286 GrGLGetUniformLocationProc fGetUniformLocation;
287 GrGLLineWidthProc fLineWidth;
288 GrGLLinkProgramProc fLinkProgram;
289 GrGLLoadMatrixfProc fLoadMatrixf;
290 GrGLMatrixModeProc fMatrixMode;
291 GrGLPixelStoreiProc fPixelStorei;
292 GrGLPointSizeProc fPointSize;
293 GrGLReadPixelsProc fReadPixels;
294 GrGLScissorProc fScissor;
295 GrGLShadeModelProc fShadeModel;
296 GrGLShaderSourceProc fShaderSource;
297 GrGLStencilFuncProc fStencilFunc;
298 GrGLStencilFuncSeparateProc fStencilFuncSeparate;
299 GrGLStencilMaskProc fStencilMask;
300 GrGLStencilMaskSeparateProc fStencilMaskSeparate;
301 GrGLStencilOpProc fStencilOp;
302 GrGLStencilOpSeparateProc fStencilOpSeparate;
303 GrGLTexCoordPointerProc fTexCoordPointer;
304 GrGLTexEnviProc fTexEnvi;
305 GrGLTexImage2DProc fTexImage2D;
306 GrGLTexParameteriProc fTexParameteri;
307 GrGLTexSubImage2DProc fTexSubImage2D;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000308 GrGLUniform1fProc fUniform1f;
twiz@google.com59a190b2011-03-14 21:23:01 +0000309 GrGLUniform1iProc fUniform1i;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000310 GrGLUniform1fvProc fUniform1fv;
311 GrGLUniform1ivProc fUniform1iv;
312 GrGLUniform2fProc fUniform2f;
313 GrGLUniform2iProc fUniform2i;
314 GrGLUniform2fvProc fUniform2fv;
315 GrGLUniform2ivProc fUniform2iv;
316 GrGLUniform3fProc fUniform3f;
317 GrGLUniform3iProc fUniform3i;
318 GrGLUniform3fvProc fUniform3fv;
319 GrGLUniform3ivProc fUniform3iv;
320 GrGLUniform4fProc fUniform4f;
321 GrGLUniform4iProc fUniform4i;
twiz@google.com59a190b2011-03-14 21:23:01 +0000322 GrGLUniform4fvProc fUniform4fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000323 GrGLUniform4ivProc fUniform4iv;
324 GrGLUniformMatrix2fvProc fUniformMatrix2fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000325 GrGLUniformMatrix3fvProc fUniformMatrix3fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000326 GrGLUniformMatrix4fvProc fUniformMatrix4fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000327 GrGLUseProgramProc fUseProgram;
328 GrGLVertexAttrib4fvProc fVertexAttrib4fv;
329 GrGLVertexAttribPointerProc fVertexAttribPointer;
330 GrGLVertexPointerProc fVertexPointer;
331 GrGLViewportProc fViewport;
332
333 // FBO Extension Functions
334 GrGLBindFramebufferProc fBindFramebuffer;
335 GrGLBindRenderbufferProc fBindRenderbuffer;
336 GrGLCheckFramebufferStatusProc fCheckFramebufferStatus;
337 GrGLDeleteFramebuffersProc fDeleteFramebuffers;
338 GrGLDeleteRenderbuffersProc fDeleteRenderbuffers;
339 GrGLFramebufferRenderbufferProc fFramebufferRenderbuffer;
340 GrGLFramebufferTexture2DProc fFramebufferTexture2D;
341 GrGLGenFramebuffersProc fGenFramebuffers;
342 GrGLGenRenderbuffersProc fGenRenderbuffers;
343 GrGLRenderbufferStorageProc fRenderbufferStorage;
344
345 // Multisampling Extension Functions
346 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
347 GrGLRenderbufferStorageMultisampleProc fRenderbufferStorageMultisample;
348 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
349 GrGLBlitFramebufferProc fBlitFramebuffer;
350 // apple's es extension
351 GrGLResolveMultisampleFramebufferProc fResolveMultisampleFramebuffer;
352
twiz@google.com59a190b2011-03-14 21:23:01 +0000353 // Buffer mapping (extension in ES).
354 GrGLMapBufferProc fMapBuffer;
355 GrGLUnmapBufferProc fUnmapBuffer;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000356
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000357 // Dual Source Blending
358 GrGLBindFragDataLocationIndexedProc fBindFragDataLocationIndexed;
359
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000360 // Code that initializes this struct using a static initializer should
361 // make this the last entry in the static initializer. It can help to guard
362 // against failing to initialize newly-added members of this struct.
363 enum { kStaticInitEndGuard } fStaticInitEndGuard;
twiz@google.com59a190b2011-03-14 21:23:01 +0000364
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000365private:
366 bool validateShaderFunctions() const;
367 bool validateFixedFunctions() const;
368};
twiz@google.com59a190b2011-03-14 21:23:01 +0000369
370#endif