diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index ca2a34c..5b91be9 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -1,4 +1,4 @@ -#/* +/* Copyright (C) 2007, 2010 - Bit-Blot This file is part of Aquaria. @@ -55,6 +55,8 @@ extern "C" #include "../BBGE/MathFunctions.h" +#undef quad // avoid conflict with quad precision types + // Define this to 1 to check types of pointers passed to functions, // and warn if a type mismatch is detected. In this case, // the pointer is treated as NULL, to avoid crashing or undefined behavior. diff --git a/BBGE/BBGECompileConfig.h b/BBGE/BBGECompileConfig.h index d93bb99..0b7f98d 100644 --- a/BBGE/BBGECompileConfig.h +++ b/BBGE/BBGECompileConfig.h @@ -3,6 +3,7 @@ #ifndef BBGE_SKIP_CONFIG_HEADERS +#define BBGE_BUILD_OPENGL_DYNAMIC 1 #define BBGE_BUILD_FMOD_OPENAL_BRIDGE 1 #define BBGE_BUILD_ACHIEVEMENTS_INTERNAL 1 #define BBGE_BUILD_VFS 1 diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index 79d66a1..7f6e78e 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -705,6 +705,7 @@ void Core::initGraphicsLibrary(int width, int height, bool fullscreen, bool vsyn window->open(width, height, fullscreen, bpp, vsync, display, hz); window->setTitle(appName.c_str()); +#ifdef BBGE_BUILD_OPENGL_DYNAMIC // get GL symbols AFTER opening the window, otherwise we get a super old GL context on windows and nothing works if (!lookup_all_glsyms()) { @@ -713,6 +714,7 @@ void Core::initGraphicsLibrary(int width, int height, bool fullscreen, bool vsyn SDL_Quit(); exit_error(os.str()); } +#endif debugLog("GL vendor, renderer & version:"); debugLog((const char*)glGetString(GL_VENDOR)); @@ -827,7 +829,9 @@ void Core::shutdownGraphicsLibrary() delete window; window = NULL; SDL_QuitSubSystem(SDL_INIT_VIDEO); +#ifdef BBGE_BUILD_OPENGL_DYNAMIC unload_all_glsyms(); +#endif lib_graphics = false; diff --git a/BBGE/GLLoad.cpp b/BBGE/GLLoad.cpp index 7383382..942bfaa 100644 --- a/BBGE/GLLoad.cpp +++ b/BBGE/GLLoad.cpp @@ -16,6 +16,7 @@ #include +#ifdef BBGE_BUILD_OPENGL_DYNAMIC PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL; @@ -41,6 +42,7 @@ PFNGLUNIFORM2IVARBPROC glUniform2ivARB = NULL; PFNGLUNIFORM3IVARBPROC glUniform3ivARB = NULL; PFNGLUNIFORM4IVARBPROC glUniform4ivARB = NULL; +// GL_ARB_shader_objects and related PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT = NULL; PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = NULL; PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = NULL; @@ -149,7 +151,6 @@ void unload_all_glsyms() glGenerateMipmapEXT = NULL; -#if defined(BBGE_BUILD_FRAMEBUFFER) // set these back to NULL and reload them upon reinit, otherwise they // might point to a bogus address when the shared library is reloaded. glIsRenderbufferEXT = NULL; @@ -168,7 +169,6 @@ void unload_all_glsyms() glFramebufferTexture3DEXT = NULL; glFramebufferRenderbufferEXT = NULL; glGetFramebufferAttachmentParameterivEXT = NULL; -#endif glCreateProgramObjectARB = NULL; glDeleteObjectARB = NULL; @@ -191,3 +191,5 @@ void unload_all_glsyms() glUniform3ivARB = NULL; glUniform4ivARB = NULL; } + +#endif // BBGE_BUILD_OPENGL_DYNAMIC diff --git a/BBGE/Shader.cpp b/BBGE/Shader.cpp index fa1f3ab..7b8dfec 100644 --- a/BBGE/Shader.cpp +++ b/BBGE/Shader.cpp @@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "RenderBase.h" #include - bool Shader::_wasInited = false; bool Shader::_useShaders = false; @@ -36,46 +35,24 @@ void Shader::staticInit() _wasInited = true; debugLog("Initializing shaders..."); - /*char *ext = (char*)glGetString( GL_EXTENSIONS ); + bool use = true; - if( strstr( ext, "GL_ARB_shading_language_100" ) == NULL ) +#ifdef BBGE_BUILD_OPENGL_DYNAMIC + if( !glCreateProgramObjectARB || !glDeleteObjectARB || !glUseProgramObjectARB || + !glCreateShaderObjectARB || !glCreateShaderObjectARB || !glCompileShaderARB || + !glGetObjectParameterivARB || !glAttachObjectARB || !glGetInfoLogARB || + !glLinkProgramARB || !glGetUniformLocationARB || !glGetActiveUniformARB || + !glUniform1fvARB || !glUniform2fvARB || !glUniform3fvARB || !glUniform4fvARB || + !glUniform1ivARB || !glUniform2ivARB || !glUniform3ivARB || !glUniform4ivARB) { - //This extension string indicates that the OpenGL Shading Language, - // version 1.00, is supported. - debugLog("GL_ARB_shading_language_100 extension was not found"); - - goto end; + glCreateProgramObjectARB = 0; + debugLog("One or more GL_ARB_shader_objects functions were not found"); + use = false; } +#endif - if( strstr( ext, "GL_ARB_shader_objects" ) == NULL ) - { - debugLog("GL_ARB_shader_objects extension was not found"); - goto end; - } - else*/ - // Better to just check if the function pointers are there; - // the driver might truncate the extension string or something. -- fg - { - if( !glCreateProgramObjectARB || !glDeleteObjectARB || !glUseProgramObjectARB || - !glCreateShaderObjectARB || !glCreateShaderObjectARB || !glCompileShaderARB || - !glGetObjectParameterivARB || !glAttachObjectARB || !glGetInfoLogARB || - !glLinkProgramARB || !glGetUniformLocationARB || !glGetActiveUniformARB || - !glUniform1fvARB || !glUniform2fvARB || !glUniform3fvARB || !glUniform4fvARB || - !glUniform1ivARB || !glUniform2ivARB || !glUniform3ivARB || !glUniform4ivARB) - { - glCreateProgramObjectARB = 0; - debugLog("One or more GL_ARB_shader_objects functions were not found"); - goto end; - } - } - - // everything fine when we are here - _useShaders = true; - - - end: - - if (_useShaders) + _useShaders = use; + if (use) debugLog("Shader support enabled."); else debugLog("Shader support not enabled."); diff --git a/CMakeLists.txt b/CMakeLists.txt index 0be81c2..daeb4a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -313,6 +313,7 @@ endif(NOT(AQUARIA_EXTRA_DATA_DIR STREQUAL "")) # Aquaria/BBGE specific defines... ADD_DEFINITIONS(-DBBGE_SKIP_CONFIG_HEADERS=1) # if this is not defined, it will use .h files to set the necessary defines +ADD_DEFINITIONS(-DBBGE_BUILD_OPENGL_DYNAMIC=1) ADD_DEFINITIONS(-DBBGE_BUILD_FMOD_OPENAL_BRIDGE=1) IF(AQUARIA_USE_VFS) ADD_DEFINITIONS(-DBBGE_BUILD_VFS=1)