From 64fce596ce61574ee57bea97966c783dd87e740b Mon Sep 17 00:00:00 2001 From: Gregor Klevze Date: Fri, 19 Dec 2025 18:22:26 +0100 Subject: [PATCH] fillRect moved --- src/graphics/renderers/RenderPrimitives.h | 16 ++++++++++++++++ src/main.cpp | 17 ++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 src/graphics/renderers/RenderPrimitives.h diff --git a/src/graphics/renderers/RenderPrimitives.h b/src/graphics/renderers/RenderPrimitives.h new file mode 100644 index 0000000..5836ce2 --- /dev/null +++ b/src/graphics/renderers/RenderPrimitives.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace RenderPrimitives { + +inline void fillRect(SDL_Renderer* renderer, float x, float y, float w, float h, SDL_Color color) { + if (!renderer) { + return; + } + SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a); + SDL_FRect rect{x, y, w, h}; + SDL_RenderFillRect(renderer, &rect); +} + +} // namespace RenderPrimitives diff --git a/src/main.cpp b/src/main.cpp index 4651f3d..7a3a0cc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,6 +42,7 @@ #include "states/LoadingManager.h" #include "utils/ImagePathResolver.h" #include "graphics/renderers/GameRenderer.h" +#include "graphics/renderers/RenderPrimitives.h" #include "core/Config.h" #include "core/Settings.h" #include "ui/MenuLayout.h" @@ -64,12 +65,6 @@ static constexpr int WELL_H = Game::ROWS * Game::TILE; // Bit 0 = (x=0,y=0), Bit 1 = (1,0) ... Bit 15 = (3,3) // Shapes & game logic now in Game.cpp -// (removed inline shapes) - -// Piece struct now in Game.h - -// Game struct replaced by Game class - static const std::array COLORS = {{ SDL_Color{20, 20, 26, 255}, // 0 empty SDL_Color{0, 255, 255, 255}, // I @@ -90,13 +85,6 @@ static std::atomic g_loadedTasks{0}; static std::string g_currentLoadingFile; static std::mutex g_currentLoadingMutex; -static void drawRect(SDL_Renderer *r, float x, float y, float w, float h, SDL_Color c) -{ - SDL_SetRenderDrawColor(r, c.r, c.g, c.b, c.a); - SDL_FRect fr{x, y, w, h}; - SDL_RenderFillRect(r, &fr); -} - // Hover state for level popup ( -1 = none, 0..19 = hovered level ) // Now managed by LevelSelectorState @@ -129,7 +117,6 @@ static bool isNewHighScore = false; static std::string playerName = ""; static bool helpOverlayPausedGame = false; -// Fireworks implementation moved to app/Fireworks.{h,cpp} int main(int, char **) { @@ -1327,7 +1314,7 @@ int main(int, char **) float contentOffsetY = (winH - contentH) * 0.5f / contentScale; auto drawRect = [&](float x, float y, float w, float h, SDL_Color c) - { SDL_SetRenderDrawColor(renderer,c.r,c.g,c.b,c.a); SDL_FRect fr{x + contentOffsetX, y + contentOffsetY, w, h}; SDL_RenderFillRect(renderer,&fr); }; + { RenderPrimitives::fillRect(renderer, x + contentOffsetX, y + contentOffsetY, w, h, c); }; // Calculate dimensions for perfect centering (like JavaScript version) const bool isLimitedHeight = LOGICAL_H < 450;