From 87d34eaed1eb6941c172fe4e6dc6ec5483ecc0b2 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 27 Mar 2006 16:32:51 +0000 Subject: [PATCH] add glx-get-proc-address, glx-os-proc-address --- panda/src/glxdisplay/config_glxdisplay.cxx | 15 +++++ panda/src/glxdisplay/config_glxdisplay.h | 2 + .../glxdisplay/glxGraphicsStateGuardian.cxx | 64 ++++++++++--------- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/panda/src/glxdisplay/config_glxdisplay.cxx b/panda/src/glxdisplay/config_glxdisplay.cxx index 252b8339b9..421a690288 100644 --- a/panda/src/glxdisplay/config_glxdisplay.cxx +++ b/panda/src/glxdisplay/config_glxdisplay.cxx @@ -38,6 +38,21 @@ ConfigVariableString display_cfg ConfigVariableBool glx_error_abort ("glx-error-abort", false); +ConfigVariableBool glx_get_proc_address +("glx-get-proc-address", true, + PRC_DESC("Set this to true to allow the use of glxGetProcAddress(), if " + "it is available, to query the OpenGL extension functions. This " + "is the standard way to query extension functions.")); + + +ConfigVariableBool glx_get_os_address +("glx-get-os-address", true, + PRC_DESC("Set this to true to allow Panda to query the OpenGL library " + "directly using standard operating system calls to locate " + "addresses of extension functions. This will be done only " + "if glxGetProcAddress() cannot be used for some reason.")); + + //////////////////////////////////////////////////////////////////// // Function: init_libglxdisplay // Description: Initializes the library. This must be called at diff --git a/panda/src/glxdisplay/config_glxdisplay.h b/panda/src/glxdisplay/config_glxdisplay.h index 30f66bbd92..059361863c 100644 --- a/panda/src/glxdisplay/config_glxdisplay.h +++ b/panda/src/glxdisplay/config_glxdisplay.h @@ -30,5 +30,7 @@ extern EXPCL_PANDAGL void init_libglxdisplay(); extern ConfigVariableString display_cfg; extern ConfigVariableBool glx_error_abort; +extern ConfigVariableBool glx_get_proc_address; +extern ConfigVariableBool glx_get_os_address; #endif /* __CONFIG_GLXDISPLAY_H__ */ diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index ef528a02fa..1444391f44 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -228,39 +228,45 @@ get_extra_extensions() { //////////////////////////////////////////////////////////////////// void *glxGraphicsStateGuardian:: get_extension_func(const char *prefix, const char *name) { - if (!_checked_get_proc_address) { - // First, check if we have glxGetProcAddress available. This will - // be superior if we can get it. - const char *funcName = NULL; - - if (glx_is_at_least_version(1, 4)) { - funcName = "glXGetProcAddress"; - - } else if (has_extension("GLX_ARB_get_proc_address")) { - funcName = "glXGetProcAddressARB"; - } - - if (funcName != NULL) { - _glxGetProcAddress = (PFNGLXGETPROCADDRESSPROC)get_system_func(funcName); - if (_glxGetProcAddress == NULL) { - glxdisplay_cat.warning() - << "Couldn't load function " << funcName - << ", GL extensions may be unavailable.\n"; - } - } - - _checked_get_proc_address = true; - } - string fullname = string(prefix) + string(name); - // Use glxGetProcAddress() if we've got it; it should be more robust. - if (_glxGetProcAddress != NULL) { - return (void *)_glxGetProcAddress((const GLubyte *)fullname.c_str()); + if (glx_get_proc_address) { + if (!_checked_get_proc_address) { + // First, check if we have glxGetProcAddress available. This will + // be superior if we can get it. + const char *funcName = NULL; + + if (glx_is_at_least_version(1, 4)) { + funcName = "glXGetProcAddress"; + + } else if (has_extension("GLX_ARB_get_proc_address")) { + funcName = "glXGetProcAddressARB"; + } + + if (funcName != NULL) { + _glxGetProcAddress = (PFNGLXGETPROCADDRESSPROC)get_system_func(funcName); + if (_glxGetProcAddress == NULL) { + glxdisplay_cat.warning() + << "Couldn't load function " << funcName + << ", GL extensions may be unavailable.\n"; + } + } + + _checked_get_proc_address = true; + } + + // Use glxGetProcAddress() if we've got it; it should be more robust. + if (_glxGetProcAddress != NULL) { + return (void *)_glxGetProcAddress((const GLubyte *)fullname.c_str()); + } } - // Otherwise, fall back to the OS-provided calls. - return get_system_func(fullname.c_str()); + if (glx_get_os_address) { + // Otherwise, fall back to the OS-provided calls. + return get_system_func(fullname.c_str()); + } + + return NULL; } ////////////////////////////////////////////////////////////////////