diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7e453e45e..d48f2b506 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -72,6 +72,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 r_data.c r_debug.cpp r_debug_parser.cpp + r_debug_printer.cpp r_draw.cpp r_fps.c r_main.cpp diff --git a/src/d_main.cpp b/src/d_main.cpp index 7dee5488f..ad5276ca1 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -90,6 +90,7 @@ #include "k_dialogue.h" #include "k_bans.h" #include "k_credits.h" +#include "r_debug.hpp" #ifdef HWRENDER #include "hardware/hw_main.h" // 3D View Rendering @@ -663,6 +664,7 @@ static bool D_Display(void) { AM_Drawer(); ST_Drawer(); + srb2::r_debug::draw_frame_list(); F_TextPromptDrawer(); break; } @@ -858,6 +860,7 @@ void D_SRB2Loop(void) g_dc = {}; Z_Frame_Reset(); + srb2::r_debug::clear_frame_list(); { // Casting the return value of a function is bad practice (apparently) diff --git a/src/r_debug.hpp b/src/r_debug.hpp new file mode 100644 index 000000000..1910912c0 --- /dev/null +++ b/src/r_debug.hpp @@ -0,0 +1,24 @@ +// DR. ROBOTNIK'S RING RACERS +//----------------------------------------------------------------------------- +// Copyright (C) 2024 by James Robert Roman. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- + +#ifndef r_debug_hpp +#define r_debug_hpp + +#include "doomtype.h" + +namespace srb2::r_debug +{ + +void add_texture_to_frame_list(INT32 texnum); +void clear_frame_list(); +void draw_frame_list(); + +}; // namespace srb2::r_debug + +#endif/*r_debug_hpp*/ diff --git a/src/r_debug_printer.cpp b/src/r_debug_printer.cpp new file mode 100644 index 000000000..728bf29ee --- /dev/null +++ b/src/r_debug_printer.cpp @@ -0,0 +1,67 @@ +// DR. ROBOTNIK'S RING RACERS +//----------------------------------------------------------------------------- +// Copyright (C) 2024 by James Robert Roman. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- + +#include +#include + +#include "r_debug.hpp" +#include "v_draw.hpp" + +#include "doomdef.h" +#include "doomtype.h" +#include "r_textures.h" +#include "screen.h" + +using srb2::Draw; + +namespace +{ + +std::unordered_set frame_list; + +}; // namespace + +namespace srb2::r_debug +{ + +void add_texture_to_frame_list(INT32 texnum) +{ + if (cht_debug & DBG_RENDER) + { + frame_list.insert(texnum); + } +} + +void clear_frame_list() +{ + frame_list.clear(); +} + +void draw_frame_list() +{ + if (!(cht_debug & DBG_RENDER)) + { + return; + } + + Draw line = Draw(4, BASEVIDHEIGHT - 20) + .font(Draw::Font::kConsole) + .scale(0.5) + .flags(V_ORANGEMAP | V_SNAPTOLEFT | V_SNAPTOBOTTOM); + + line.y(-4 * static_cast(frame_list.size() - 1)).size(32, 4 * frame_list.size()).fill(31); + + for (INT32 texnum : frame_list) + { + line.text("{}", std::string_view {textures[texnum]->name, 8}); + line = line.y(-4); + } +} + +}; // namespace srb2::r_debug diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 6f0ca5224..e25b1415f 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -35,6 +35,7 @@ #include "core/memory.h" #include "core/thread_pool.h" #include "k_terrain.h" +#include "r_debug.hpp" extern "C" consvar_t cv_debugfinishline; @@ -2064,7 +2065,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) auto get_flat_tex = [](INT32 texnum) { texnum = R_GetTextureNum(texnum); - return textures[texnum]->holes ? 0 : texnum; // R_DrawWallColumn cannot render holey textures + if (textures[texnum]->holes) + { + srb2::r_debug::add_texture_to_frame_list(texnum); + return 0; // R_DrawWallColumn cannot render holey textures + } + return texnum; }; if (!backsector)