Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2012-01-26 |
2 | // Created by: Kirill GAVRILOV | |
3 | // Copyright (c) 2012-2012 OPEN CASCADE SAS | |
4 | // | |
5 | // The content of this file is subject to the Open CASCADE Technology Public | |
6 | // License Version 6.5 (the "License"). You may not use the content of this file | |
7 | // except in compliance with the License. Please obtain a copy of the License | |
8 | // at http://www.opencascade.org and read it completely before using this file. | |
9 | // | |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
12 | // | |
13 | // The Original Code and all software distributed under the License is | |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
15 | // Initial Developer hereby disclaims all such warranties, including without | |
16 | // limitation, any warranties of merchantability, fitness for a particular | |
17 | // purpose or non-infringement. Please see the License for the specific terms | |
18 | // and conditions governing the rights and limitations under the License. | |
19 | ||
2166f0fa | 20 | |
5f8b738e | 21 | #if (defined(_WIN32) || defined(__WIN32__)) |
22 | #include <windows.h> | |
23 | #endif | |
24 | ||
2166f0fa SK |
25 | #include <OpenGl_Context.hxx> |
26 | ||
5f8b738e | 27 | #include <OpenGl_ArbVBO.hxx> |
28 | #include <OpenGl_ExtFBO.hxx> | |
29 | #include <OpenGl_GlCore20.hxx> | |
30 | ||
2bd4c032 | 31 | #include <Standard_ProgramError.hxx> |
32 | ||
5f8b738e | 33 | #if (defined(_WIN32) || defined(__WIN32__)) |
34 | // | |
35 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) | |
36 | #include <dlfcn.h> | |
37 | #else | |
38 | #include <GL/glx.h> // glXGetProcAddress() | |
39 | #endif | |
40 | ||
2166f0fa SK |
41 | IMPLEMENT_STANDARD_HANDLE (OpenGl_Context, Standard_Transient) |
42 | IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Context, Standard_Transient) | |
43 | ||
5f8b738e | 44 | //! Make record shorter to retrieve function pointer using variable with same name |
45 | #define FindProcShort(theStruct, theFunc) FindProc(#theFunc, theStruct->theFunc) | |
2166f0fa SK |
46 | |
47 | // ======================================================================= | |
48 | // function : OpenGl_Context | |
49 | // purpose : | |
50 | // ======================================================================= | |
51 | OpenGl_Context::OpenGl_Context() | |
5f8b738e | 52 | : core12 (NULL), |
53 | core13 (NULL), | |
54 | core14 (NULL), | |
55 | core15 (NULL), | |
56 | core20 (NULL), | |
57 | arbVBO (NULL), | |
58 | extFBO (NULL), | |
59 | myGlLibHandle (NULL), | |
60 | myGlCore20 (NULL), | |
61 | myGlVerMajor (0), | |
62 | myGlVerMinor (0), | |
63 | myIsInitialized (Standard_False) | |
2166f0fa | 64 | { |
5f8b738e | 65 | #if defined(MAC_OS_X_VERSION_10_3) && !defined(MACOSX_USE_GLX) |
66 | // Vendors can not extend functionality on this system | |
67 | // and developers are limited to OpenGL support provided by Mac OS X SDK. | |
68 | // We retrieve function pointers from system library | |
69 | // to generalize extensions support on all platforms. | |
70 | // In this way we also reach binary compatibility benefit between OS releases | |
71 | // if some newest functionality is optionally used. | |
72 | // Notice that GL version / extension availability checks are required | |
73 | // because function pointers may be available but not functionality itself | |
74 | // (depends on renderer). | |
75 | myGlLibHandle = dlopen ("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); | |
76 | #endif | |
2166f0fa SK |
77 | } |
78 | ||
79 | // ======================================================================= | |
80 | // function : ~OpenGl_Context | |
81 | // purpose : | |
82 | // ======================================================================= | |
83 | OpenGl_Context::~OpenGl_Context() | |
84 | { | |
5f8b738e | 85 | delete myGlCore20; |
86 | delete arbVBO; | |
87 | delete extFBO; | |
88 | } | |
89 | ||
2bd4c032 | 90 | // ======================================================================= |
91 | // function : MakeCurrent | |
92 | // purpose : | |
93 | // ======================================================================= | |
94 | Standard_Boolean OpenGl_Context::MakeCurrent() | |
95 | { | |
96 | #if (defined(_WIN32) || defined(__WIN32__)) | |
97 | if (myWindowDC == NULL || myGContext == NULL || | |
98 | !wglMakeCurrent ((HDC )myWindowDC, (HGLRC )myGContext)) | |
99 | { | |
100 | //GLenum anErrCode = glGetError(); | |
101 | //const GLubyte* anErrorString = gluErrorString (anErrCode); | |
102 | //std::cerr << "wglMakeCurrent() failed: " << anErrCode << " " << anErrorString << "\n"; | |
103 | return Standard_False; | |
104 | } | |
105 | #else | |
106 | if (myDisplay == NULL || myWindow == 0 || myGContext == 0 || | |
107 | !glXMakeCurrent ((Display* )myDisplay, (GLXDrawable )myWindow, (GLXContext )myGContext)) | |
108 | { | |
109 | // if there is no current context it might be impossible to use glGetError() correctly | |
110 | //std::cerr << "glXMakeCurrent() failed!\n"; | |
111 | return Standard_False; | |
112 | } | |
113 | #endif | |
114 | return Standard_True; | |
115 | } | |
116 | ||
5f8b738e | 117 | // ======================================================================= |
118 | // function : findProc | |
119 | // purpose : | |
120 | // ======================================================================= | |
121 | void* OpenGl_Context::findProc (const char* theFuncName) | |
122 | { | |
123 | #if (defined(_WIN32) || defined(__WIN32__)) | |
124 | return wglGetProcAddress (theFuncName); | |
125 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) | |
126 | return (myGlLibHandle != NULL) ? dlsym (myGlLibHandle, theFuncName) : NULL; | |
127 | #else | |
128 | return (void* )glXGetProcAddress ((const GLubyte* )theFuncName); | |
129 | #endif | |
2166f0fa SK |
130 | } |
131 | ||
132 | // ======================================================================= | |
133 | // function : CheckExtension | |
134 | // purpose : | |
135 | // ======================================================================= | |
2bd4c032 | 136 | Standard_Boolean OpenGl_Context::CheckExtension (const char* theExtName) const |
2166f0fa | 137 | { |
5f8b738e | 138 | if (theExtName == NULL) |
139 | { | |
140 | std::cerr << "CheckExtension called with NULL string!\n"; | |
141 | return Standard_False; | |
142 | } | |
143 | int anExtNameLen = strlen (theExtName); | |
144 | ||
145 | // available since OpenGL 3.0 | |
146 | // and the ONLY way to check extensions with OpenGL 3.1+ core profile | |
2bd4c032 | 147 | /**if (IsGlGreaterEqual (3, 0)) |
5f8b738e | 148 | { |
149 | GLint anExtNb = 0; | |
150 | glGetIntegerv (GL_NUM_EXTENSIONS, &anExtNb); | |
151 | for (GLint anIter = 0; anIter < anExtNb; ++anIter) | |
152 | { | |
153 | const char* anExtension = (const char* )core30->glGetStringi (GL_EXTENSIONS, (GLuint )anIter); | |
154 | if (anExtension[anExtNameLen] == '\0' && | |
155 | strncmp (anExtension, theExtName, anExtNameLen) == 0) | |
156 | { | |
157 | return Standard_True; | |
158 | } | |
159 | } | |
160 | return Standard_False; | |
161 | }*/ | |
162 | ||
163 | // use old way with huge string for all extensions | |
164 | const char* anExtString = (const char* )glGetString (GL_EXTENSIONS); | |
165 | if (anExtString == NULL) | |
166 | { | |
167 | std::cerr << "glGetString (GL_EXTENSIONS) returns NULL! No GL context?\n"; | |
2166f0fa SK |
168 | return Standard_False; |
169 | } | |
170 | ||
171 | // Search for theExtName in the extensions string. | |
172 | // Use of strstr() is not sufficient because extension names can be prefixes of other extension names. | |
5f8b738e | 173 | char* aPtrIter = (char* )anExtString; |
174 | const char* aPtrEnd = aPtrIter + strlen (anExtString); | |
2166f0fa SK |
175 | while (aPtrIter < aPtrEnd) |
176 | { | |
177 | int n = strcspn (aPtrIter, " "); | |
5f8b738e | 178 | if ((n == anExtNameLen) && (strncmp (aPtrIter, theExtName, anExtNameLen) == 0)) |
179 | { | |
2166f0fa | 180 | return Standard_True; |
5f8b738e | 181 | } |
2166f0fa SK |
182 | aPtrIter += (n + 1); |
183 | } | |
184 | return Standard_False; | |
185 | } | |
186 | ||
187 | // ======================================================================= | |
188 | // function : Init | |
189 | // purpose : | |
190 | // ======================================================================= | |
191 | void OpenGl_Context::Init() | |
192 | { | |
2bd4c032 | 193 | if (myIsInitialized) |
5f8b738e | 194 | { |
2bd4c032 | 195 | return; |
5f8b738e | 196 | } |
2bd4c032 | 197 | |
198 | #if (defined(_WIN32) || defined(__WIN32__)) | |
199 | myWindowDC = (Aspect_Handle )wglGetCurrentDC(); | |
200 | myGContext = (Aspect_RenderingContext )wglGetCurrentContext(); | |
201 | #else | |
202 | myDisplay = (Aspect_Display )glXGetCurrentDisplay(); | |
203 | myGContext = (Aspect_RenderingContext )glXGetCurrentContext(); | |
204 | myWindow = (Aspect_Drawable )glXGetCurrentDrawable(); | |
205 | #endif | |
206 | ||
207 | init(); | |
208 | myIsInitialized = Standard_True; | |
209 | } | |
210 | ||
211 | // ======================================================================= | |
212 | // function : Init | |
213 | // purpose : | |
214 | // ======================================================================= | |
215 | #if (defined(_WIN32) || defined(__WIN32__)) | |
216 | void OpenGl_Context::Init (const Aspect_Handle theWindow, | |
217 | const Aspect_Handle theWindowDC, | |
218 | const Aspect_RenderingContext theGContext) | |
219 | #else | |
220 | void OpenGl_Context::Init (const Aspect_Drawable theWindow, | |
221 | const Aspect_Display theDisplay, | |
222 | const Aspect_RenderingContext theGContext) | |
223 | #endif | |
224 | { | |
225 | Standard_ProgramError_Raise_if (myIsInitialized, "OpenGl_Context::Init() should be called only once!"); | |
226 | ||
227 | myWindow = theWindow; | |
228 | myGContext = theGContext; | |
229 | #if (defined(_WIN32) || defined(__WIN32__)) | |
230 | myWindowDC = theWindowDC; | |
231 | #else | |
232 | myDisplay = theDisplay; | |
233 | #endif | |
234 | ||
235 | init(); | |
236 | myIsInitialized = Standard_True; | |
5f8b738e | 237 | } |
238 | ||
239 | // ======================================================================= | |
240 | // function : ResetErrors | |
241 | // purpose : | |
242 | // ======================================================================= | |
243 | void OpenGl_Context::ResetErrors() | |
244 | { | |
245 | while (glGetError() != GL_NO_ERROR) | |
246 | { | |
247 | // | |
248 | } | |
249 | } | |
250 | ||
251 | // ======================================================================= | |
252 | // function : readGlVersion | |
253 | // purpose : | |
254 | // ======================================================================= | |
255 | void OpenGl_Context::readGlVersion() | |
256 | { | |
257 | // reset values | |
258 | myGlVerMajor = 0; | |
259 | myGlVerMinor = 0; | |
260 | ||
261 | // available since OpenGL 3.0 | |
262 | GLint aMajor, aMinor; | |
263 | glGetIntegerv (GL_MAJOR_VERSION, &aMajor); | |
264 | glGetIntegerv (GL_MINOR_VERSION, &aMinor); | |
265 | if (glGetError() == GL_NO_ERROR) | |
266 | { | |
267 | myGlVerMajor = aMajor; | |
268 | myGlVerMinor = aMinor; | |
269 | return; | |
270 | } | |
271 | ResetErrors(); | |
272 | ||
273 | // Read version string. | |
274 | // Notice that only first two numbers splitted by point '2.1 XXXXX' are significant. | |
275 | // Following trash (after space) is vendor-specific. | |
276 | // New drivers also returns micro version of GL like '3.3.0' which has no meaning | |
277 | // and should be considered as vendor-specific too. | |
278 | const char* aVerStr = (const char* )glGetString (GL_VERSION); | |
279 | if (aVerStr == NULL || *aVerStr == '\0') | |
280 | { | |
281 | // invalid GL context | |
282 | return; | |
283 | } | |
284 | ||
285 | // parse string for major number | |
286 | char aMajorStr[32]; | |
287 | char aMinorStr[32]; | |
288 | size_t aMajIter = 0; | |
289 | while (aVerStr[aMajIter] >= '0' && aVerStr[aMajIter] <= '9') | |
290 | { | |
291 | ++aMajIter; | |
292 | } | |
293 | if (aMajIter == 0 || aMajIter >= sizeof(aMajorStr)) | |
294 | { | |
295 | return; | |
296 | } | |
297 | memcpy (aMajorStr, aVerStr, aMajIter); | |
298 | aMajorStr[aMajIter] = '\0'; | |
299 | ||
300 | // parse string for minor number | |
301 | size_t aMinIter = aMajIter + 1; | |
302 | while (aVerStr[aMinIter] >= '0' && aVerStr[aMinIter] <= '9') | |
303 | { | |
304 | ++aMinIter; | |
305 | } | |
306 | size_t aMinLen = aMinIter - aMajIter - 1; | |
307 | if (aMinLen == 0 || aMinLen >= sizeof(aMinorStr)) | |
308 | { | |
309 | return; | |
310 | } | |
311 | memcpy (aMinorStr, aVerStr, aMinLen); | |
312 | aMinorStr[aMinLen] = '\0'; | |
313 | ||
314 | // read numbers | |
315 | myGlVerMajor = atoi (aMajorStr); | |
316 | myGlVerMinor = atoi (aMinorStr); | |
317 | ||
318 | if (myGlVerMajor <= 0) | |
319 | { | |
320 | myGlVerMajor = 0; | |
321 | myGlVerMinor = 0; | |
322 | } | |
323 | } | |
324 | ||
325 | // ======================================================================= | |
326 | // function : init | |
327 | // purpose : | |
328 | // ======================================================================= | |
329 | void OpenGl_Context::init() | |
330 | { | |
331 | // read version | |
332 | readGlVersion(); | |
333 | ||
334 | // initialize VBO extension (ARB) | |
335 | if (CheckExtension ("GL_ARB_vertex_buffer_object")) | |
2166f0fa SK |
336 | { |
337 | arbVBO = new OpenGl_ArbVBO(); | |
5f8b738e | 338 | memset (arbVBO, 0, sizeof(OpenGl_ArbVBO)); // nullify whole structure |
339 | if (!FindProcShort (arbVBO, glGenBuffersARB) | |
340 | || !FindProcShort (arbVBO, glBindBufferARB) | |
341 | || !FindProcShort (arbVBO, glBufferDataARB) | |
342 | || !FindProcShort (arbVBO, glDeleteBuffersARB)) | |
2166f0fa SK |
343 | { |
344 | delete arbVBO; | |
345 | arbVBO = NULL; | |
346 | } | |
347 | } | |
348 | ||
5f8b738e | 349 | // initialize FBO extension (EXT) |
350 | if (CheckExtension ("GL_EXT_framebuffer_object")) | |
2166f0fa SK |
351 | { |
352 | extFBO = new OpenGl_ExtFBO(); | |
5f8b738e | 353 | memset (extFBO, 0, sizeof(OpenGl_ExtFBO)); // nullify whole structure |
354 | if (!FindProcShort (extFBO, glGenFramebuffersEXT) | |
355 | || !FindProcShort (extFBO, glDeleteFramebuffersEXT) | |
356 | || !FindProcShort (extFBO, glBindFramebufferEXT) | |
357 | || !FindProcShort (extFBO, glFramebufferTexture2DEXT) | |
358 | || !FindProcShort (extFBO, glCheckFramebufferStatusEXT) | |
359 | || !FindProcShort (extFBO, glGenRenderbuffersEXT) | |
360 | || !FindProcShort (extFBO, glDeleteRenderbuffersEXT) | |
361 | || !FindProcShort (extFBO, glBindRenderbufferEXT) | |
362 | || !FindProcShort (extFBO, glRenderbufferStorageEXT) | |
363 | || !FindProcShort (extFBO, glFramebufferRenderbufferEXT)) | |
2166f0fa SK |
364 | { |
365 | delete extFBO; | |
366 | extFBO = NULL; | |
367 | } | |
368 | } | |
5f8b738e | 369 | |
370 | myGlCore20 = new OpenGl_GlCore20(); | |
371 | memset (myGlCore20, 0, sizeof(OpenGl_GlCore20)); // nullify whole structure | |
372 | ||
373 | // initialize OpenGL 1.2 core functionality | |
2bd4c032 | 374 | if (IsGlGreaterEqual (1, 2)) |
5f8b738e | 375 | { |
376 | if (!FindProcShort (myGlCore20, glBlendColor) | |
377 | || !FindProcShort (myGlCore20, glBlendEquation) | |
378 | || !FindProcShort (myGlCore20, glDrawRangeElements) | |
379 | || !FindProcShort (myGlCore20, glTexImage3D) | |
380 | || !FindProcShort (myGlCore20, glTexSubImage3D) | |
381 | || !FindProcShort (myGlCore20, glCopyTexSubImage3D)) | |
382 | { | |
383 | myGlVerMajor = 1; | |
384 | myGlVerMinor = 1; | |
385 | } | |
386 | } | |
387 | ||
388 | // initialize OpenGL 1.3 core functionality | |
2bd4c032 | 389 | if (IsGlGreaterEqual (1, 3)) |
5f8b738e | 390 | { |
391 | if (!FindProcShort (myGlCore20, glActiveTexture) | |
392 | || !FindProcShort (myGlCore20, glSampleCoverage) | |
393 | || !FindProcShort (myGlCore20, glCompressedTexImage3D) | |
394 | || !FindProcShort (myGlCore20, glCompressedTexImage2D) | |
395 | || !FindProcShort (myGlCore20, glCompressedTexImage1D) | |
396 | || !FindProcShort (myGlCore20, glCompressedTexSubImage3D) | |
397 | || !FindProcShort (myGlCore20, glCompressedTexSubImage2D) | |
398 | || !FindProcShort (myGlCore20, glCompressedTexSubImage1D) | |
399 | || !FindProcShort (myGlCore20, glGetCompressedTexImage) | |
400 | // deprecated | |
401 | || !FindProcShort (myGlCore20, glClientActiveTexture) | |
402 | || !FindProcShort (myGlCore20, glMultiTexCoord1d) | |
403 | || !FindProcShort (myGlCore20, glMultiTexCoord1dv) | |
404 | || !FindProcShort (myGlCore20, glMultiTexCoord1f) | |
405 | || !FindProcShort (myGlCore20, glMultiTexCoord1fv) | |
406 | || !FindProcShort (myGlCore20, glMultiTexCoord1i) | |
407 | || !FindProcShort (myGlCore20, glMultiTexCoord1iv) | |
408 | || !FindProcShort (myGlCore20, glMultiTexCoord1s) | |
409 | || !FindProcShort (myGlCore20, glMultiTexCoord1sv) | |
410 | || !FindProcShort (myGlCore20, glMultiTexCoord2d) | |
411 | || !FindProcShort (myGlCore20, glMultiTexCoord2dv) | |
412 | || !FindProcShort (myGlCore20, glMultiTexCoord2f) | |
413 | || !FindProcShort (myGlCore20, glMultiTexCoord2fv) | |
414 | || !FindProcShort (myGlCore20, glMultiTexCoord2i) | |
415 | || !FindProcShort (myGlCore20, glMultiTexCoord2iv) | |
416 | || !FindProcShort (myGlCore20, glMultiTexCoord2s) | |
417 | || !FindProcShort (myGlCore20, glMultiTexCoord2sv) | |
418 | || !FindProcShort (myGlCore20, glMultiTexCoord3d) | |
419 | || !FindProcShort (myGlCore20, glMultiTexCoord3dv) | |
420 | || !FindProcShort (myGlCore20, glMultiTexCoord3f) | |
421 | || !FindProcShort (myGlCore20, glMultiTexCoord3fv) | |
422 | || !FindProcShort (myGlCore20, glMultiTexCoord3i) | |
423 | || !FindProcShort (myGlCore20, glMultiTexCoord3iv) | |
424 | || !FindProcShort (myGlCore20, glMultiTexCoord3s) | |
425 | || !FindProcShort (myGlCore20, glMultiTexCoord3sv) | |
426 | || !FindProcShort (myGlCore20, glMultiTexCoord4d) | |
427 | || !FindProcShort (myGlCore20, glMultiTexCoord4dv) | |
428 | || !FindProcShort (myGlCore20, glMultiTexCoord4f) | |
429 | || !FindProcShort (myGlCore20, glMultiTexCoord4fv) | |
430 | || !FindProcShort (myGlCore20, glMultiTexCoord4i) | |
431 | || !FindProcShort (myGlCore20, glMultiTexCoord4iv) | |
432 | || !FindProcShort (myGlCore20, glMultiTexCoord4s) | |
433 | || !FindProcShort (myGlCore20, glMultiTexCoord4sv) | |
434 | || !FindProcShort (myGlCore20, glLoadTransposeMatrixf) | |
435 | || !FindProcShort (myGlCore20, glLoadTransposeMatrixd) | |
436 | || !FindProcShort (myGlCore20, glMultTransposeMatrixf) | |
437 | || !FindProcShort (myGlCore20, glMultTransposeMatrixd)) | |
438 | { | |
439 | myGlVerMajor = 1; | |
440 | myGlVerMinor = 2; | |
441 | core12 = myGlCore20; | |
442 | } | |
443 | } | |
444 | ||
445 | // initialize OpenGL 1.4 core functionality | |
2bd4c032 | 446 | if (IsGlGreaterEqual (1, 4)) |
5f8b738e | 447 | { |
448 | if (!FindProcShort (myGlCore20, glBlendFuncSeparate) | |
449 | || !FindProcShort (myGlCore20, glMultiDrawArrays) | |
450 | || !FindProcShort (myGlCore20, glMultiDrawElements) | |
451 | || !FindProcShort (myGlCore20, glPointParameterf) | |
452 | || !FindProcShort (myGlCore20, glPointParameterfv) | |
453 | || !FindProcShort (myGlCore20, glPointParameteri) | |
454 | || !FindProcShort (myGlCore20, glPointParameteriv)) | |
455 | { | |
456 | myGlVerMajor = 1; | |
457 | myGlVerMinor = 3; | |
458 | core12 = myGlCore20; | |
459 | core13 = myGlCore20; | |
460 | } | |
461 | } | |
462 | ||
463 | // initialize OpenGL 1.5 core functionality | |
2bd4c032 | 464 | if (IsGlGreaterEqual (1, 5)) |
5f8b738e | 465 | { |
466 | if (!FindProcShort (myGlCore20, glGenQueries) | |
467 | || !FindProcShort (myGlCore20, glDeleteQueries) | |
468 | || !FindProcShort (myGlCore20, glIsQuery) | |
469 | || !FindProcShort (myGlCore20, glBeginQuery) | |
470 | || !FindProcShort (myGlCore20, glEndQuery) | |
471 | || !FindProcShort (myGlCore20, glGetQueryiv) | |
472 | || !FindProcShort (myGlCore20, glGetQueryObjectiv) | |
473 | || !FindProcShort (myGlCore20, glGetQueryObjectuiv) | |
474 | || !FindProcShort (myGlCore20, glBindBuffer) | |
475 | || !FindProcShort (myGlCore20, glDeleteBuffers) | |
476 | || !FindProcShort (myGlCore20, glGenBuffers) | |
477 | || !FindProcShort (myGlCore20, glIsBuffer) | |
478 | || !FindProcShort (myGlCore20, glBufferData) | |
479 | || !FindProcShort (myGlCore20, glBufferSubData) | |
480 | || !FindProcShort (myGlCore20, glGetBufferSubData) | |
481 | || !FindProcShort (myGlCore20, glMapBuffer) | |
482 | || !FindProcShort (myGlCore20, glUnmapBuffer) | |
483 | || !FindProcShort (myGlCore20, glGetBufferParameteriv) | |
484 | || !FindProcShort (myGlCore20, glGetBufferPointerv)) | |
485 | { | |
486 | myGlVerMajor = 1; | |
487 | myGlVerMinor = 4; | |
488 | core12 = myGlCore20; | |
489 | core13 = myGlCore20; | |
490 | core14 = myGlCore20; | |
491 | } | |
492 | } | |
493 | ||
494 | // initialize OpenGL 2.0 core functionality | |
2bd4c032 | 495 | if (IsGlGreaterEqual (2, 0)) |
5f8b738e | 496 | { |
497 | if (!FindProcShort (myGlCore20, glBlendEquationSeparate) | |
498 | || !FindProcShort (myGlCore20, glDrawBuffers) | |
499 | || !FindProcShort (myGlCore20, glStencilOpSeparate) | |
500 | || !FindProcShort (myGlCore20, glStencilFuncSeparate) | |
501 | || !FindProcShort (myGlCore20, glStencilMaskSeparate) | |
502 | || !FindProcShort (myGlCore20, glAttachShader) | |
503 | || !FindProcShort (myGlCore20, glBindAttribLocation) | |
504 | || !FindProcShort (myGlCore20, glCompileShader) | |
505 | || !FindProcShort (myGlCore20, glCreateProgram) | |
506 | || !FindProcShort (myGlCore20, glCreateShader) | |
507 | || !FindProcShort (myGlCore20, glDeleteProgram) | |
508 | || !FindProcShort (myGlCore20, glDeleteShader) | |
509 | || !FindProcShort (myGlCore20, glDetachShader) | |
510 | || !FindProcShort (myGlCore20, glDisableVertexAttribArray) | |
511 | || !FindProcShort (myGlCore20, glEnableVertexAttribArray) | |
512 | || !FindProcShort (myGlCore20, glGetActiveAttrib) | |
513 | || !FindProcShort (myGlCore20, glGetActiveUniform) | |
514 | || !FindProcShort (myGlCore20, glGetAttachedShaders) | |
515 | || !FindProcShort (myGlCore20, glGetAttribLocation) | |
516 | || !FindProcShort (myGlCore20, glGetProgramiv) | |
517 | || !FindProcShort (myGlCore20, glGetProgramInfoLog) | |
518 | || !FindProcShort (myGlCore20, glGetShaderiv) | |
519 | || !FindProcShort (myGlCore20, glGetShaderInfoLog) | |
520 | || !FindProcShort (myGlCore20, glGetShaderSource) | |
521 | || !FindProcShort (myGlCore20, glGetUniformLocation) | |
522 | || !FindProcShort (myGlCore20, glGetUniformfv) | |
523 | || !FindProcShort (myGlCore20, glGetUniformiv) | |
524 | || !FindProcShort (myGlCore20, glGetVertexAttribdv) | |
525 | || !FindProcShort (myGlCore20, glGetVertexAttribfv) | |
526 | || !FindProcShort (myGlCore20, glGetVertexAttribiv) | |
527 | || !FindProcShort (myGlCore20, glGetVertexAttribPointerv) | |
528 | || !FindProcShort (myGlCore20, glIsProgram) | |
529 | || !FindProcShort (myGlCore20, glIsShader) | |
530 | || !FindProcShort (myGlCore20, glLinkProgram) | |
531 | || !FindProcShort (myGlCore20, glShaderSource) | |
532 | || !FindProcShort (myGlCore20, glUseProgram) | |
533 | || !FindProcShort (myGlCore20, glUniform1f) | |
534 | || !FindProcShort (myGlCore20, glUniform2f) | |
535 | || !FindProcShort (myGlCore20, glUniform3f) | |
536 | || !FindProcShort (myGlCore20, glUniform4f) | |
537 | || !FindProcShort (myGlCore20, glUniform1i) | |
538 | || !FindProcShort (myGlCore20, glUniform2i) | |
539 | || !FindProcShort (myGlCore20, glUniform3i) | |
540 | || !FindProcShort (myGlCore20, glUniform4i) | |
541 | || !FindProcShort (myGlCore20, glUniform1fv) | |
542 | || !FindProcShort (myGlCore20, glUniform2fv) | |
543 | || !FindProcShort (myGlCore20, glUniform3fv) | |
544 | || !FindProcShort (myGlCore20, glUniform4fv) | |
545 | || !FindProcShort (myGlCore20, glUniform1iv) | |
546 | || !FindProcShort (myGlCore20, glUniform2iv) | |
547 | || !FindProcShort (myGlCore20, glUniform3iv) | |
548 | || !FindProcShort (myGlCore20, glUniform4iv) | |
549 | || !FindProcShort (myGlCore20, glUniformMatrix2fv) | |
550 | || !FindProcShort (myGlCore20, glUniformMatrix3fv) | |
551 | || !FindProcShort (myGlCore20, glUniformMatrix4fv) | |
552 | || !FindProcShort (myGlCore20, glValidateProgram) | |
553 | || !FindProcShort (myGlCore20, glVertexAttrib1d) | |
554 | || !FindProcShort (myGlCore20, glVertexAttrib1dv) | |
555 | || !FindProcShort (myGlCore20, glVertexAttrib1f) | |
556 | || !FindProcShort (myGlCore20, glVertexAttrib1fv) | |
557 | || !FindProcShort (myGlCore20, glVertexAttrib1s) | |
558 | || !FindProcShort (myGlCore20, glVertexAttrib1sv) | |
559 | || !FindProcShort (myGlCore20, glVertexAttrib2d) | |
560 | || !FindProcShort (myGlCore20, glVertexAttrib2dv) | |
561 | || !FindProcShort (myGlCore20, glVertexAttrib2f) | |
562 | || !FindProcShort (myGlCore20, glVertexAttrib2fv) | |
563 | || !FindProcShort (myGlCore20, glVertexAttrib2s) | |
564 | || !FindProcShort (myGlCore20, glVertexAttrib2sv) | |
565 | || !FindProcShort (myGlCore20, glVertexAttrib3d) | |
566 | || !FindProcShort (myGlCore20, glVertexAttrib3dv) | |
567 | || !FindProcShort (myGlCore20, glVertexAttrib3f) | |
568 | || !FindProcShort (myGlCore20, glVertexAttrib3fv) | |
569 | || !FindProcShort (myGlCore20, glVertexAttrib3s) | |
570 | || !FindProcShort (myGlCore20, glVertexAttrib3sv) | |
571 | || !FindProcShort (myGlCore20, glVertexAttrib4Nbv) | |
572 | || !FindProcShort (myGlCore20, glVertexAttrib4Niv) | |
573 | || !FindProcShort (myGlCore20, glVertexAttrib4Nsv) | |
574 | || !FindProcShort (myGlCore20, glVertexAttrib4Nub) | |
575 | || !FindProcShort (myGlCore20, glVertexAttrib4Nubv) | |
576 | || !FindProcShort (myGlCore20, glVertexAttrib4Nuiv) | |
577 | || !FindProcShort (myGlCore20, glVertexAttrib4Nusv) | |
578 | || !FindProcShort (myGlCore20, glVertexAttrib4bv) | |
579 | || !FindProcShort (myGlCore20, glVertexAttrib4d) | |
580 | || !FindProcShort (myGlCore20, glVertexAttrib4dv) | |
581 | || !FindProcShort (myGlCore20, glVertexAttrib4f) | |
582 | || !FindProcShort (myGlCore20, glVertexAttrib4fv) | |
583 | || !FindProcShort (myGlCore20, glVertexAttrib4iv) | |
584 | || !FindProcShort (myGlCore20, glVertexAttrib4s) | |
585 | || !FindProcShort (myGlCore20, glVertexAttrib4sv) | |
586 | || !FindProcShort (myGlCore20, glVertexAttrib4ubv) | |
587 | || !FindProcShort (myGlCore20, glVertexAttrib4uiv) | |
588 | || !FindProcShort (myGlCore20, glVertexAttrib4usv) | |
589 | || !FindProcShort (myGlCore20, glVertexAttribPointer)) | |
590 | { | |
591 | myGlVerMajor = 1; | |
592 | myGlVerMinor = 5; | |
593 | core12 = myGlCore20; | |
594 | core13 = myGlCore20; | |
595 | core14 = myGlCore20; | |
596 | core15 = myGlCore20; | |
597 | } | |
598 | } | |
599 | ||
2bd4c032 | 600 | if (IsGlGreaterEqual (2, 0)) |
5f8b738e | 601 | { |
602 | core12 = myGlCore20; | |
603 | core13 = myGlCore20; | |
604 | core14 = myGlCore20; | |
605 | core15 = myGlCore20; | |
606 | core20 = myGlCore20; | |
607 | } | |
2166f0fa | 608 | } |