blob: 63ebca524a1d5a554c59329cfb4d431134ddd55c [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);
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000114 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawBufferProc)(GrGLenum mode);
115 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawBuffersProc)(GrGLsizei n, const GrGLenum* bufs);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000116 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices);
117 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableProc)(GrGLenum cap);
118 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableClientStateProc)(GrGLenum cap);
119 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableVertexAttribArrayProc)(GrGLuint index);
120 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFrontFaceProc)(GrGLenum mode);
121 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenBuffersProc)(GrGLsizei n, GrGLuint* buffers);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000122 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures);
123 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000124 typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLGetErrorProc)(void);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000125 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetIntegervProc)(GrGLenum pname, GrGLint* params);
126 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramInfoLogProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
127 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramivProc)(GrGLuint program, GrGLenum pname, GrGLint* params);
128 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderInfoLogProc)(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
129 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderivProc)(GrGLuint shader, GrGLenum pname, GrGLint* params);
130 typedef const GrGLubyte* (GR_GL_FUNCTION_TYPE *GrGLGetStringProc)(GrGLenum name);
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000131 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetTexLevelParameteriv)(GrGLenum target, GrGLint level, GrGLenum pname, GrGLint* params);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000132 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);
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000189 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetFramebufferAttachmentParameterivProc)(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params);
190 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetRenderbufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000191 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
twiz@google.com59a190b2011-03-14 21:23:01 +0000192
193 // Multisampling Extension Functions
194 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
twiz@google.com0f31ca72011-03-18 17:38:11 +0000195 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 +0000196 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
twiz@google.com0f31ca72011-03-18 17:38:11 +0000197 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 +0000198 // apple's es extension
twiz@google.com0f31ca72011-03-18 17:38:11 +0000199 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLResolveMultisampleFramebufferProc)();
twiz@google.com59a190b2011-03-14 21:23:01 +0000200
twiz@google.com59a190b2011-03-14 21:23:01 +0000201 // Buffer mapping (extension in ES).
twiz@google.com0f31ca72011-03-18 17:38:11 +0000202 typedef GrGLvoid* (GR_GL_FUNCTION_TYPE *GrGLMapBufferProc)(GrGLenum target, GrGLenum access);
203 typedef GrGLboolean (GR_GL_FUNCTION_TYPE *GrGLUnmapBufferProc)(GrGLenum target);
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000204
205 // Dual source blending
206 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000207} // extern "C"
208
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000209enum GrGLCapability {
210 kProbe_GrGLCapability = -1
tomhudson@google.com30e4bb62011-06-15 19:41:46 +0000211};
212
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000213/*
214 * The following interface exports the OpenGL entry points used by the system.
215 * Use of OpenGL calls is disallowed. All calls should be invoked through
216 * the global instance of this struct, defined above.
217 *
218 * IMPORTANT NOTE: The OpenGL entry points exposed here include both core GL
219 * functions, and extensions. The system assumes that the address of the
220 * extension pointer will be valid across contexts.
221 */
222struct GrGLInterface {
223 bool validate(GrEngine engine) const;
twiz@google.com59a190b2011-03-14 21:23:01 +0000224
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000225 // Indicator variable specifying the type of GL implementation
226 // exported: GLES{1|2} or Desktop.
227 GrGLBinding fBindingsExported;
228
tomhudson@google.com747bf292011-06-14 18:16:52 +0000229 /// Does this GL support NPOT textures on FBOs?
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000230 /// boolean value, or kProbe_GrGLCapability to probe (slowly) at context creation.
tomhudson@google.com747bf292011-06-14 18:16:52 +0000231 int fNPOTRenderTargetSupport;
232
233 /// Some GL implementations (PowerVR SGX devices like the iPhone 4)
234 /// have restrictions on the size of small render targets.
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000235 /// kProbe_GrGLCapability to probe (slowly) at context creation.
tomhudson@google.com747bf292011-06-14 18:16:52 +0000236 int fMinRenderTargetHeight;
237 int fMinRenderTargetWidth;
238
twiz@google.com59a190b2011-03-14 21:23:01 +0000239 GrGLActiveTextureProc fActiveTexture;
240 GrGLAttachShaderProc fAttachShader;
241 GrGLBindAttribLocationProc fBindAttribLocation;
242 GrGLBindBufferProc fBindBuffer;
243 GrGLBindTextureProc fBindTexture;
bsalomon@google.com080773c2011-03-15 19:09:25 +0000244 GrGLBlendColorProc fBlendColor;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000245 GrGLBlendFuncProc fBlendFunc;
twiz@google.com59a190b2011-03-14 21:23:01 +0000246 GrGLBufferDataProc fBufferData;
247 GrGLBufferSubDataProc fBufferSubData;
248 GrGLClearProc fClear;
249 GrGLClearColorProc fClearColor;
250 GrGLClearStencilProc fClearStencil;
251 GrGLClientActiveTextureProc fClientActiveTexture;
252 GrGLColor4ubProc fColor4ub;
253 GrGLColorMaskProc fColorMask;
254 GrGLColorPointerProc fColorPointer;
255 GrGLCompileShaderProc fCompileShader;
256 GrGLCompressedTexImage2DProc fCompressedTexImage2D;
257 GrGLCreateProgramProc fCreateProgram;
258 GrGLCreateShaderProc fCreateShader;
259 GrGLCullFaceProc fCullFace;
260 GrGLDeleteBuffersProc fDeleteBuffers;
261 GrGLDeleteProgramProc fDeleteProgram;
262 GrGLDeleteShaderProc fDeleteShader;
263 GrGLDeleteTexturesProc fDeleteTextures;
264 GrGLDepthMaskProc fDepthMask;
265 GrGLDisableProc fDisable;
266 GrGLDisableClientStateProc fDisableClientState;
267 GrGLDisableVertexAttribArrayProc fDisableVertexAttribArray;
268 GrGLDrawArraysProc fDrawArrays;
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000269 GrGLDrawBufferProc fDrawBuffer;
270 GrGLDrawBuffersProc fDrawBuffers;
twiz@google.com59a190b2011-03-14 21:23:01 +0000271 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;
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000286 GrGLGetTexLevelParameteriv fGetTexLevelParameteriv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000287 GrGLGetUniformLocationProc fGetUniformLocation;
288 GrGLLineWidthProc fLineWidth;
289 GrGLLinkProgramProc fLinkProgram;
290 GrGLLoadMatrixfProc fLoadMatrixf;
291 GrGLMatrixModeProc fMatrixMode;
292 GrGLPixelStoreiProc fPixelStorei;
293 GrGLPointSizeProc fPointSize;
294 GrGLReadPixelsProc fReadPixels;
295 GrGLScissorProc fScissor;
296 GrGLShadeModelProc fShadeModel;
297 GrGLShaderSourceProc fShaderSource;
298 GrGLStencilFuncProc fStencilFunc;
299 GrGLStencilFuncSeparateProc fStencilFuncSeparate;
300 GrGLStencilMaskProc fStencilMask;
301 GrGLStencilMaskSeparateProc fStencilMaskSeparate;
302 GrGLStencilOpProc fStencilOp;
303 GrGLStencilOpSeparateProc fStencilOpSeparate;
304 GrGLTexCoordPointerProc fTexCoordPointer;
305 GrGLTexEnviProc fTexEnvi;
306 GrGLTexImage2DProc fTexImage2D;
307 GrGLTexParameteriProc fTexParameteri;
308 GrGLTexSubImage2DProc fTexSubImage2D;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000309 GrGLUniform1fProc fUniform1f;
twiz@google.com59a190b2011-03-14 21:23:01 +0000310 GrGLUniform1iProc fUniform1i;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000311 GrGLUniform1fvProc fUniform1fv;
312 GrGLUniform1ivProc fUniform1iv;
313 GrGLUniform2fProc fUniform2f;
314 GrGLUniform2iProc fUniform2i;
315 GrGLUniform2fvProc fUniform2fv;
316 GrGLUniform2ivProc fUniform2iv;
317 GrGLUniform3fProc fUniform3f;
318 GrGLUniform3iProc fUniform3i;
319 GrGLUniform3fvProc fUniform3fv;
320 GrGLUniform3ivProc fUniform3iv;
321 GrGLUniform4fProc fUniform4f;
322 GrGLUniform4iProc fUniform4i;
twiz@google.com59a190b2011-03-14 21:23:01 +0000323 GrGLUniform4fvProc fUniform4fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000324 GrGLUniform4ivProc fUniform4iv;
325 GrGLUniformMatrix2fvProc fUniformMatrix2fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000326 GrGLUniformMatrix3fvProc fUniformMatrix3fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000327 GrGLUniformMatrix4fvProc fUniformMatrix4fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000328 GrGLUseProgramProc fUseProgram;
329 GrGLVertexAttrib4fvProc fVertexAttrib4fv;
330 GrGLVertexAttribPointerProc fVertexAttribPointer;
331 GrGLVertexPointerProc fVertexPointer;
332 GrGLViewportProc fViewport;
333
334 // FBO Extension Functions
335 GrGLBindFramebufferProc fBindFramebuffer;
336 GrGLBindRenderbufferProc fBindRenderbuffer;
337 GrGLCheckFramebufferStatusProc fCheckFramebufferStatus;
338 GrGLDeleteFramebuffersProc fDeleteFramebuffers;
339 GrGLDeleteRenderbuffersProc fDeleteRenderbuffers;
340 GrGLFramebufferRenderbufferProc fFramebufferRenderbuffer;
341 GrGLFramebufferTexture2DProc fFramebufferTexture2D;
342 GrGLGenFramebuffersProc fGenFramebuffers;
343 GrGLGenRenderbuffersProc fGenRenderbuffers;
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000344 GrGLGetFramebufferAttachmentParameterivProc fGetFramebufferAttachmentParameteriv;
345 GrGLGetRenderbufferParameterivProc fGetRenderbufferParameteriv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000346 GrGLRenderbufferStorageProc fRenderbufferStorage;
347
348 // Multisampling Extension Functions
349 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
350 GrGLRenderbufferStorageMultisampleProc fRenderbufferStorageMultisample;
351 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
352 GrGLBlitFramebufferProc fBlitFramebuffer;
353 // apple's es extension
354 GrGLResolveMultisampleFramebufferProc fResolveMultisampleFramebuffer;
355
twiz@google.com59a190b2011-03-14 21:23:01 +0000356 // Buffer mapping (extension in ES).
357 GrGLMapBufferProc fMapBuffer;
358 GrGLUnmapBufferProc fUnmapBuffer;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000359
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000360 // Dual Source Blending
361 GrGLBindFragDataLocationIndexedProc fBindFragDataLocationIndexed;
362
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000363 // Code that initializes this struct using a static initializer should
364 // make this the last entry in the static initializer. It can help to guard
365 // against failing to initialize newly-added members of this struct.
366 enum { kStaticInitEndGuard } fStaticInitEndGuard;
twiz@google.com59a190b2011-03-14 21:23:01 +0000367
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000368private:
369 bool validateShaderFunctions() const;
370 bool validateFixedFunctions() const;
371};
twiz@google.com59a190b2011-03-14 21:23:01 +0000372
373#endif