Changeset View
Changeset View
Standalone View
Standalone View
source/lib/ogl.cpp
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
//---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||||
// define extension function pointers | // define extension function pointers | ||||
extern "C" | extern "C" | ||||
{ | { | ||||
#define FUNC(ret, name, params) ret (GL_CALL_CONV *p##name) params; | #define FUNC(ret, name, params) ret (GL_CALL_CONV *p##name) params; | ||||
#define FUNC2(ret, nameARB, nameCore, version, params) ret (GL_CALL_CONV *p##nameARB) params; | #define FUNC2(ret, nameARB, nameCore, version, params) ret (GL_CALL_CONV *p##nameARB) params; | ||||
#define FUNC3(ret, nameARB, nameCore, version, params) ret (GL_CALL_CONV *p##nameCore) params; | #define FUNC3(ret, nameARB, nameCore, version, params) ret (GL_CALL_CONV *p##nameCore) params; | ||||
#include "lib/external_libraries/glext_funcs.h" | |||||
#undef FUNC3 | #undef FUNC3 | ||||
#undef FUNC2 | #undef FUNC2 | ||||
#undef FUNC | #undef FUNC | ||||
} | } | ||||
static const char* exts = NULL; | static const char* exts = NULL; | ||||
static bool have_30, have_21, have_20, have_15, have_14, have_13, have_12; | static bool have_30, have_21, have_20, have_15, have_14, have_13, have_12; | ||||
▲ Show 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
glTexCoord3f(s, t, r); | glTexCoord3f(s, t, r); | ||||
} | } | ||||
static void enableDummyFunctions() | static void enableDummyFunctions() | ||||
{ | { | ||||
// fall back to the dummy functions when extensions (or equivalent core support) are missing | // fall back to the dummy functions when extensions (or equivalent core support) are missing | ||||
if(!ogl_HaveExtension("GL_EXT_draw_range_elements")) | //if(!ogl_HaveExtension("GL_EXT_draw_range_elements")) | ||||
{ | //{ | ||||
pglDrawRangeElementsEXT = &dummy_glDrawRangeElementsEXT; | // pglDrawRangeElementsEXT = &dummy_glDrawRangeElementsEXT; | ||||
} | //} | ||||
if(!ogl_HaveExtension("GL_ARB_multitexture")) | //if(!ogl_HaveExtension("GL_ARB_multitexture")) | ||||
{ | //{ | ||||
pglActiveTextureARB = &dummy_glActiveTextureARB; | // glActiveTextureARB = &dummy_glActiveTextureARB; | ||||
pglClientActiveTextureARB = &dummy_glClientActiveTextureARB; | // glClientActiveTextureARB = &dummy_glClientActiveTextureARB; | ||||
pglMultiTexCoord2fARB = &dummy_glMultiTexCoord2fARB; | // glMultiTexCoord2fARB = &dummy_glMultiTexCoord2fARB; | ||||
pglMultiTexCoord3fARB = &dummy_glMultiTexCoord3fARB; | // glMultiTexCoord3fARB = &dummy_glMultiTexCoord3fARB; | ||||
} | //} | ||||
} | } | ||||
#endif // #if CONFIG2_GLES | #endif // #if CONFIG2_GLES | ||||
static void importExtensionFunctions() | static void importExtensionFunctions() | ||||
{ | { | ||||
// It should be safe to load the ARB function pointers even if the | // It should be safe to load the ARB function pointers even if the | ||||
// extension isn't advertised, since we won't actually use them without | // extension isn't advertised, since we won't actually use them without | ||||
// checking for the extension. | // checking for the extension. | ||||
// (TODO: this calls ogl_HaveVersion far more times than is necessary - | // (TODO: this calls ogl_HaveVersion far more times than is necessary - | ||||
// we should probably use the have_* variables instead) | // we should probably use the have_* variables instead) | ||||
// Note: the xorg-x11 implementation of glXGetProcAddress doesn't return NULL | // Note: the xorg-x11 implementation of glXGetProcAddress doesn't return NULL | ||||
// if the function is unsupported (i.e. the rare case of a driver not reporting | // if the function is unsupported (i.e. the rare case of a driver not reporting | ||||
// its supported version correctly, see http://trac.wildfiregames.com/ticket/171) | // its supported version correctly, see http://trac.wildfiregames.com/ticket/171) | ||||
#define FUNC(ret, name, params) p##name = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#name); | #define FUNC(ret, name, params) p##name = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#name); | ||||
#define FUNC23(pname, ret, nameARB, nameCore, version, params) \ | #define FUNC23(pname, ret, nameARB, nameCore, version, params) \ | ||||
pname = NULL; \ | pname = NULL; \ | ||||
if(ogl_HaveVersion(version)) \ | if(ogl_HaveVersion(version)) \ | ||||
pname = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#nameCore); \ | pname = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#nameCore); \ | ||||
if(!pname) /* use the ARB name if the driver lied about what version it supports */ \ | if(!pname) /* use the ARB name if the driver lied about what version it supports */ \ | ||||
pname = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#nameARB); | pname = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#nameARB); | ||||
#define FUNC2(ret, nameARB, nameCore, version, params) FUNC23(p##nameARB, ret, nameARB, nameCore, version, params) | #define FUNC2(ret, nameARB, nameCore, version, params) FUNC23(p##nameARB, ret, nameARB, nameCore, version, params) | ||||
#define FUNC3(ret, nameARB, nameCore, version, params) FUNC23(p##nameCore, ret, nameARB, nameCore, version, params) | #define FUNC3(ret, nameARB, nameCore, version, params) FUNC23(p##nameCore, ret, nameARB, nameCore, version, params) | ||||
#include "lib/external_libraries/glext_funcs.h" | |||||
#undef FUNC3 | #undef FUNC3 | ||||
#undef FUNC2 | #undef FUNC2 | ||||
#undef FUNC23 | #undef FUNC23 | ||||
#undef FUNC | #undef FUNC | ||||
enableDummyFunctions(); | enableDummyFunctions(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator