blob: 05eb2430a633b795a3745bbbfc8a5d8ea141937b [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
twiz@google.com59a190b2011-03-14 21:23:01 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
twiz@google.com59a190b2011-03-14 21:23:01 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
twiz@google.com59a190b2011-03-14 21:23:01 +000011#ifndef GrGLInterface_DEFINED
12#define GrGLInterface_DEFINED
13
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000014#include "GrGLConfig.h"
bsalomon@google.combf2a4692011-05-04 12:35:39 +000015#include "GrTypes.h"
twiz@google.com59a190b2011-03-14 21:23:01 +000016
17#if !defined(GR_GL_FUNCTION_TYPE)
18 #define GR_GL_FUNCTION_TYPE
19#endif
20
21////////////////////////////////////////////////////////////////////////////////
22
23/**
24 * Helpers for glGetString()
25 */
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000026
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +000027// these variants assume caller already has a string from glGetString()
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000028void gl_version_from_string(int* major, int* minor,
29 const char* versionString);
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +000030float gl_version_as_float_from_string(const char* versionString);
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000031bool has_gl_extension_from_string(const char* ext,
32 const char* extensionString);
33
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +000034// these variants call glGetString()
twiz@google.com59a190b2011-03-14 21:23:01 +000035bool has_gl_extension(const char* ext);
36void gl_version(int* major, int* minor);
bsalomon@google.com2c17fcd2011-07-06 17:47:02 +000037float gl_version_as_float();
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000038
twiz@google.com59a190b2011-03-14 21:23:01 +000039////////////////////////////////////////////////////////////////////////////////
40
41/*
42 * Routines managing the global interface used to invoke OpenGL calls.
43 */
44struct GrGLInterface;
bsalomon@google.com91826102011-03-21 19:51:57 +000045GR_API GrGLInterface* GrGLGetGLInterface();
46GR_API void GrGLSetGLInterface(GrGLInterface* gl_interface);
twiz@google.com59a190b2011-03-14 21:23:01 +000047
48/*
tomhudson@google.com747bf292011-06-14 18:16:52 +000049 * This is called when GrGLSetGLInterface() hasn't been called before creating
50 * a GrGpuGL object. It provides a default implementation. The actual
51 * implementation depends on which GrGLDefaultInterface_*.cpp has been linked.
52 * There are some platform-specific implementations provided as well as
53 * GrGLDefaultInterface_none.cpp which does nothing (effectively requiring an
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000054 * explicit GrGLSetGLInterface call by the host).
twiz@google.com59a190b2011-03-14 21:23:01 +000055 */
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000056void GrGLSetDefaultGLInterface();
twiz@google.com59a190b2011-03-14 21:23:01 +000057
twiz@google.com0f31ca72011-03-18 17:38:11 +000058typedef unsigned int GrGLenum;
59typedef unsigned char GrGLboolean;
60typedef unsigned int GrGLbitfield;
61typedef signed char GrGLbyte;
bsalomon@google.com271cffc2011-05-20 14:13:56 +000062typedef char GrGLchar;
twiz@google.com0f31ca72011-03-18 17:38:11 +000063typedef short GrGLshort;
64typedef int GrGLint;
65typedef int GrGLsizei;
66typedef unsigned char GrGLubyte;
67typedef unsigned short GrGLushort;
68typedef unsigned int GrGLuint;
69typedef float GrGLfloat;
70typedef float GrGLclampf;
71typedef double GrGLdouble;
72typedef double GrGLclampd;
73typedef void GrGLvoid;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000074typedef long GrGLintptr;
75typedef long GrGLsizeiptr;
twiz@google.com0f31ca72011-03-18 17:38:11 +000076
twiz@google.comb65e0cb2011-03-18 20:41:44 +000077enum GrGLBinding {
78 kDesktop_GrGLBinding = 0x01,
79 kES1_GrGLBinding = 0x02,
80 kES2_GrGLBinding = 0x04
81};
82
twiz@google.com59a190b2011-03-14 21:23:01 +000083extern "C" {
twiz@google.com0f31ca72011-03-18 17:38:11 +000084 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLActiveTextureProc)(GrGLenum texture);
85 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLAttachShaderProc)(GrGLuint program, GrGLuint shader);
86 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindAttribLocationProc)(GrGLuint program, GrGLuint index, const char* name);
87 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindBufferProc)(GrGLenum target, GrGLuint buffer);
88 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindTextureProc)(GrGLenum target, GrGLuint texture);
89 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
90 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor);
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000091 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage);
92 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferSubDataProc)(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const GrGLvoid* data);
twiz@google.com0f31ca72011-03-18 17:38:11 +000093 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearProc)(GrGLbitfield mask);
94 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
95 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearStencilProc)(GrGLint s);
96 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClientActiveTextureProc)(GrGLenum texture);
97 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColor4ubProc)(GrGLubyte red, GrGLubyte green, GrGLubyte blue, GrGLubyte alpha);
98 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorMaskProc)(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha);
99 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
100 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompileShaderProc)(GrGLuint shader);
101 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompressedTexImage2DProc)(GrGLenum target, GrGLint level, GrGLenum internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLsizei imageSize, const GrGLvoid* data);
102 typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateProgramProc)(void);
103 typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateShaderProc)(GrGLenum type);
104 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCullFaceProc)(GrGLenum mode);
105 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteBuffersProc)(GrGLsizei n, const GrGLuint* buffers);
106 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteProgramProc)(GrGLuint program);
107 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteShaderProc)(GrGLuint shader);
108 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteTexturesProc)(GrGLsizei n, const GrGLuint* textures);
109 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDepthMaskProc)(GrGLboolean flag);
110 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableProc)(GrGLenum cap);
111 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableClientStateProc)(GrGLenum array);
112 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableVertexAttribArrayProc)(GrGLuint index);
113 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawArraysProc)(GrGLenum mode, GrGLint first, GrGLsizei count);
114 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices);
115 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableProc)(GrGLenum cap);
116 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableClientStateProc)(GrGLenum cap);
117 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableVertexAttribArrayProc)(GrGLuint index);
118 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFrontFaceProc)(GrGLenum mode);
119 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenBuffersProc)(GrGLsizei n, GrGLuint* buffers);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000120 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures);
121 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000122 typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLGetErrorProc)(void);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000123 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetIntegervProc)(GrGLenum pname, GrGLint* params);
124 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramInfoLogProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
125 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramivProc)(GrGLuint program, GrGLenum pname, GrGLint* params);
126 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderInfoLogProc)(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
127 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderivProc)(GrGLuint shader, GrGLenum pname, GrGLint* params);
128 typedef const GrGLubyte* (GR_GL_FUNCTION_TYPE *GrGLGetStringProc)(GrGLenum name);
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000129 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetTexLevelParameteriv)(GrGLenum target, GrGLint level, GrGLenum pname, GrGLint* params);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000130 typedef GrGLint (GR_GL_FUNCTION_TYPE *GrGLGetUniformLocationProc)(GrGLuint program, const char* name);
131 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLineWidthProc)(GrGLfloat width);
132 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLinkProgramProc)(GrGLuint program);
133 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLoadMatrixfProc)(const GrGLfloat* m);
134 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLMatrixModeProc)(GrGLenum mode);
135 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPixelStoreiProc)(GrGLenum pname, GrGLint param);
136 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPointSizeProc)(GrGLfloat size);
137 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLReadPixelsProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels);
138 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
139 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShadeModelProc)(GrGLenum mode);
140 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShaderSourceProc)(GrGLuint shader, GrGLsizei count, const char** str, const GrGLint* length);
141 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncProc)(GrGLenum func, GrGLint ref, GrGLuint mask);
142 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncSeparateProc)(GrGLenum face, GrGLenum func, GrGLint ref, GrGLuint mask);
143 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskProc)(GrGLuint mask);
144 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskSeparateProc)(GrGLenum face, GrGLuint mask);
145 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpProc)(GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
146 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpSeparateProc)(GrGLenum face, GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
147 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexCoordPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
148 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexEnviProc)(GrGLenum target, GrGLenum pname, GrGLint param);
149 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);
150 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexParameteriProc)(GrGLenum target, GrGLenum pname, GrGLint param);
151 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 +0000152 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fProc)(GrGLint location, GrGLfloat v0);
153 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1iProc)(GrGLint location, GrGLint v0);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000154 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000155 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
156 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1);
157 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2iProc)(GrGLint location, GrGLint v0, GrGLint v1);
158 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
159 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
160 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2);
161 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2);
162 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
163 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
164 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2, GrGLfloat v3);
165 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 +0000166 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000167 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
168 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix2fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000169 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix3fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000170 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix4fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000171 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUseProgramProc)(GrGLuint program);
172 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttrib4fvProc)(GrGLuint indx, const GrGLfloat* values);
173 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttribPointerProc)(GrGLuint indx, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const GrGLvoid* ptr);
174 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
175 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLViewportProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
twiz@google.com59a190b2011-03-14 21:23:01 +0000176
177 // FBO Extension Functions
twiz@google.com0f31ca72011-03-18 17:38:11 +0000178 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFramebufferProc)(GrGLenum target, GrGLuint framebuffer);
179 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindRenderbufferProc)(GrGLenum target, GrGLuint renderbuffer);
180 typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLCheckFramebufferStatusProc)(GrGLenum target);
181 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteFramebuffersProc)(GrGLsizei n, const GrGLuint *framebuffers);
182 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteRenderbuffersProc)(GrGLsizei n, const GrGLuint *renderbuffers);
183 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferRenderbufferProc)(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer);
184 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferTexture2DProc)(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level);
185 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenFramebuffersProc)(GrGLsizei n, GrGLuint *framebuffers);
186 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenRenderbuffersProc)(GrGLsizei n, GrGLuint *renderbuffers);
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000187 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetFramebufferAttachmentParameterivProc)(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params);
188 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetRenderbufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000189 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.com271cffc2011-05-20 14:13:56 +0000202
203 // Dual source blending
204 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000205} // extern "C"
206
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000207enum GrGLCapability {
208 kProbe_GrGLCapability = -1
tomhudson@google.com30e4bb62011-06-15 19:41:46 +0000209};
210
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000211/*
212 * The following interface exports the OpenGL entry points used by the system.
213 * Use of OpenGL calls is disallowed. All calls should be invoked through
214 * the global instance of this struct, defined above.
215 *
216 * IMPORTANT NOTE: The OpenGL entry points exposed here include both core GL
217 * functions, and extensions. The system assumes that the address of the
218 * extension pointer will be valid across contexts.
219 */
220struct GrGLInterface {
221 bool validate(GrEngine engine) const;
twiz@google.com59a190b2011-03-14 21:23:01 +0000222
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000223 // Indicator variable specifying the type of GL implementation
224 // exported: GLES{1|2} or Desktop.
225 GrGLBinding fBindingsExported;
226
tomhudson@google.com747bf292011-06-14 18:16:52 +0000227 /// Does this GL support NPOT textures on FBOs?
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000228 /// boolean value, or kProbe_GrGLCapability to probe (slowly) at context creation.
tomhudson@google.com747bf292011-06-14 18:16:52 +0000229 int fNPOTRenderTargetSupport;
230
231 /// Some GL implementations (PowerVR SGX devices like the iPhone 4)
232 /// have restrictions on the size of small render targets.
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000233 /// kProbe_GrGLCapability to probe (slowly) at context creation.
tomhudson@google.com747bf292011-06-14 18:16:52 +0000234 int fMinRenderTargetHeight;
235 int fMinRenderTargetWidth;
236
twiz@google.com59a190b2011-03-14 21:23:01 +0000237 GrGLActiveTextureProc fActiveTexture;
238 GrGLAttachShaderProc fAttachShader;
239 GrGLBindAttribLocationProc fBindAttribLocation;
240 GrGLBindBufferProc fBindBuffer;
241 GrGLBindTextureProc fBindTexture;
bsalomon@google.com080773c2011-03-15 19:09:25 +0000242 GrGLBlendColorProc fBlendColor;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000243 GrGLBlendFuncProc fBlendFunc;
twiz@google.com59a190b2011-03-14 21:23:01 +0000244 GrGLBufferDataProc fBufferData;
245 GrGLBufferSubDataProc fBufferSubData;
246 GrGLClearProc fClear;
247 GrGLClearColorProc fClearColor;
248 GrGLClearStencilProc fClearStencil;
249 GrGLClientActiveTextureProc fClientActiveTexture;
250 GrGLColor4ubProc fColor4ub;
251 GrGLColorMaskProc fColorMask;
252 GrGLColorPointerProc fColorPointer;
253 GrGLCompileShaderProc fCompileShader;
254 GrGLCompressedTexImage2DProc fCompressedTexImage2D;
255 GrGLCreateProgramProc fCreateProgram;
256 GrGLCreateShaderProc fCreateShader;
257 GrGLCullFaceProc fCullFace;
258 GrGLDeleteBuffersProc fDeleteBuffers;
259 GrGLDeleteProgramProc fDeleteProgram;
260 GrGLDeleteShaderProc fDeleteShader;
261 GrGLDeleteTexturesProc fDeleteTextures;
262 GrGLDepthMaskProc fDepthMask;
263 GrGLDisableProc fDisable;
264 GrGLDisableClientStateProc fDisableClientState;
265 GrGLDisableVertexAttribArrayProc fDisableVertexAttribArray;
266 GrGLDrawArraysProc fDrawArrays;
267 GrGLDrawElementsProc fDrawElements;
268 GrGLEnableProc fEnable;
269 GrGLEnableClientStateProc fEnableClientState;
270 GrGLEnableVertexAttribArrayProc fEnableVertexAttribArray;
271 GrGLFrontFaceProc fFrontFace;
272 GrGLGenBuffersProc fGenBuffers;
273 GrGLGenTexturesProc fGenTextures;
274 GrGLGetBufferParameterivProc fGetBufferParameteriv;
275 GrGLGetErrorProc fGetError;
276 GrGLGetIntegervProc fGetIntegerv;
277 GrGLGetProgramInfoLogProc fGetProgramInfoLog;
278 GrGLGetProgramivProc fGetProgramiv;
279 GrGLGetShaderInfoLogProc fGetShaderInfoLog;
280 GrGLGetShaderivProc fGetShaderiv;
281 GrGLGetStringProc fGetString;
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000282 GrGLGetTexLevelParameteriv fGetTexLevelParameteriv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000283 GrGLGetUniformLocationProc fGetUniformLocation;
284 GrGLLineWidthProc fLineWidth;
285 GrGLLinkProgramProc fLinkProgram;
286 GrGLLoadMatrixfProc fLoadMatrixf;
287 GrGLMatrixModeProc fMatrixMode;
288 GrGLPixelStoreiProc fPixelStorei;
289 GrGLPointSizeProc fPointSize;
290 GrGLReadPixelsProc fReadPixels;
291 GrGLScissorProc fScissor;
292 GrGLShadeModelProc fShadeModel;
293 GrGLShaderSourceProc fShaderSource;
294 GrGLStencilFuncProc fStencilFunc;
295 GrGLStencilFuncSeparateProc fStencilFuncSeparate;
296 GrGLStencilMaskProc fStencilMask;
297 GrGLStencilMaskSeparateProc fStencilMaskSeparate;
298 GrGLStencilOpProc fStencilOp;
299 GrGLStencilOpSeparateProc fStencilOpSeparate;
300 GrGLTexCoordPointerProc fTexCoordPointer;
301 GrGLTexEnviProc fTexEnvi;
302 GrGLTexImage2DProc fTexImage2D;
303 GrGLTexParameteriProc fTexParameteri;
304 GrGLTexSubImage2DProc fTexSubImage2D;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000305 GrGLUniform1fProc fUniform1f;
twiz@google.com59a190b2011-03-14 21:23:01 +0000306 GrGLUniform1iProc fUniform1i;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000307 GrGLUniform1fvProc fUniform1fv;
308 GrGLUniform1ivProc fUniform1iv;
309 GrGLUniform2fProc fUniform2f;
310 GrGLUniform2iProc fUniform2i;
311 GrGLUniform2fvProc fUniform2fv;
312 GrGLUniform2ivProc fUniform2iv;
313 GrGLUniform3fProc fUniform3f;
314 GrGLUniform3iProc fUniform3i;
315 GrGLUniform3fvProc fUniform3fv;
316 GrGLUniform3ivProc fUniform3iv;
317 GrGLUniform4fProc fUniform4f;
318 GrGLUniform4iProc fUniform4i;
twiz@google.com59a190b2011-03-14 21:23:01 +0000319 GrGLUniform4fvProc fUniform4fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000320 GrGLUniform4ivProc fUniform4iv;
321 GrGLUniformMatrix2fvProc fUniformMatrix2fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000322 GrGLUniformMatrix3fvProc fUniformMatrix3fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000323 GrGLUniformMatrix4fvProc fUniformMatrix4fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000324 GrGLUseProgramProc fUseProgram;
325 GrGLVertexAttrib4fvProc fVertexAttrib4fv;
326 GrGLVertexAttribPointerProc fVertexAttribPointer;
327 GrGLVertexPointerProc fVertexPointer;
328 GrGLViewportProc fViewport;
329
330 // FBO Extension Functions
331 GrGLBindFramebufferProc fBindFramebuffer;
332 GrGLBindRenderbufferProc fBindRenderbuffer;
333 GrGLCheckFramebufferStatusProc fCheckFramebufferStatus;
334 GrGLDeleteFramebuffersProc fDeleteFramebuffers;
335 GrGLDeleteRenderbuffersProc fDeleteRenderbuffers;
336 GrGLFramebufferRenderbufferProc fFramebufferRenderbuffer;
337 GrGLFramebufferTexture2DProc fFramebufferTexture2D;
338 GrGLGenFramebuffersProc fGenFramebuffers;
339 GrGLGenRenderbuffersProc fGenRenderbuffers;
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000340 GrGLGetFramebufferAttachmentParameterivProc fGetFramebufferAttachmentParameteriv;
341 GrGLGetRenderbufferParameterivProc fGetRenderbufferParameteriv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000342 GrGLRenderbufferStorageProc fRenderbufferStorage;
343
344 // Multisampling Extension Functions
345 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
346 GrGLRenderbufferStorageMultisampleProc fRenderbufferStorageMultisample;
347 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
348 GrGLBlitFramebufferProc fBlitFramebuffer;
349 // apple's es extension
350 GrGLResolveMultisampleFramebufferProc fResolveMultisampleFramebuffer;
351
twiz@google.com59a190b2011-03-14 21:23:01 +0000352 // Buffer mapping (extension in ES).
353 GrGLMapBufferProc fMapBuffer;
354 GrGLUnmapBufferProc fUnmapBuffer;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000355
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000356 // Dual Source Blending
357 GrGLBindFragDataLocationIndexedProc fBindFragDataLocationIndexed;
358
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000359 // Code that initializes this struct using a static initializer should
360 // make this the last entry in the static initializer. It can help to guard
361 // against failing to initialize newly-added members of this struct.
362 enum { kStaticInitEndGuard } fStaticInitEndGuard;
twiz@google.com59a190b2011-03-14 21:23:01 +0000363
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000364private:
365 bool validateShaderFunctions() const;
366 bool validateFixedFunctions() const;
367};
twiz@google.com59a190b2011-03-14 21:23:01 +0000368
369#endif