From 53a151511e463ee3b0671fd12bc20fc98b840d21 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sat, 18 Jan 2025 03:18:44 -0500 Subject: [PATCH] Make it so that DNEBUG is forced on release build, and that the UI stats counter will show that this is a debug build or not via NDEBUG. --- Makefile | 2 +- constants.hpp | 6 ++++++ main.cpp | 4 ++-- raycaster.cpp | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e8fc1c7..6542778 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ build: meson compile -j 10 -C builddir release_build: - meson --wipe builddir --buildtype release + meson --wipe builddir -Dcpp_args=-DNDEBUG=1 --buildtype release meson compile -j 10 -C builddir debug_build: diff --git a/constants.hpp b/constants.hpp index 3ad692f..68d535a 100644 --- a/constants.hpp +++ b/constants.hpp @@ -6,3 +6,9 @@ constexpr const int RAY_VIEW_X=(1280 - RAY_VIEW_WIDTH); constexpr const int RAY_VIEW_Y=0; constexpr const int SCREEN_HEIGHT=720; constexpr const int SCREEN_WIDTH=1280; +constexpr const bool VSYNC=false; +#ifdef NDEBUG +constexpr const bool DEBUG_BUILD=false; +#else +constexpr const bool DEBUG_BUILD=true; +#endif diff --git a/main.cpp b/main.cpp index 7e622f6..17d82f3 100644 --- a/main.cpp +++ b/main.cpp @@ -26,8 +26,8 @@ void draw_gui(sf::RenderWindow &window, sf::Text &text, Stats &stats) { window.draw(rect); text.setString( - fmt::format("FPS\nmean:{:>8.5}\nsdev: {:>8.5}\nmin: {:>8.5}\nmax: {:>8.5}\ncount:{:<10}\n\nHit R to reset.", - stats.mean(), stats.stddev(), stats.min, stats.max, stats.n)); + fmt::format("FPS\nmean:{:>8.5}\nsdev: {:>8.5}\nmin: {:>8.5}\nmax: {:>8.5}\ncount:{:<10}\n\nVSync? {}\nDebug? {}\n\nHit R to reset.", + stats.mean(), stats.stddev(), stats.min, stats.max, stats.n, VSYNC, DEBUG_BUILD)); window.draw(text); } diff --git a/raycaster.cpp b/raycaster.cpp index f888a75..a1034a1 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -1,6 +1,7 @@ #include "raycaster.hpp" #include "texture.hpp" #include +#include "constants.hpp" using namespace fmt; using std::make_unique; @@ -37,7 +38,7 @@ Raycaster::Raycaster(sf::RenderWindow& window, Matrix &map, int width, int heigh spriteDistance($textures.NUM_SPRITES), ZBuffer(width) { - // $window.setVerticalSyncEnabled(true); + $window.setVerticalSyncEnabled(VSYNC); $view_sprite.setPosition({0, 0}); $pixels = make_unique($width * $height); $textures.load_textures();