Gate OpenGL error-checking on a compilation setting rather than Debug/Release

This commit is contained in:
Chris Sarbora 2024-08-14 09:34:13 -05:00
parent 46043e709d
commit 8bd1b678f0
No known key found for this signature in database
2 changed files with 10 additions and 4 deletions

View File

@ -5,11 +5,12 @@ if(NOT CMAKE_BUILD_TYPE AND NOT DEFINED ENV{CMAKE_BUILD_TYPE})
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "default build type")
endif()
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with Ninja)." OFF)
option(FORCE_PORTABLE_INSTALL "Install all files into local directory defined by CMAKE_INSTALL_PREFIX" ON)
option(BUILD_TESTING "Enable testing. Requires GTest." OFF)
option(ENABLE_LOGGER "Enable logging to the terminal" OFF)
option(ENABLE_MEM_RTL "Enable Real-time library memory management functions (disable to verbose memory allocations)" ON)
option(BUILD_TESTING "Enable testing. Requires GTest." OFF)
option(FATAL_GL_ERRORS "Check OpenGL calls and raise exceptions on errors." OFF)
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with Ninja)." OFF)
option(FORCE_PORTABLE_INSTALL "Install all files into local directory defined by CMAKE_INSTALL_PREFIX" ON)
set(USE_VCPKG "DEFAULT" CACHE STRING "Use vcpkg for dependency management. DEFAULT defers to existence of $VCPKG_ROOT environment variable.")
set_property(CACHE USE_VCPKG PROPERTY STRINGS "DEFAULT" "ON" "OFF")
@ -197,6 +198,11 @@ if(ENABLE_LOGGER)
add_compile_definitions(LOGGER)
endif()
if(FATAL_GL_ERRORS)
message("Raising exceptions on OpenGL errors")
add_compile_definitions(FATAL_GL_ERRORS)
endif()
include_directories(
"cfile" # TODO: Remove after untying all modules
"ddebug" # -*-

View File

@ -39,7 +39,7 @@
#endif
inline void CheckError() {
#if defined(_DEBUG)
#if defined(FATAL_GL_ERRORS)
static auto _dglGetError = reinterpret_cast<GLenum (*)()>(SDL_GL_GetProcAddress("glGetError"));
auto err = _dglGetError();
switch (err) {