Skip to content

Commit

Permalink
Gate OpenGL error-checking on a compilation setting rather than Debug…
Browse files Browse the repository at this point in the history
…/Release
  • Loading branch information
tophyr committed Aug 14, 2024
1 parent 16cc66d commit e455ed5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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" # -*-
Expand Down
2 changes: 1 addition & 1 deletion renderer/dyna_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e455ed5

Please sign in to comment.