1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL Utilities
3 * ---------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Function table initialization.
22 *//*--------------------------------------------------------------------*/
23
24 #include "glwInitFunctions.hpp"
25 #include "deSTLUtil.hpp"
26
27 #include <string>
28 #include <set>
29
30 namespace glw
31 {
32
33 // \todo [2014-03-19 pyry] Replace this with more generic system based on upstream XML spec desc.
34
initES20(Functions * gl,const FunctionLoader * loader)35 void initES20 (Functions* gl, const FunctionLoader* loader)
36 {
37 #include "glwInitES20.inl"
38 }
39
initES30(Functions * gl,const FunctionLoader * loader)40 void initES30 (Functions* gl, const FunctionLoader* loader)
41 {
42 #include "glwInitES30.inl"
43 }
44
initES31(Functions * gl,const FunctionLoader * loader)45 void initES31 (Functions* gl, const FunctionLoader* loader)
46 {
47 #include "glwInitES31.inl"
48 }
49
initGL30Core(Functions * gl,const FunctionLoader * loader)50 void initGL30Core (Functions* gl, const FunctionLoader* loader)
51 {
52 #include "glwInitGL30.inl"
53 }
54
initGL31Core(Functions * gl,const FunctionLoader * loader)55 void initGL31Core (Functions* gl, const FunctionLoader* loader)
56 {
57 #include "glwInitGL31.inl"
58 }
59
initGL32Core(Functions * gl,const FunctionLoader * loader)60 void initGL32Core (Functions* gl, const FunctionLoader* loader)
61 {
62 #include "glwInitGL32.inl"
63 }
64
initGL33Core(Functions * gl,const FunctionLoader * loader)65 void initGL33Core (Functions* gl, const FunctionLoader* loader)
66 {
67 #include "glwInitGL33.inl"
68 }
69
initGL40Core(Functions * gl,const FunctionLoader * loader)70 void initGL40Core (Functions* gl, const FunctionLoader* loader)
71 {
72 #include "glwInitGL40.inl"
73 }
74
initGL41Core(Functions * gl,const FunctionLoader * loader)75 void initGL41Core (Functions* gl, const FunctionLoader* loader)
76 {
77 #include "glwInitGL41.inl"
78 }
79
initGL42Core(Functions * gl,const FunctionLoader * loader)80 void initGL42Core (Functions* gl, const FunctionLoader* loader)
81 {
82 #include "glwInitGL42.inl"
83 }
84
initGL43Core(Functions * gl,const FunctionLoader * loader)85 void initGL43Core (Functions* gl, const FunctionLoader* loader)
86 {
87 #include "glwInitGL43.inl"
88 }
89
initGL44Core(Functions * gl,const FunctionLoader * loader)90 void initGL44Core (Functions* gl, const FunctionLoader* loader)
91 {
92 #include "glwInitGL44.inl"
93 }
94
initExtensionsShared(Functions * gl,const FunctionLoader * loader,const std::set<std::string> & extensions)95 void initExtensionsShared (Functions* gl, const FunctionLoader* loader, const std::set<std::string>& extensions)
96 {
97 if (de::contains(extensions, "GL_KHR_blend_equation_advanced"))
98 {
99 gl->blendBarrierKHR = (glBlendBarrierKHRFunc) loader->get("glBlendBarrierKHR");
100 }
101 }
102
initExtensionsGL(Functions * gl,const FunctionLoader * loader,int numExtensions,const char * const * extensions)103 void initExtensionsGL (Functions* gl, const FunctionLoader* loader, int numExtensions, const char* const* extensions)
104 {
105 using std::string;
106 using std::set;
107
108 const set<string> extSet(extensions, extensions+numExtensions);
109
110 initExtensionsShared(gl, loader, extSet);
111
112 if (de::contains(extSet, "GL_KHR_debug"))
113 {
114 /*
115 From the spec:
116 NOTE: when implemented in an OpenGL ES context, all entry points defined
117 by this extension must have a "KHR" suffix. When implemented in an
118 OpenGL context, all entry points must have NO suffix, as shown below.
119 */
120 gl->debugMessageControl = (glDebugMessageControlFunc) loader->get("glDebugMessageControl");
121 gl->debugMessageInsert = (glDebugMessageInsertFunc) loader->get("glDebugMessageInsert");
122 gl->debugMessageCallback= (glDebugMessageCallbackFunc) loader->get("glDebugMessageCallback");
123 gl->getDebugMessageLog = (glGetDebugMessageLogFunc) loader->get("glGetDebugMessageLog");
124 gl->getPointerv = (glGetPointervFunc) loader->get("glGetPointerv");
125 gl->pushDebugGroup = (glPushDebugGroupFunc) loader->get("glPushDebugGroup");
126 gl->popDebugGroup = (glPopDebugGroupFunc) loader->get("glPopDebugGroup");
127 gl->objectLabel = (glObjectLabelFunc) loader->get("glObjectLabel");
128 gl->getObjectLabel = (glGetObjectLabelFunc) loader->get("glGetObjectLabel");
129 gl->objectPtrLabel = (glObjectPtrLabelFunc) loader->get("glObjectPtrLabel");
130 gl->getObjectPtrLabel = (glGetObjectPtrLabelFunc) loader->get("glGetObjectPtrLabel");
131 }
132 }
133
initExtensionsES(Functions * gl,const FunctionLoader * loader,int numExtensions,const char * const * extensions)134 void initExtensionsES (Functions* gl, const FunctionLoader* loader, int numExtensions, const char* const* extensions)
135 {
136 using std::string;
137 using std::set;
138
139 const set<string> extSet(extensions, extensions+numExtensions);
140
141 initExtensionsShared(gl, loader, extSet);
142
143 if (de::contains(extSet, "GL_OES_sample_shading"))
144 {
145 gl->minSampleShading = (glMinSampleShadingFunc) loader->get("glMinSampleShadingOES");
146 }
147
148 if (de::contains(extSet, "GL_OES_texture_storage_multisample_2d_array"))
149 {
150 gl->texStorage3DMultisample = (glTexStorage3DMultisampleFunc) loader->get("glTexStorage3DMultisampleOES");
151 }
152
153 if (de::contains(extSet, "GL_KHR_debug"))
154 {
155 /*
156 From the spec:
157 NOTE: when implemented in an OpenGL ES context, all entry points defined
158 by this extension must have a "KHR" suffix. When implemented in an
159 OpenGL context, all entry points must have NO suffix, as shown below.
160 */
161 gl->debugMessageControl = (glDebugMessageControlFunc) loader->get("glDebugMessageControlKHR");
162 gl->debugMessageInsert = (glDebugMessageInsertFunc) loader->get("glDebugMessageInsertKHR");
163 gl->debugMessageCallback = (glDebugMessageCallbackFunc) loader->get("glDebugMessageCallbackKHR");
164 gl->getDebugMessageLog = (glGetDebugMessageLogFunc) loader->get("glGetDebugMessageLogKHR");
165 gl->getPointerv = (glGetPointervFunc) loader->get("glGetPointervKHR");
166 gl->pushDebugGroup = (glPushDebugGroupFunc) loader->get("glPushDebugGroupKHR");
167 gl->popDebugGroup = (glPopDebugGroupFunc) loader->get("glPopDebugGroupKHR");
168 gl->objectLabel = (glObjectLabelFunc) loader->get("glObjectLabelKHR");
169 gl->getObjectLabel = (glGetObjectLabelFunc) loader->get("glGetObjectLabelKHR");
170 gl->objectPtrLabel = (glObjectPtrLabelFunc) loader->get("glObjectPtrLabelKHR");
171 gl->getObjectPtrLabel = (glGetObjectPtrLabelFunc) loader->get("glGetObjectPtrLabelKHR");
172 }
173
174 if (de::contains(extSet, "GL_EXT_tessellation_shader"))
175 {
176 gl->patchParameteri = (glPatchParameteriFunc) loader->get("glPatchParameteriEXT");
177 }
178
179 if (de::contains(extSet, "GL_EXT_geometry_shader"))
180 {
181 gl->framebufferTexture = (glFramebufferTextureFunc) loader->get("glFramebufferTextureEXT");
182 }
183
184 if (de::contains(extSet, "GL_EXT_texture_buffer"))
185 {
186 gl->texBuffer = (glTexBufferFunc) loader->get("glTexBufferEXT");
187 gl->texBufferRange = (glTexBufferRangeFunc) loader->get("glTexBufferRangeEXT");
188 }
189 }
190
191 } // glw
192