yangsu@google.com | bd3e320 | 2011-07-13 22:05:00 +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 | #include "GrGLInterface.h" |
| 18 | |
| 19 | #import <OpenGLES/ES1/gl.h> |
| 20 | #import <OpenGLES/ES1/glext.h> |
| 21 | |
| 22 | #import <OpenGLES/ES2/gl.h> |
| 23 | #import <OpenGLES/ES2/glext.h> |
| 24 | |
| 25 | void GrGLSetDefaultGLInterface() { |
| 26 | static GrGLInterface gDefaultInterface; |
| 27 | static bool gDefaultInterfaceInit; |
| 28 | if (!gDefaultInterfaceInit) { |
| 29 | gDefaultInterface.fNPOTRenderTargetSupport = kProbe_GrGLCapability; |
| 30 | gDefaultInterface.fMinRenderTargetHeight = kProbe_GrGLCapability; |
| 31 | gDefaultInterface.fMinRenderTargetWidth = kProbe_GrGLCapability; |
| 32 | |
| 33 | gDefaultInterface.fActiveTexture = glActiveTexture; |
| 34 | gDefaultInterface.fAttachShader = glAttachShader; |
| 35 | gDefaultInterface.fBindAttribLocation = glBindAttribLocation; |
| 36 | gDefaultInterface.fBindBuffer = glBindBuffer; |
| 37 | gDefaultInterface.fBindTexture = glBindTexture; |
| 38 | gDefaultInterface.fBlendColor = glBlendColor; |
| 39 | gDefaultInterface.fBlendFunc = glBlendFunc; |
| 40 | gDefaultInterface.fBufferData = (GrGLBufferDataProc)glBufferData; |
| 41 | gDefaultInterface.fBufferSubData = (GrGLBufferSubDataProc)glBufferSubData; |
| 42 | gDefaultInterface.fClear = glClear; |
| 43 | gDefaultInterface.fClearColor = glClearColor; |
| 44 | gDefaultInterface.fClearStencil = glClearStencil; |
| 45 | gDefaultInterface.fClientActiveTexture = glClientActiveTexture; |
| 46 | gDefaultInterface.fColorMask = glColorMask; |
| 47 | gDefaultInterface.fColorPointer = glColorPointer; |
| 48 | gDefaultInterface.fColor4ub = glColor4ub; |
| 49 | gDefaultInterface.fCompileShader = glCompileShader; |
| 50 | gDefaultInterface.fCompressedTexImage2D = glCompressedTexImage2D; |
| 51 | gDefaultInterface.fCreateProgram = glCreateProgram; |
| 52 | gDefaultInterface.fCreateShader = glCreateShader; |
| 53 | gDefaultInterface.fCullFace = glCullFace; |
| 54 | gDefaultInterface.fDeleteBuffers = glDeleteBuffers; |
| 55 | gDefaultInterface.fDeleteProgram = glDeleteProgram; |
| 56 | gDefaultInterface.fDeleteShader = glDeleteShader; |
| 57 | gDefaultInterface.fDeleteTextures = glDeleteTextures; |
| 58 | gDefaultInterface.fDepthMask = glDepthMask; |
| 59 | gDefaultInterface.fDisable = glDisable; |
| 60 | gDefaultInterface.fDisableClientState = glDisableClientState; |
| 61 | gDefaultInterface.fDisableVertexAttribArray = |
| 62 | glDisableVertexAttribArray; |
| 63 | gDefaultInterface.fDrawArrays = glDrawArrays; |
| 64 | gDefaultInterface.fDrawElements = glDrawElements; |
| 65 | gDefaultInterface.fEnable = glEnable; |
| 66 | gDefaultInterface.fEnableClientState = glEnableClientState; |
| 67 | gDefaultInterface.fEnableVertexAttribArray = glEnableVertexAttribArray; |
| 68 | gDefaultInterface.fFrontFace = glFrontFace; |
| 69 | gDefaultInterface.fGenBuffers = glGenBuffers; |
| 70 | gDefaultInterface.fGetBufferParameteriv = glGetBufferParameteriv; |
| 71 | gDefaultInterface.fGetError = glGetError; |
| 72 | gDefaultInterface.fGetIntegerv = glGetIntegerv; |
| 73 | gDefaultInterface.fGetProgramInfoLog = glGetProgramInfoLog; |
| 74 | gDefaultInterface.fGetProgramiv = glGetProgramiv; |
| 75 | gDefaultInterface.fGetShaderInfoLog = glGetShaderInfoLog; |
| 76 | gDefaultInterface.fGetShaderiv = glGetShaderiv; |
| 77 | gDefaultInterface.fGetString = glGetString; |
| 78 | gDefaultInterface.fGenTextures = glGenTextures; |
| 79 | gDefaultInterface.fGetUniformLocation = glGetUniformLocation; |
| 80 | gDefaultInterface.fLineWidth = glLineWidth; |
| 81 | gDefaultInterface.fLinkProgram = glLinkProgram; |
| 82 | gDefaultInterface.fLoadMatrixf = glLoadMatrixf; |
| 83 | gDefaultInterface.fMatrixMode = glMatrixMode; |
| 84 | gDefaultInterface.fPointSize = glPointSize; |
| 85 | gDefaultInterface.fPixelStorei = glPixelStorei; |
| 86 | gDefaultInterface.fReadPixels = glReadPixels; |
| 87 | gDefaultInterface.fScissor = glScissor; |
| 88 | gDefaultInterface.fShadeModel = glShadeModel; |
| 89 | gDefaultInterface.fShaderSource = glShaderSource; |
| 90 | gDefaultInterface.fStencilFunc = glStencilFunc; |
| 91 | gDefaultInterface.fStencilFuncSeparate = glStencilFuncSeparate; |
| 92 | gDefaultInterface.fStencilMask = glStencilMask; |
| 93 | gDefaultInterface.fStencilMaskSeparate = glStencilMaskSeparate; |
| 94 | gDefaultInterface.fStencilOp = glStencilOp; |
| 95 | gDefaultInterface.fStencilOpSeparate = glStencilOpSeparate; |
| 96 | gDefaultInterface.fTexCoordPointer = glTexCoordPointer; |
| 97 | gDefaultInterface.fTexEnvi = glTexEnvi; |
| 98 | // mac uses GLenum for internalFormat param (non-standard) |
| 99 | // amounts to int vs. uint. |
| 100 | gDefaultInterface.fTexImage2D = (GrGLTexImage2DProc)glTexImage2D; |
| 101 | gDefaultInterface.fTexParameteri = glTexParameteri; |
| 102 | gDefaultInterface.fTexSubImage2D = glTexSubImage2D; |
| 103 | gDefaultInterface.fUniform1f = glUniform1f; |
| 104 | gDefaultInterface.fUniform1i = glUniform1i; |
| 105 | gDefaultInterface.fUniform1fv = glUniform1fv; |
| 106 | gDefaultInterface.fUniform1iv = glUniform1iv; |
| 107 | gDefaultInterface.fUniform2f = glUniform2f; |
| 108 | gDefaultInterface.fUniform2i = glUniform2i; |
| 109 | gDefaultInterface.fUniform2fv = glUniform2fv; |
| 110 | gDefaultInterface.fUniform2iv = glUniform2iv; |
| 111 | gDefaultInterface.fUniform3f = glUniform3f; |
| 112 | gDefaultInterface.fUniform3i = glUniform3i; |
| 113 | gDefaultInterface.fUniform3fv = glUniform3fv; |
| 114 | gDefaultInterface.fUniform3iv = glUniform3iv; |
| 115 | gDefaultInterface.fUniform4f = glUniform4f; |
| 116 | gDefaultInterface.fUniform4i = glUniform4i; |
| 117 | gDefaultInterface.fUniform4fv = glUniform4fv; |
| 118 | gDefaultInterface.fUniform4iv = glUniform4iv; |
| 119 | gDefaultInterface.fUniform4fv = glUniform4fv; |
| 120 | gDefaultInterface.fUniformMatrix2fv = glUniformMatrix2fv; |
| 121 | gDefaultInterface.fUniformMatrix3fv = glUniformMatrix3fv; |
| 122 | gDefaultInterface.fUniformMatrix4fv = glUniformMatrix4fv; |
| 123 | gDefaultInterface.fUseProgram = glUseProgram; |
| 124 | gDefaultInterface.fVertexAttrib4fv = glVertexAttrib4fv; |
| 125 | gDefaultInterface.fVertexAttribPointer = glVertexAttribPointer; |
| 126 | gDefaultInterface.fVertexPointer = glVertexPointer; |
| 127 | gDefaultInterface.fViewport = glViewport; |
| 128 | |
| 129 | gDefaultInterface.fGenFramebuffers = glGenFramebuffers; |
bsalomon@google.com | aab1fd9 | 2011-07-25 17:41:12 +0000 | [diff] [blame^] | 130 | gDefaultInterface.fGetFramebufferAttachmentParameteriv = glFramebufferAttachmentParameteriv; |
| 131 | gDefaultInterface.fGetRenderbufferParameteriv = glRenderbufferParameteriv; |
yangsu@google.com | bd3e320 | 2011-07-13 22:05:00 +0000 | [diff] [blame] | 132 | gDefaultInterface.fBindFramebuffer = glBindFramebuffer; |
| 133 | gDefaultInterface.fFramebufferTexture2D = glFramebufferTexture2D; |
| 134 | gDefaultInterface.fCheckFramebufferStatus = glCheckFramebufferStatus; |
| 135 | gDefaultInterface.fDeleteFramebuffers = glDeleteFramebuffers; |
| 136 | gDefaultInterface.fRenderbufferStorage = glRenderbufferStorage; |
| 137 | gDefaultInterface.fGenRenderbuffers = glGenRenderbuffers; |
| 138 | gDefaultInterface.fDeleteRenderbuffers = glDeleteRenderbuffers; |
| 139 | gDefaultInterface.fFramebufferRenderbuffer = glFramebufferRenderbuffer; |
| 140 | gDefaultInterface.fBindRenderbuffer = glBindRenderbuffer; |
| 141 | |
| 142 | #if GL_OES_mapbuffer |
| 143 | gDefaultInterface.fMapBuffer = glMapBufferOES; |
| 144 | gDefaultInterface.fUnmapBuffer = glUnmapBufferOES; |
| 145 | #endif |
| 146 | |
| 147 | #if GL_APPLE_framebuffer_multisample |
| 148 | gDefaultInterface.fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleAPPLE; |
| 149 | gDefaultInterface.fResolveMultisampleFramebuffer = glResolveMultisampleFramebufferAPPLE; |
| 150 | #endif |
| 151 | gDefaultInterface.fBindFragDataLocationIndexed = NULL; |
| 152 | |
| 153 | gDefaultInterface.fBindingsExported = kES2_GrGLBinding; |
| 154 | |
| 155 | gDefaultInterfaceInit = true; |
| 156 | } |
| 157 | GrGLSetGLInterface(&gDefaultInterface); |
| 158 | } |