robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame^] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 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. |
| 7 | */ |
| 8 | |
| 9 | |
| 10 | #include "gl/GrGLInterface.h" |
| 11 | |
| 12 | #ifndef GL_GLEXT_PROTOTYPES |
| 13 | #define GL_GLEXT_PROTOTYPES |
| 14 | #endif |
| 15 | |
| 16 | #include "GLES2/gl2.h" |
| 17 | #include "GLES2/gl2ext.h" |
| 18 | #include "EGL/egl.h" |
| 19 | |
| 20 | const GrGLInterface* GrGLCreateANGLEInterface() { |
| 21 | static SkAutoTUnref<GrGLInterface> glInterface; |
| 22 | if (!glInterface.get()) { |
| 23 | GrGLInterface* interface = new GrGLInterface; |
| 24 | glInterface.reset(interface); |
| 25 | interface->fBindingsExported = kES2_GrGLBinding; |
| 26 | interface->fActiveTexture = angle::glActiveTexture; |
| 27 | interface->fAttachShader = angle::glAttachShader; |
| 28 | interface->fBindAttribLocation = angle::glBindAttribLocation; |
| 29 | interface->fBindBuffer = angle::glBindBuffer; |
| 30 | interface->fBindTexture = angle::glBindTexture; |
| 31 | interface->fBlendColor = angle::glBlendColor; |
| 32 | interface->fBlendFunc = angle::glBlendFunc; |
| 33 | interface->fBufferData = angle::glBufferData; |
| 34 | interface->fBufferSubData = angle::glBufferSubData; |
| 35 | interface->fClear = angle::glClear; |
| 36 | interface->fClearColor = angle::glClearColor; |
| 37 | interface->fClearStencil = angle::glClearStencil; |
| 38 | interface->fColorMask = angle::glColorMask; |
| 39 | interface->fCompileShader = angle::glCompileShader; |
| 40 | interface->fCompressedTexImage2D = angle::glCompressedTexImage2D; |
| 41 | interface->fCreateProgram = angle::glCreateProgram; |
| 42 | interface->fCreateShader = angle::glCreateShader; |
| 43 | interface->fCullFace = angle::glCullFace; |
| 44 | interface->fDeleteBuffers = angle::glDeleteBuffers; |
| 45 | interface->fDeleteProgram = angle::glDeleteProgram; |
| 46 | interface->fDeleteShader = angle::glDeleteShader; |
| 47 | interface->fDeleteTextures = angle::glDeleteTextures; |
| 48 | interface->fDepthMask = angle::glDepthMask; |
| 49 | interface->fDisable = angle::glDisable; |
| 50 | interface->fDisableVertexAttribArray = angle::glDisableVertexAttribArray; |
| 51 | interface->fDrawArrays = angle::glDrawArrays; |
| 52 | interface->fDrawElements = angle::glDrawElements; |
| 53 | interface->fEnable = angle::glEnable; |
| 54 | interface->fEnableVertexAttribArray = angle::glEnableVertexAttribArray; |
| 55 | interface->fFinish = angle::glFinish; |
| 56 | interface->fFlush = angle::glFlush; |
| 57 | interface->fFrontFace = angle::glFrontFace; |
| 58 | interface->fGenBuffers = angle::glGenBuffers; |
| 59 | interface->fGenTextures = angle::glGenTextures; |
| 60 | interface->fGetBufferParameteriv = angle::glGetBufferParameteriv; |
| 61 | interface->fGetError = angle::glGetError; |
| 62 | interface->fGetIntegerv = angle::glGetIntegerv; |
| 63 | interface->fGetProgramInfoLog = angle::glGetProgramInfoLog; |
| 64 | interface->fGetProgramiv = angle::glGetProgramiv; |
| 65 | interface->fGetShaderInfoLog = angle::glGetShaderInfoLog; |
| 66 | interface->fGetShaderiv = angle::glGetShaderiv; |
| 67 | interface->fGetString = angle::glGetString; |
| 68 | interface->fGetUniformLocation = angle::glGetUniformLocation; |
| 69 | interface->fLineWidth = angle::glLineWidth; |
| 70 | interface->fLinkProgram = angle::glLinkProgram; |
| 71 | interface->fPixelStorei = angle::glPixelStorei; |
| 72 | interface->fReadPixels = angle::glReadPixels; |
| 73 | interface->fScissor = angle::glScissor; |
| 74 | interface->fShaderSource = angle::glShaderSource; |
| 75 | interface->fStencilFunc = angle::glStencilFunc; |
| 76 | interface->fStencilFuncSeparate = angle::glStencilFuncSeparate; |
| 77 | interface->fStencilMask = angle::glStencilMask; |
| 78 | interface->fStencilMaskSeparate = angle::glStencilMaskSeparate; |
| 79 | interface->fStencilOp = angle::glStencilOp; |
| 80 | interface->fStencilOpSeparate = angle::glStencilOpSeparate; |
| 81 | interface->fTexImage2D = angle::glTexImage2D; |
| 82 | interface->fTexParameteri = angle::glTexParameteri; |
| 83 | interface->fTexSubImage2D = angle::glTexSubImage2D; |
| 84 | #if GL_ARB_texture_storage |
| 85 | interface->fTexStorage2D = angle::glTexStorage2D; |
| 86 | #elif GL_EXT_texture_storage |
| 87 | interface->fTexStorage2D = angle::glTexStorage2DEXT; |
| 88 | #endif |
| 89 | interface->fUniform1f = angle::glUniform1f; |
| 90 | interface->fUniform1i = angle::glUniform1i; |
| 91 | interface->fUniform1fv = angle::glUniform1fv; |
| 92 | interface->fUniform1iv = angle::glUniform1iv; |
| 93 | interface->fUniform2f = angle::glUniform2f; |
| 94 | interface->fUniform2i = angle::glUniform2i; |
| 95 | interface->fUniform2fv = angle::glUniform2fv; |
| 96 | interface->fUniform2iv = angle::glUniform2iv; |
| 97 | interface->fUniform3f = angle::glUniform3f; |
| 98 | interface->fUniform3i = angle::glUniform3i; |
| 99 | interface->fUniform3fv = angle::glUniform3fv; |
| 100 | interface->fUniform3iv = angle::glUniform3iv; |
| 101 | interface->fUniform4f = angle::glUniform4f; |
| 102 | interface->fUniform4i = angle::glUniform4i; |
| 103 | interface->fUniform4fv = angle::glUniform4fv; |
| 104 | interface->fUniform4iv = angle::glUniform4iv; |
| 105 | interface->fUniformMatrix2fv = angle::glUniformMatrix2fv; |
| 106 | interface->fUniformMatrix3fv = angle::glUniformMatrix3fv; |
| 107 | interface->fUniformMatrix4fv = angle::glUniformMatrix4fv; |
| 108 | interface->fUseProgram = angle::glUseProgram; |
| 109 | interface->fVertexAttrib4fv = angle::glVertexAttrib4fv; |
| 110 | interface->fVertexAttribPointer = angle::glVertexAttribPointer; |
| 111 | interface->fViewport = angle::glViewport; |
| 112 | interface->fBindFramebuffer = angle::glBindFramebuffer; |
| 113 | interface->fBindRenderbuffer = angle::glBindRenderbuffer; |
| 114 | interface->fCheckFramebufferStatus = angle::glCheckFramebufferStatus; |
| 115 | interface->fDeleteFramebuffers = angle::glDeleteFramebuffers; |
| 116 | interface->fDeleteRenderbuffers = angle::glDeleteRenderbuffers; |
| 117 | interface->fFramebufferRenderbuffer = angle::glFramebufferRenderbuffer; |
| 118 | interface->fFramebufferTexture2D = angle::glFramebufferTexture2D; |
| 119 | interface->fGenFramebuffers = angle::glGenFramebuffers; |
| 120 | interface->fGenRenderbuffers = angle::glGenRenderbuffers; |
| 121 | interface->fGetFramebufferAttachmentParameteriv = angle::glGetFramebufferAttachmentParameteriv; |
| 122 | interface->fGetRenderbufferParameteriv = angle::glGetRenderbufferParameteriv; |
| 123 | interface->fRenderbufferStorage = angle::glRenderbufferStorage; |
| 124 | |
| 125 | interface->fMapBuffer = (angle::PFNGLMAPBUFFEROESPROC) angle::eglGetProcAddress("glMapBufferOES"); |
| 126 | interface->fUnmapBuffer = (angle::PFNGLUNMAPBUFFEROESPROC) angle::eglGetProcAddress("glUnmapBufferOES"); |
| 127 | } |
| 128 | glInterface.get()->ref(); |
| 129 | return glInterface.get(); |
| 130 | } |