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