| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 1 | /* |
| 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.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 21 | #include "GrGLConfig.h" |
| bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame^] | 22 | #include "GrTypes.h" |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 23 | |
| 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.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 33 | |
| 34 | void gl_version_from_string(int* major, int* minor, |
| 35 | const char* versionString); |
| 36 | bool has_gl_extension_from_string(const char* ext, |
| 37 | const char* extensionString); |
| 38 | |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 39 | bool has_gl_extension(const char* ext); |
| 40 | void gl_version(int* major, int* minor); |
| 41 | |
| bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 42 | |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 43 | //////////////////////////////////////////////////////////////////////////////// |
| 44 | |
| 45 | /* |
| 46 | * Routines managing the global interface used to invoke OpenGL calls. |
| 47 | */ |
| 48 | struct GrGLInterface; |
| bsalomon@google.com | 9182610 | 2011-03-21 19:51:57 +0000 | [diff] [blame] | 49 | GR_API GrGLInterface* GrGLGetGLInterface(); |
| 50 | GR_API void GrGLSetGLInterface(GrGLInterface* gl_interface); |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 51 | |
| 52 | /* |
| bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 53 | * This is called when GrGLSetGLInterface() hasn't been called before creating a |
| 54 | * GrGpuGL object. It provides a default implementation. The actual implementation |
| 55 | * depends on which GrGLDefaultInterface_*.cpp has been linked. There are some |
| 56 | * platform-specific implementations provided as well as |
| 57 | * GrGLDefaultInterface_none.cpp which does nothing (effectively requiring an |
| 58 | * explicit GrGLSetGLInterface call by the host). |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 59 | */ |
| bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 60 | void GrGLSetDefaultGLInterface(); |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 61 | |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 62 | typedef unsigned int GrGLenum; |
| 63 | typedef unsigned char GrGLboolean; |
| 64 | typedef unsigned int GrGLbitfield; |
| 65 | typedef signed char GrGLbyte; |
| 66 | typedef short GrGLshort; |
| 67 | typedef int GrGLint; |
| 68 | typedef int GrGLsizei; |
| 69 | typedef unsigned char GrGLubyte; |
| 70 | typedef unsigned short GrGLushort; |
| 71 | typedef unsigned int GrGLuint; |
| 72 | typedef float GrGLfloat; |
| 73 | typedef float GrGLclampf; |
| 74 | typedef double GrGLdouble; |
| 75 | typedef double GrGLclampd; |
| 76 | typedef void GrGLvoid; |
| bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 77 | typedef long GrGLintptr; |
| 78 | typedef long GrGLsizeiptr; |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 79 | |
| twiz@google.com | b65e0cb | 2011-03-18 20:41:44 +0000 | [diff] [blame] | 80 | enum GrGLBinding { |
| 81 | kDesktop_GrGLBinding = 0x01, |
| 82 | kES1_GrGLBinding = 0x02, |
| 83 | kES2_GrGLBinding = 0x04 |
| 84 | }; |
| 85 | |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 86 | extern "C" { |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 87 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLActiveTextureProc)(GrGLenum texture); |
| 88 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLAttachShaderProc)(GrGLuint program, GrGLuint shader); |
| 89 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindAttribLocationProc)(GrGLuint program, GrGLuint index, const char* name); |
| 90 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindBufferProc)(GrGLenum target, GrGLuint buffer); |
| 91 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindTextureProc)(GrGLenum target, GrGLuint texture); |
| 92 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha); |
| 93 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor); |
| bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 94 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage); |
| 95 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferSubDataProc)(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const GrGLvoid* data); |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 96 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearProc)(GrGLbitfield mask); |
| 97 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha); |
| 98 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearStencilProc)(GrGLint s); |
| 99 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClientActiveTextureProc)(GrGLenum texture); |
| 100 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColor4ubProc)(GrGLubyte red, GrGLubyte green, GrGLubyte blue, GrGLubyte alpha); |
| 101 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorMaskProc)(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha); |
| 102 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer); |
| 103 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompileShaderProc)(GrGLuint shader); |
| 104 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompressedTexImage2DProc)(GrGLenum target, GrGLint level, GrGLenum internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLsizei imageSize, const GrGLvoid* data); |
| 105 | typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateProgramProc)(void); |
| 106 | typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateShaderProc)(GrGLenum type); |
| 107 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCullFaceProc)(GrGLenum mode); |
| 108 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteBuffersProc)(GrGLsizei n, const GrGLuint* buffers); |
| 109 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteProgramProc)(GrGLuint program); |
| 110 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteShaderProc)(GrGLuint shader); |
| 111 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteTexturesProc)(GrGLsizei n, const GrGLuint* textures); |
| 112 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDepthMaskProc)(GrGLboolean flag); |
| 113 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableProc)(GrGLenum cap); |
| 114 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableClientStateProc)(GrGLenum array); |
| 115 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableVertexAttribArrayProc)(GrGLuint index); |
| 116 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawArraysProc)(GrGLenum mode, GrGLint first, GrGLsizei count); |
| 117 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices); |
| 118 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableProc)(GrGLenum cap); |
| 119 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableClientStateProc)(GrGLenum cap); |
| 120 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableVertexAttribArrayProc)(GrGLuint index); |
| 121 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFrontFaceProc)(GrGLenum mode); |
| 122 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenBuffersProc)(GrGLsizei n, GrGLuint* buffers); |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 123 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures); |
| 124 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params); |
| bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 125 | typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLGetErrorProc)(void); |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 126 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetIntegervProc)(GrGLenum pname, GrGLint* params); |
| 127 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramInfoLogProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog); |
| 128 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramivProc)(GrGLuint program, GrGLenum pname, GrGLint* params); |
| 129 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderInfoLogProc)(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog); |
| 130 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderivProc)(GrGLuint shader, GrGLenum pname, GrGLint* params); |
| 131 | typedef const GrGLubyte* (GR_GL_FUNCTION_TYPE *GrGLGetStringProc)(GrGLenum name); |
| 132 | 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.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame^] | 154 | 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.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 156 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v); |
| bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame^] | 157 | 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.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 168 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v); |
| bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame^] | 169 | 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.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 171 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix3fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value); |
| bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame^] | 172 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix4fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value); |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 173 | 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.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 178 | |
| 179 | // FBO Extension Functions |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 180 | 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); |
| 189 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 190 | |
| 191 | // Multisampling Extension Functions |
| 192 | // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 193 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageMultisampleProc)(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 194 | // desktop: ext_fbo_blit, arb_fbo, gl 3.0 |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 195 | 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.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 196 | // apple's es extension |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 197 | typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLResolveMultisampleFramebufferProc)(); |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 198 | |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 199 | // Buffer mapping (extension in ES). |
| twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 200 | typedef GrGLvoid* (GR_GL_FUNCTION_TYPE *GrGLMapBufferProc)(GrGLenum target, GrGLenum access); |
| 201 | typedef GrGLboolean (GR_GL_FUNCTION_TYPE *GrGLUnmapBufferProc)(GrGLenum target); |
| bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame^] | 202 | } // extern "C" |
| 203 | |
| 204 | /* |
| 205 | * The following interface exports the OpenGL entry points used by the system. |
| 206 | * Use of OpenGL calls is disallowed. All calls should be invoked through |
| 207 | * the global instance of this struct, defined above. |
| 208 | * |
| 209 | * IMPORTANT NOTE: The OpenGL entry points exposed here include both core GL |
| 210 | * functions, and extensions. The system assumes that the address of the |
| 211 | * extension pointer will be valid across contexts. |
| 212 | */ |
| 213 | struct GrGLInterface { |
| 214 | bool validate(GrEngine engine) const; |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 215 | |
| twiz@google.com | b65e0cb | 2011-03-18 20:41:44 +0000 | [diff] [blame] | 216 | // Indicator variable specifying the type of GL implementation |
| 217 | // exported: GLES{1|2} or Desktop. |
| 218 | GrGLBinding fBindingsExported; |
| 219 | |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 220 | GrGLActiveTextureProc fActiveTexture; |
| 221 | GrGLAttachShaderProc fAttachShader; |
| 222 | GrGLBindAttribLocationProc fBindAttribLocation; |
| 223 | GrGLBindBufferProc fBindBuffer; |
| 224 | GrGLBindTextureProc fBindTexture; |
| bsalomon@google.com | 080773c | 2011-03-15 19:09:25 +0000 | [diff] [blame] | 225 | GrGLBlendColorProc fBlendColor; |
| bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 226 | GrGLBlendFuncProc fBlendFunc; |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 227 | GrGLBufferDataProc fBufferData; |
| 228 | GrGLBufferSubDataProc fBufferSubData; |
| 229 | GrGLClearProc fClear; |
| 230 | GrGLClearColorProc fClearColor; |
| 231 | GrGLClearStencilProc fClearStencil; |
| 232 | GrGLClientActiveTextureProc fClientActiveTexture; |
| 233 | GrGLColor4ubProc fColor4ub; |
| 234 | GrGLColorMaskProc fColorMask; |
| 235 | GrGLColorPointerProc fColorPointer; |
| 236 | GrGLCompileShaderProc fCompileShader; |
| 237 | GrGLCompressedTexImage2DProc fCompressedTexImage2D; |
| 238 | GrGLCreateProgramProc fCreateProgram; |
| 239 | GrGLCreateShaderProc fCreateShader; |
| 240 | GrGLCullFaceProc fCullFace; |
| 241 | GrGLDeleteBuffersProc fDeleteBuffers; |
| 242 | GrGLDeleteProgramProc fDeleteProgram; |
| 243 | GrGLDeleteShaderProc fDeleteShader; |
| 244 | GrGLDeleteTexturesProc fDeleteTextures; |
| 245 | GrGLDepthMaskProc fDepthMask; |
| 246 | GrGLDisableProc fDisable; |
| 247 | GrGLDisableClientStateProc fDisableClientState; |
| 248 | GrGLDisableVertexAttribArrayProc fDisableVertexAttribArray; |
| 249 | GrGLDrawArraysProc fDrawArrays; |
| 250 | GrGLDrawElementsProc fDrawElements; |
| 251 | GrGLEnableProc fEnable; |
| 252 | GrGLEnableClientStateProc fEnableClientState; |
| 253 | GrGLEnableVertexAttribArrayProc fEnableVertexAttribArray; |
| 254 | GrGLFrontFaceProc fFrontFace; |
| 255 | GrGLGenBuffersProc fGenBuffers; |
| 256 | GrGLGenTexturesProc fGenTextures; |
| 257 | GrGLGetBufferParameterivProc fGetBufferParameteriv; |
| 258 | GrGLGetErrorProc fGetError; |
| 259 | GrGLGetIntegervProc fGetIntegerv; |
| 260 | GrGLGetProgramInfoLogProc fGetProgramInfoLog; |
| 261 | GrGLGetProgramivProc fGetProgramiv; |
| 262 | GrGLGetShaderInfoLogProc fGetShaderInfoLog; |
| 263 | GrGLGetShaderivProc fGetShaderiv; |
| 264 | GrGLGetStringProc fGetString; |
| 265 | GrGLGetUniformLocationProc fGetUniformLocation; |
| 266 | GrGLLineWidthProc fLineWidth; |
| 267 | GrGLLinkProgramProc fLinkProgram; |
| 268 | GrGLLoadMatrixfProc fLoadMatrixf; |
| 269 | GrGLMatrixModeProc fMatrixMode; |
| 270 | GrGLPixelStoreiProc fPixelStorei; |
| 271 | GrGLPointSizeProc fPointSize; |
| 272 | GrGLReadPixelsProc fReadPixels; |
| 273 | GrGLScissorProc fScissor; |
| 274 | GrGLShadeModelProc fShadeModel; |
| 275 | GrGLShaderSourceProc fShaderSource; |
| 276 | GrGLStencilFuncProc fStencilFunc; |
| 277 | GrGLStencilFuncSeparateProc fStencilFuncSeparate; |
| 278 | GrGLStencilMaskProc fStencilMask; |
| 279 | GrGLStencilMaskSeparateProc fStencilMaskSeparate; |
| 280 | GrGLStencilOpProc fStencilOp; |
| 281 | GrGLStencilOpSeparateProc fStencilOpSeparate; |
| 282 | GrGLTexCoordPointerProc fTexCoordPointer; |
| 283 | GrGLTexEnviProc fTexEnvi; |
| 284 | GrGLTexImage2DProc fTexImage2D; |
| 285 | GrGLTexParameteriProc fTexParameteri; |
| 286 | GrGLTexSubImage2DProc fTexSubImage2D; |
| bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame^] | 287 | GrGLUniform1fProc fUniform1f; |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 288 | GrGLUniform1iProc fUniform1i; |
| bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame^] | 289 | GrGLUniform1fvProc fUniform1fv; |
| 290 | GrGLUniform1ivProc fUniform1iv; |
| 291 | GrGLUniform2fProc fUniform2f; |
| 292 | GrGLUniform2iProc fUniform2i; |
| 293 | GrGLUniform2fvProc fUniform2fv; |
| 294 | GrGLUniform2ivProc fUniform2iv; |
| 295 | GrGLUniform3fProc fUniform3f; |
| 296 | GrGLUniform3iProc fUniform3i; |
| 297 | GrGLUniform3fvProc fUniform3fv; |
| 298 | GrGLUniform3ivProc fUniform3iv; |
| 299 | GrGLUniform4fProc fUniform4f; |
| 300 | GrGLUniform4iProc fUniform4i; |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 301 | GrGLUniform4fvProc fUniform4fv; |
| bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame^] | 302 | GrGLUniform4ivProc fUniform4iv; |
| 303 | GrGLUniformMatrix2fvProc fUniformMatrix2fv; |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 304 | GrGLUniformMatrix3fvProc fUniformMatrix3fv; |
| bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame^] | 305 | GrGLUniformMatrix4fvProc fUniformMatrix4fv; |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 306 | GrGLUseProgramProc fUseProgram; |
| 307 | GrGLVertexAttrib4fvProc fVertexAttrib4fv; |
| 308 | GrGLVertexAttribPointerProc fVertexAttribPointer; |
| 309 | GrGLVertexPointerProc fVertexPointer; |
| 310 | GrGLViewportProc fViewport; |
| 311 | |
| 312 | // FBO Extension Functions |
| 313 | GrGLBindFramebufferProc fBindFramebuffer; |
| 314 | GrGLBindRenderbufferProc fBindRenderbuffer; |
| 315 | GrGLCheckFramebufferStatusProc fCheckFramebufferStatus; |
| 316 | GrGLDeleteFramebuffersProc fDeleteFramebuffers; |
| 317 | GrGLDeleteRenderbuffersProc fDeleteRenderbuffers; |
| 318 | GrGLFramebufferRenderbufferProc fFramebufferRenderbuffer; |
| 319 | GrGLFramebufferTexture2DProc fFramebufferTexture2D; |
| 320 | GrGLGenFramebuffersProc fGenFramebuffers; |
| 321 | GrGLGenRenderbuffersProc fGenRenderbuffers; |
| 322 | GrGLRenderbufferStorageProc fRenderbufferStorage; |
| 323 | |
| 324 | // Multisampling Extension Functions |
| 325 | // same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension |
| 326 | GrGLRenderbufferStorageMultisampleProc fRenderbufferStorageMultisample; |
| 327 | // desktop: ext_fbo_blit, arb_fbo, gl 3.0 |
| 328 | GrGLBlitFramebufferProc fBlitFramebuffer; |
| 329 | // apple's es extension |
| 330 | GrGLResolveMultisampleFramebufferProc fResolveMultisampleFramebuffer; |
| 331 | |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 332 | // Buffer mapping (extension in ES). |
| 333 | GrGLMapBufferProc fMapBuffer; |
| 334 | GrGLUnmapBufferProc fUnmapBuffer; |
| bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 335 | |
| 336 | // Code that initializes this struct using a static initializer should |
| 337 | // make this the last entry in the static initializer. It can help to guard |
| 338 | // against failing to initialize newly-added members of this struct. |
| 339 | enum { kStaticInitEndGuard } fStaticInitEndGuard; |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 340 | |
| bsalomon@google.com | bf2a469 | 2011-05-04 12:35:39 +0000 | [diff] [blame^] | 341 | private: |
| 342 | bool validateShaderFunctions() const; |
| 343 | bool validateFixedFunctions() const; |
| 344 | }; |
| twiz@google.com | 59a190b | 2011-03-14 21:23:01 +0000 | [diff] [blame] | 345 | |
| 346 | #endif |