From 7456e785fa8ef5504fded779d124f510eabbbcb2 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sun, 5 Feb 2017 22:51:25 +0100 Subject: [PATCH] Remove mandatory defines and their checks: BBGE_BUILD_SHADERS BBGE_BUILD_FRAMEBUFFER BBGE_BUILD_OPENGL BBGE_BUILD_OPENGL_DYNAMIC --- BBGE/BBGECompileConfig.h | 4 ---- BBGE/Core.cpp | 4 ---- BBGE/FrameBuffer.cpp | 23 ----------------------- BBGE/GLLoad.cpp | 24 ++++-------------------- BBGE/RenderBase.h | 4 ---- BBGE/Shader.cpp | 19 ------------------- CMakeLists.txt | 3 --- ExternalLibs/glfont2/glfont2.cpp | 4 ---- 8 files changed, 4 insertions(+), 81 deletions(-) diff --git a/BBGE/BBGECompileConfig.h b/BBGE/BBGECompileConfig.h index f4419bd..d93bb99 100644 --- a/BBGE/BBGECompileConfig.h +++ b/BBGE/BBGECompileConfig.h @@ -3,10 +3,6 @@ #ifndef BBGE_SKIP_CONFIG_HEADERS -#define BBGE_BUILD_FRAMEBUFFER 1 -#define BBGE_BUILD_SHADERS 1 -#define BBGE_BUILD_OPENGL 1 -#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 f208d54..ffa9dcd 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -881,7 +881,6 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, bool vsyn createWindow(width, height, !width && !height, fullscreen); -#if BBGE_BUILD_OPENGL_DYNAMIC if (SDL_GL_LoadLibrary(NULL) == -1) { std::string err = std::string("SDL_GL_LoadLibrary Error: ") + std::string(SDL_GetError()); @@ -896,7 +895,6 @@ bool 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)); @@ -1070,9 +1068,7 @@ void Core::shutdownGraphicsLibrary() #endif SDL_QuitSubSystem(SDL_INIT_VIDEO); gScreen = 0; -#if BBGE_BUILD_OPENGL_DYNAMIC unload_all_glsyms(); -#endif _hasFocus = false; diff --git a/BBGE/FrameBuffer.cpp b/BBGE/FrameBuffer.cpp index a4073f2..a55165e 100644 --- a/BBGE/FrameBuffer.cpp +++ b/BBGE/FrameBuffer.cpp @@ -58,8 +58,6 @@ float FrameBuffer::getHeightP() bool FrameBuffer::init(int width, int height, bool fitToScreen) { -#ifdef BBGE_BUILD_FRAMEBUFFER - _w = width; _h = height; @@ -157,9 +155,6 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen) debugLog("Done"); inited = true; return true; -#endif - - return false; } void FrameBuffer::unloadDevice() @@ -167,10 +162,6 @@ void FrameBuffer::unloadDevice() debugLog("frameBuffer::unloadDevice"); inited = false; -#ifdef BBGE_BUILD_FRAMEBUFFER - - - if (glDeleteFramebuffersEXT == NULL) { debugLog("Already shut down the GL, don't delete framebuffers"); @@ -204,7 +195,6 @@ void FrameBuffer::unloadDevice() g_depthRenderBuffer = 0; } -#endif debugLog("done"); } @@ -217,32 +207,19 @@ void FrameBuffer::reloadDevice() void FrameBuffer::startCapture() { assert(inited); -#ifdef BBGE_BUILD_FRAMEBUFFER - glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, g_frameBuffer ); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - -#endif } void FrameBuffer::endCapture() { assert(inited); -#ifdef BBGE_BUILD_FRAMEBUFFER - glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); - -#endif } void FrameBuffer::bindTexture() { assert(inited); -#ifdef BBGE_BUILD_FRAMEBUFFER - glBindTexture( GL_TEXTURE_2D, g_dynamicTextureID ); - -#endif } diff --git a/BBGE/GLLoad.cpp b/BBGE/GLLoad.cpp index a87e666..b670986 100644 --- a/BBGE/GLLoad.cpp +++ b/BBGE/GLLoad.cpp @@ -1,7 +1,5 @@ #include "Base.h" -#if BBGE_BUILD_OPENGL_DYNAMIC - #include "RenderBase.h" #include "GLLoad.h" #include @@ -21,7 +19,6 @@ PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL; -#ifdef BBGE_BUILD_SHADERS // GL_ARB_shader_objects PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = NULL; PFNGLDELETEOBJECTARBPROC glDeleteObjectARB = NULL; @@ -43,9 +40,7 @@ PFNGLUNIFORM1IVARBPROC glUniform1ivARB = NULL; PFNGLUNIFORM2IVARBPROC glUniform2ivARB = NULL; PFNGLUNIFORM3IVARBPROC glUniform3ivARB = NULL; PFNGLUNIFORM4IVARBPROC glUniform4ivARB = NULL; -#endif -#ifdef BBGE_BUILD_FRAMEBUFFER PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT = NULL; PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = NULL; PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = NULL; @@ -62,13 +57,10 @@ PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT = NULL; PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT = NULL; PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT = NULL; PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT = NULL; -#endif - unsigned g_dbg_numRenderCalls = 0; // extern -#ifdef BBGE_BUILD_OPENGL_DYNAMIC #define GL_FUNC(ret,fn,params,call,rt) \ extern "C" { \ static ret (GLAPIENTRY *p##fn) params = NULL; \ @@ -99,9 +91,11 @@ bool lookup_all_glsyms() #undef GL_FUNC // optional functions + + // mipmaps glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)SDL_GL_GetProcAddress("glGenerateMipmapEXT"); -#if defined(BBGE_BUILD_FRAMEBUFFER) + // framebuffer glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)SDL_GL_GetProcAddress("glIsRenderbufferEXT"); glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)SDL_GL_GetProcAddress("glBindRenderbufferEXT"); glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)SDL_GL_GetProcAddress("glDeleteRenderbuffersEXT"); @@ -118,9 +112,8 @@ bool lookup_all_glsyms() glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)SDL_GL_GetProcAddress("glFramebufferTexture3DEXT"); glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)SDL_GL_GetProcAddress("glFramebufferRenderbufferEXT"); glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameterivEXT"); -#endif -#if defined(BBGE_BUILD_SHADERS) + // shaders glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glCreateProgramObjectARB"); glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)SDL_GL_GetProcAddress("glDeleteObjectARB"); glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glUseProgramObjectARB"); @@ -141,22 +134,18 @@ bool lookup_all_glsyms() glUniform2ivARB = (PFNGLUNIFORM2IVARBPROC)SDL_GL_GetProcAddress("glUniform2ivARB"); glUniform3ivARB = (PFNGLUNIFORM3IVARBPROC)SDL_GL_GetProcAddress("glUniform3ivARB"); glUniform4ivARB = (PFNGLUNIFORM4IVARBPROC)SDL_GL_GetProcAddress("glUniform4ivARB"); -#endif return retval; } -#endif void unload_all_glsyms() { -#if BBGE_BUILD_OPENGL_DYNAMIC // reset all the entry points to NULL, so we know exactly what happened // if we call a GL function after shutdown. #define GL_FUNC(ret,fn,params,call,rt) \ p##fn = NULL; #include "OpenGLStubs.h" #undef GL_FUNC -#endif glGenerateMipmapEXT = NULL; @@ -181,7 +170,6 @@ void unload_all_glsyms() glGetFramebufferAttachmentParameterivEXT = NULL; #endif -#if defined(BBGE_BUILD_SHADERS) glCreateProgramObjectARB = NULL; glDeleteObjectARB = NULL; glUseProgramObjectARB = NULL; @@ -202,8 +190,4 @@ void unload_all_glsyms() glUniform2ivARB = NULL; glUniform3ivARB = NULL; glUniform4ivARB = NULL; -#endif - } - -#endif diff --git a/BBGE/RenderBase.h b/BBGE/RenderBase.h index 2119b4d..4ea09be 100644 --- a/BBGE/RenderBase.h +++ b/BBGE/RenderBase.h @@ -26,7 +26,6 @@ extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT; -#ifdef BBGE_BUILD_SHADERS // GL_ARB_shader_objects extern PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB; extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; @@ -48,9 +47,7 @@ extern PFNGLUNIFORM1IVARBPROC glUniform1ivARB; extern PFNGLUNIFORM2IVARBPROC glUniform2ivARB; extern PFNGLUNIFORM3IVARBPROC glUniform3ivARB; extern PFNGLUNIFORM4IVARBPROC glUniform4ivARB; -#endif -#ifdef BBGE_BUILD_FRAMEBUFFER extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT; extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT; extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT; @@ -67,7 +64,6 @@ extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT; extern PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT; extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT; extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT; -#endif diff --git a/BBGE/Shader.cpp b/BBGE/Shader.cpp index dccf685..fa1f3ab 100644 --- a/BBGE/Shader.cpp +++ b/BBGE/Shader.cpp @@ -36,7 +36,6 @@ void Shader::staticInit() _wasInited = true; debugLog("Initializing shaders..."); -#if defined(BBGE_BUILD_SHADERS) && defined(BBGE_BUILD_OPENGL) /*char *ext = (char*)glGetString( GL_EXTENSIONS ); if( strstr( ext, "GL_ARB_shading_language_100" ) == NULL ) @@ -75,7 +74,6 @@ void Shader::staticInit() end: -#endif if (_useShaders) debugLog("Shader support enabled."); @@ -98,7 +96,6 @@ Shader::~Shader() void Shader::unload() { -#ifdef BBGE_BUILD_SHADERS if (!_useShaders) return; if (g_programObj) @@ -106,7 +103,6 @@ void Shader::unload() glDeleteObjectARB( g_programObj ); g_programObj = 0; } -#endif } bool Shader::isLoaded() const @@ -124,26 +120,21 @@ void Shader::reload() void Shader::bind() { -#ifdef BBGE_BUILD_SHADERS if (!_useShaders) return; glUseProgramObjectARB(g_programObj); _flushUniforms(); -#endif } void Shader::unbind() { -#ifdef BBGE_BUILD_SHADERS if (!_useShaders) return; glUseProgramObjectARB(0); -#endif } unsigned int Shader::_compileShader(int type, const char *src, char *errbuf, size_t errbufsize) { -#ifdef BBGE_BUILD_SHADERS GLint compiled = 0; GLhandleARB handle = glCreateShaderObjectARB(type); if(!handle) @@ -172,8 +163,6 @@ unsigned int Shader::_compileShader(int type, const char *src, char *errbuf, siz errorLog(os.str()); } return handle; -#endif - return 0; } void Shader::load(const std::string &file, const std::string &fragFile) @@ -204,8 +193,6 @@ void Shader::loadSrc(const char *vertCode, const char *fragCode) if(!_useShaders) return; -#ifdef BBGE_BUILD_SHADERS - char str[4096]; GLhandleARB vertexShader = 0; @@ -280,8 +267,6 @@ void Shader::loadSrc(const char *vertCode, const char *fragCode) fragSrc = fragCode ? fragCode : ""; _queryUniforms(); - -#endif } void Shader::_setUniform(Uniform *u) @@ -384,7 +369,6 @@ int Shader::_getUniformIndex(const char *name) void Shader::setInt(const char *name, int x, int y /* = 0 */, int z /* = 0 */, int w /* = 0 */) { -#if BBGE_BUILD_SHADERS if(!g_programObj || numUniforms == 0 || numUniforms == -1) return; int idx = _getUniformIndex(name); @@ -397,12 +381,10 @@ void Shader::setInt(const char *name, int x, int y /* = 0 */, int z /* = 0 */, i u.data.i.i[3] = w; u.dirty = true; uniformsDirty = true; -#endif } void Shader::setFloat(const char *name, float x, float y /* = 0 */, float z /* = 0 */, float w /* = 0 */) { -#if BBGE_BUILD_SHADERS if(!g_programObj || numUniforms == 0 || numUniforms == -1) return; int idx = _getUniformIndex(name); @@ -415,5 +397,4 @@ void Shader::setFloat(const char *name, float x, float y /* = 0 */, float z /* = u.data.f.f[3] = w; u.dirty = true; uniformsDirty = true; -#endif } diff --git a/CMakeLists.txt b/CMakeLists.txt index b3261fd..8134d3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,9 +300,6 @@ 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_FRAMEBUFFER=1) -ADD_DEFINITIONS(-DBBGE_BUILD_SHADERS=1) -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) diff --git a/ExternalLibs/glfont2/glfont2.cpp b/ExternalLibs/glfont2/glfont2.cpp index 93cd491..b878afb 100644 --- a/ExternalLibs/glfont2/glfont2.cpp +++ b/ExternalLibs/glfont2/glfont2.cpp @@ -105,7 +105,6 @@ bool GLFont::Create (const char *file_name, int tex, bool loadTexture) if (loadTexture) { -#ifdef BBGE_BUILD_OPENGL glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); @@ -128,7 +127,6 @@ bool GLFont::Create (const char *file_name, int tex, bool loadTexture) //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); */ -#endif } //Free texture pixels memory @@ -253,10 +251,8 @@ int GLFont::GetCharHeight (unsigned char c) //******************************************************************* void GLFont::Begin (void) { -#ifdef BBGE_BUILD_OPENGL //Bind to font texture glBindTexture(GL_TEXTURE_2D, header.tex); -#endif } //******************************************************************* void GLFont::GetStringSize (const std::string &text, std::pair *size)