blob: 0e0c5666b10c95fe8c5d29ed6ae73662ba8cb391 [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);
bsalomon@google.comc49d66b2011-08-03 14:22:30 +0000139 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLReadBufferProc)(GrGLenum src);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000140 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);
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000190 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetFramebufferAttachmentParameterivProc)(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params);
191 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetRenderbufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000192 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
twiz@google.com59a190b2011-03-14 21:23:01 +0000193
194 // Multisampling Extension Functions
195 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
twiz@google.com0f31ca72011-03-18 17:38:11 +0000196 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 +0000197 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
twiz@google.com0f31ca72011-03-18 17:38:11 +0000198 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 +0000199 // apple's es extension
twiz@google.com0f31ca72011-03-18 17:38:11 +0000200 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLResolveMultisampleFramebufferProc)();
twiz@google.com59a190b2011-03-14 21:23:01 +0000201
twiz@google.com59a190b2011-03-14 21:23:01 +0000202 // Buffer mapping (extension in ES).
twiz@google.com0f31ca72011-03-18 17:38:11 +0000203 typedef GrGLvoid* (GR_GL_FUNCTION_TYPE *GrGLMapBufferProc)(GrGLenum target, GrGLenum access);
204 typedef GrGLboolean (GR_GL_FUNCTION_TYPE *GrGLUnmapBufferProc)(GrGLenum target);
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000205
206 // Dual source blending
207 typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name);
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000208} // extern "C"
209
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000210enum GrGLCapability {
211 kProbe_GrGLCapability = -1
tomhudson@google.com30e4bb62011-06-15 19:41:46 +0000212};
213
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000214/*
215 * The following interface exports the OpenGL entry points used by the system.
216 * Use of OpenGL calls is disallowed. All calls should be invoked through
217 * the global instance of this struct, defined above.
218 *
219 * IMPORTANT NOTE: The OpenGL entry points exposed here include both core GL
220 * functions, and extensions. The system assumes that the address of the
221 * extension pointer will be valid across contexts.
222 */
223struct GrGLInterface {
224 bool validate(GrEngine engine) const;
twiz@google.com59a190b2011-03-14 21:23:01 +0000225
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000226 // Indicator variable specifying the type of GL implementation
227 // exported: GLES{1|2} or Desktop.
228 GrGLBinding fBindingsExported;
229
tomhudson@google.com747bf292011-06-14 18:16:52 +0000230 /// Does this GL support NPOT textures on FBOs?
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000231 /// boolean value, or kProbe_GrGLCapability to probe (slowly) at context creation.
tomhudson@google.com747bf292011-06-14 18:16:52 +0000232 int fNPOTRenderTargetSupport;
233
234 /// Some GL implementations (PowerVR SGX devices like the iPhone 4)
235 /// have restrictions on the size of small render targets.
tomhudson@google.come67bd3f2011-06-16 14:08:04 +0000236 /// kProbe_GrGLCapability to probe (slowly) at context creation.
tomhudson@google.com747bf292011-06-14 18:16:52 +0000237 int fMinRenderTargetHeight;
238 int fMinRenderTargetWidth;
239
twiz@google.com59a190b2011-03-14 21:23:01 +0000240 GrGLActiveTextureProc fActiveTexture;
241 GrGLAttachShaderProc fAttachShader;
242 GrGLBindAttribLocationProc fBindAttribLocation;
243 GrGLBindBufferProc fBindBuffer;
244 GrGLBindTextureProc fBindTexture;
bsalomon@google.com080773c2011-03-15 19:09:25 +0000245 GrGLBlendColorProc fBlendColor;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000246 GrGLBlendFuncProc fBlendFunc;
twiz@google.com59a190b2011-03-14 21:23:01 +0000247 GrGLBufferDataProc fBufferData;
248 GrGLBufferSubDataProc fBufferSubData;
249 GrGLClearProc fClear;
250 GrGLClearColorProc fClearColor;
251 GrGLClearStencilProc fClearStencil;
252 GrGLClientActiveTextureProc fClientActiveTexture;
253 GrGLColor4ubProc fColor4ub;
254 GrGLColorMaskProc fColorMask;
255 GrGLColorPointerProc fColorPointer;
256 GrGLCompileShaderProc fCompileShader;
257 GrGLCompressedTexImage2DProc fCompressedTexImage2D;
258 GrGLCreateProgramProc fCreateProgram;
259 GrGLCreateShaderProc fCreateShader;
260 GrGLCullFaceProc fCullFace;
261 GrGLDeleteBuffersProc fDeleteBuffers;
262 GrGLDeleteProgramProc fDeleteProgram;
263 GrGLDeleteShaderProc fDeleteShader;
264 GrGLDeleteTexturesProc fDeleteTextures;
265 GrGLDepthMaskProc fDepthMask;
266 GrGLDisableProc fDisable;
267 GrGLDisableClientStateProc fDisableClientState;
268 GrGLDisableVertexAttribArrayProc fDisableVertexAttribArray;
269 GrGLDrawArraysProc fDrawArrays;
bsalomon@google.comd32c5f52011-08-02 19:29:03 +0000270 GrGLDrawBufferProc fDrawBuffer;
271 GrGLDrawBuffersProc fDrawBuffers;
twiz@google.com59a190b2011-03-14 21:23:01 +0000272 GrGLDrawElementsProc fDrawElements;
273 GrGLEnableProc fEnable;
274 GrGLEnableClientStateProc fEnableClientState;
275 GrGLEnableVertexAttribArrayProc fEnableVertexAttribArray;
276 GrGLFrontFaceProc fFrontFace;
277 GrGLGenBuffersProc fGenBuffers;
278 GrGLGenTexturesProc fGenTextures;
279 GrGLGetBufferParameterivProc fGetBufferParameteriv;
280 GrGLGetErrorProc fGetError;
281 GrGLGetIntegervProc fGetIntegerv;
282 GrGLGetProgramInfoLogProc fGetProgramInfoLog;
283 GrGLGetProgramivProc fGetProgramiv;
284 GrGLGetShaderInfoLogProc fGetShaderInfoLog;
285 GrGLGetShaderivProc fGetShaderiv;
286 GrGLGetStringProc fGetString;
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000287 GrGLGetTexLevelParameteriv fGetTexLevelParameteriv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000288 GrGLGetUniformLocationProc fGetUniformLocation;
289 GrGLLineWidthProc fLineWidth;
290 GrGLLinkProgramProc fLinkProgram;
291 GrGLLoadMatrixfProc fLoadMatrixf;
292 GrGLMatrixModeProc fMatrixMode;
293 GrGLPixelStoreiProc fPixelStorei;
294 GrGLPointSizeProc fPointSize;
bsalomon@google.comc49d66b2011-08-03 14:22:30 +0000295 GrGLReadBufferProc fReadBuffer;
twiz@google.com59a190b2011-03-14 21:23:01 +0000296 GrGLReadPixelsProc fReadPixels;
297 GrGLScissorProc fScissor;
298 GrGLShadeModelProc fShadeModel;
299 GrGLShaderSourceProc fShaderSource;
300 GrGLStencilFuncProc fStencilFunc;
301 GrGLStencilFuncSeparateProc fStencilFuncSeparate;
302 GrGLStencilMaskProc fStencilMask;
303 GrGLStencilMaskSeparateProc fStencilMaskSeparate;
304 GrGLStencilOpProc fStencilOp;
305 GrGLStencilOpSeparateProc fStencilOpSeparate;
306 GrGLTexCoordPointerProc fTexCoordPointer;
307 GrGLTexEnviProc fTexEnvi;
308 GrGLTexImage2DProc fTexImage2D;
309 GrGLTexParameteriProc fTexParameteri;
310 GrGLTexSubImage2DProc fTexSubImage2D;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000311 GrGLUniform1fProc fUniform1f;
twiz@google.com59a190b2011-03-14 21:23:01 +0000312 GrGLUniform1iProc fUniform1i;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000313 GrGLUniform1fvProc fUniform1fv;
314 GrGLUniform1ivProc fUniform1iv;
315 GrGLUniform2fProc fUniform2f;
316 GrGLUniform2iProc fUniform2i;
317 GrGLUniform2fvProc fUniform2fv;
318 GrGLUniform2ivProc fUniform2iv;
319 GrGLUniform3fProc fUniform3f;
320 GrGLUniform3iProc fUniform3i;
321 GrGLUniform3fvProc fUniform3fv;
322 GrGLUniform3ivProc fUniform3iv;
323 GrGLUniform4fProc fUniform4f;
324 GrGLUniform4iProc fUniform4i;
twiz@google.com59a190b2011-03-14 21:23:01 +0000325 GrGLUniform4fvProc fUniform4fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000326 GrGLUniform4ivProc fUniform4iv;
327 GrGLUniformMatrix2fvProc fUniformMatrix2fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000328 GrGLUniformMatrix3fvProc fUniformMatrix3fv;
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000329 GrGLUniformMatrix4fvProc fUniformMatrix4fv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000330 GrGLUseProgramProc fUseProgram;
331 GrGLVertexAttrib4fvProc fVertexAttrib4fv;
332 GrGLVertexAttribPointerProc fVertexAttribPointer;
333 GrGLVertexPointerProc fVertexPointer;
334 GrGLViewportProc fViewport;
335
336 // FBO Extension Functions
337 GrGLBindFramebufferProc fBindFramebuffer;
338 GrGLBindRenderbufferProc fBindRenderbuffer;
339 GrGLCheckFramebufferStatusProc fCheckFramebufferStatus;
340 GrGLDeleteFramebuffersProc fDeleteFramebuffers;
341 GrGLDeleteRenderbuffersProc fDeleteRenderbuffers;
342 GrGLFramebufferRenderbufferProc fFramebufferRenderbuffer;
343 GrGLFramebufferTexture2DProc fFramebufferTexture2D;
344 GrGLGenFramebuffersProc fGenFramebuffers;
345 GrGLGenRenderbuffersProc fGenRenderbuffers;
bsalomon@google.comcee661a2011-07-26 12:32:36 +0000346 GrGLGetFramebufferAttachmentParameterivProc fGetFramebufferAttachmentParameteriv;
347 GrGLGetRenderbufferParameterivProc fGetRenderbufferParameteriv;
twiz@google.com59a190b2011-03-14 21:23:01 +0000348 GrGLRenderbufferStorageProc fRenderbufferStorage;
349
350 // Multisampling Extension Functions
351 // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
352 GrGLRenderbufferStorageMultisampleProc fRenderbufferStorageMultisample;
353 // desktop: ext_fbo_blit, arb_fbo, gl 3.0
354 GrGLBlitFramebufferProc fBlitFramebuffer;
355 // apple's es extension
356 GrGLResolveMultisampleFramebufferProc fResolveMultisampleFramebuffer;
357
twiz@google.com59a190b2011-03-14 21:23:01 +0000358 // Buffer mapping (extension in ES).
359 GrGLMapBufferProc fMapBuffer;
360 GrGLUnmapBufferProc fUnmapBuffer;
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000361
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000362 // Dual Source Blending
363 GrGLBindFragDataLocationIndexedProc fBindFragDataLocationIndexed;
364
bsalomon@google.comf987d1b2011-04-04 17:13:52 +0000365 // Code that initializes this struct using a static initializer should
366 // make this the last entry in the static initializer. It can help to guard
367 // against failing to initialize newly-added members of this struct.
368 enum { kStaticInitEndGuard } fStaticInitEndGuard;
twiz@google.com59a190b2011-03-14 21:23:01 +0000369
bsalomon@google.combf2a4692011-05-04 12:35:39 +0000370private:
371 bool validateShaderFunctions() const;
372 bool validateFixedFunctions() const;
373};
twiz@google.com59a190b2011-03-14 21:23:01 +0000374
375#endif