add glx-get-proc-address, glx-os-proc-address

This commit is contained in:
David Rose 2006-03-27 16:32:51 +00:00
parent 59f32111b3
commit 87d34eaed1
3 changed files with 52 additions and 29 deletions

View File

@ -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

View File

@ -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__ */

View File

@ -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;
}
////////////////////////////////////////////////////////////////////