|
1 |
|
2 /* |
|
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. |
|
7 */ |
|
8 |
|
9 |
|
10 #include "gl/GrGLInterface.h" |
|
11 |
|
12 #import <OpenGLES/ES2/gl.h> |
|
13 #import <OpenGLES/ES2/glext.h> |
|
14 |
|
15 const GrGLInterface* GrGLCreateNativeInterface() { |
|
16 GrGLInterface* interface = SkNEW(GrGLInterface); |
|
17 |
|
18 GrGLInterface::Functions* functions = &interface->fFunctions; |
|
19 |
|
20 functions->fActiveTexture = glActiveTexture; |
|
21 functions->fAttachShader = glAttachShader; |
|
22 functions->fBindAttribLocation = glBindAttribLocation; |
|
23 functions->fBindBuffer = glBindBuffer; |
|
24 functions->fBindTexture = glBindTexture; |
|
25 functions->fBlendColor = glBlendColor; |
|
26 functions->fBlendFunc = glBlendFunc; |
|
27 functions->fBufferData = (GrGLBufferDataProc)glBufferData; |
|
28 functions->fBufferSubData = (GrGLBufferSubDataProc)glBufferSubData; |
|
29 functions->fClear = glClear; |
|
30 functions->fClearColor = glClearColor; |
|
31 functions->fClearStencil = glClearStencil; |
|
32 functions->fColorMask = glColorMask; |
|
33 functions->fCompileShader = glCompileShader; |
|
34 functions->fCompressedTexImage2D = glCompressedTexImage2D; |
|
35 functions->fCopyTexSubImage2D = glCopyTexSubImage2D; |
|
36 functions->fCreateProgram = glCreateProgram; |
|
37 functions->fCreateShader = glCreateShader; |
|
38 functions->fCullFace = glCullFace; |
|
39 functions->fDeleteBuffers = glDeleteBuffers; |
|
40 functions->fDeleteProgram = glDeleteProgram; |
|
41 functions->fDeleteShader = glDeleteShader; |
|
42 functions->fDeleteTextures = glDeleteTextures; |
|
43 functions->fDepthMask = glDepthMask; |
|
44 functions->fDisable = glDisable; |
|
45 functions->fDisableVertexAttribArray = glDisableVertexAttribArray; |
|
46 functions->fDrawArrays = glDrawArrays; |
|
47 functions->fDrawBuffer = NULL; |
|
48 functions->fDrawBuffers = NULL; |
|
49 functions->fDrawElements = glDrawElements; |
|
50 functions->fEnable = glEnable; |
|
51 functions->fEnableVertexAttribArray = glEnableVertexAttribArray; |
|
52 functions->fFinish = glFinish; |
|
53 functions->fFlush = glFlush; |
|
54 functions->fFrontFace = glFrontFace; |
|
55 functions->fGenBuffers = glGenBuffers; |
|
56 functions->fGenerateMipmap = glGenerateMipmap; |
|
57 functions->fGetBufferParameteriv = glGetBufferParameteriv; |
|
58 functions->fGetError = glGetError; |
|
59 functions->fGetIntegerv = glGetIntegerv; |
|
60 functions->fGetProgramInfoLog = glGetProgramInfoLog; |
|
61 functions->fGetProgramiv = glGetProgramiv; |
|
62 functions->fGetShaderInfoLog = glGetShaderInfoLog; |
|
63 functions->fGetShaderiv = glGetShaderiv; |
|
64 functions->fGetString = glGetString; |
|
65 functions->fGenTextures = glGenTextures; |
|
66 functions->fGetUniformLocation = glGetUniformLocation; |
|
67 functions->fLineWidth = glLineWidth; |
|
68 functions->fLinkProgram = glLinkProgram; |
|
69 functions->fPixelStorei = glPixelStorei; |
|
70 functions->fReadBuffer = NULL; |
|
71 functions->fReadPixels = glReadPixels; |
|
72 functions->fScissor = glScissor; |
|
73 functions->fShaderSource = glShaderSource; |
|
74 functions->fStencilFunc = glStencilFunc; |
|
75 functions->fStencilFuncSeparate = glStencilFuncSeparate; |
|
76 functions->fStencilMask = glStencilMask; |
|
77 functions->fStencilMaskSeparate = glStencilMaskSeparate; |
|
78 functions->fStencilOp = glStencilOp; |
|
79 functions->fStencilOpSeparate = glStencilOpSeparate; |
|
80 // mac uses GLenum for internalFormat param (non-standard) |
|
81 // amounts to int vs. uint. |
|
82 functions->fTexImage2D = (GrGLTexImage2DProc)glTexImage2D; |
|
83 #if GL_ARB_texture_storage |
|
84 functions->fTexStorage2D = glTexStorage2D; |
|
85 #elif GL_EXT_texture_storage |
|
86 functions->fTexStorage2D = glTexStorage2DEXT; |
|
87 #endif |
|
88 #if GL_EXT_discard_framebuffer |
|
89 functions->fDiscardFramebuffer = glDiscardFramebufferEXT; |
|
90 #endif |
|
91 functions->fTexParameteri = glTexParameteri; |
|
92 functions->fTexParameteriv = glTexParameteriv; |
|
93 functions->fTexSubImage2D = glTexSubImage2D; |
|
94 functions->fUniform1f = glUniform1f; |
|
95 functions->fUniform1i = glUniform1i; |
|
96 functions->fUniform1fv = glUniform1fv; |
|
97 functions->fUniform1iv = glUniform1iv; |
|
98 functions->fUniform2f = glUniform2f; |
|
99 functions->fUniform2i = glUniform2i; |
|
100 functions->fUniform2fv = glUniform2fv; |
|
101 functions->fUniform2iv = glUniform2iv; |
|
102 functions->fUniform3f = glUniform3f; |
|
103 functions->fUniform3i = glUniform3i; |
|
104 functions->fUniform3fv = glUniform3fv; |
|
105 functions->fUniform3iv = glUniform3iv; |
|
106 functions->fUniform4f = glUniform4f; |
|
107 functions->fUniform4i = glUniform4i; |
|
108 functions->fUniform4fv = glUniform4fv; |
|
109 functions->fUniform4iv = glUniform4iv; |
|
110 functions->fUniform4fv = glUniform4fv; |
|
111 functions->fUniformMatrix2fv = glUniformMatrix2fv; |
|
112 functions->fUniformMatrix3fv = glUniformMatrix3fv; |
|
113 functions->fUniformMatrix4fv = glUniformMatrix4fv; |
|
114 functions->fUseProgram = glUseProgram; |
|
115 functions->fVertexAttrib4fv = glVertexAttrib4fv; |
|
116 functions->fVertexAttribPointer = glVertexAttribPointer; |
|
117 functions->fViewport = glViewport; |
|
118 functions->fGenFramebuffers = glGenFramebuffers; |
|
119 functions->fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv; |
|
120 functions->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv; |
|
121 functions->fBindFramebuffer = glBindFramebuffer; |
|
122 functions->fFramebufferTexture2D = glFramebufferTexture2D; |
|
123 functions->fCheckFramebufferStatus = glCheckFramebufferStatus; |
|
124 functions->fDeleteFramebuffers = glDeleteFramebuffers; |
|
125 functions->fRenderbufferStorage = glRenderbufferStorage; |
|
126 functions->fGenRenderbuffers = glGenRenderbuffers; |
|
127 functions->fDeleteRenderbuffers = glDeleteRenderbuffers; |
|
128 functions->fFramebufferRenderbuffer = glFramebufferRenderbuffer; |
|
129 functions->fBindRenderbuffer = glBindRenderbuffer; |
|
130 |
|
131 #if GL_OES_mapbuffer |
|
132 functions->fMapBuffer = glMapBufferOES; |
|
133 functions->fUnmapBuffer = glUnmapBufferOES; |
|
134 #endif |
|
135 |
|
136 #if GL_APPLE_framebuffer_multisample |
|
137 functions->fRenderbufferStorageMultisample = glRenderbufferStorageMultisampleAPPLE; |
|
138 functions->fResolveMultisampleFramebuffer = glResolveMultisampleFramebufferAPPLE; |
|
139 #endif |
|
140 |
|
141 #if GL_OES_vertex_array_object |
|
142 functions->fBindVertexArray = glBindVertexArrayOES; |
|
143 functions->fDeleteVertexArrays = glDeleteVertexArraysOES; |
|
144 functions->fGenVertexArrays = glGenVertexArraysOES; |
|
145 #endif |
|
146 |
|
147 #if GL_EXT_debug_marker |
|
148 functions->fInsertEventMarker = glInsertEventMarkerEXT; |
|
149 functions->fPushGroupMarker = glPushGroupMarkerEXT; |
|
150 functions->fPopGroupMarker = glPopGroupMarkerEXT; |
|
151 #endif |
|
152 |
|
153 interface->fStandard = kGLES_GrGLStandard; |
|
154 interface->fExtensions.init(kGLES_GrGLStandard, glGetString, NULL, glGetIntegerv); |
|
155 |
|
156 return interface; |
|
157 } |