From 004b9b714da7f5b9296c8d3d00cff1419a8bb8b8 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Sun, 14 Nov 2021 12:03:12 +0100 Subject: [PATCH] refactor: changed defines to constexpr --- src/window/Display.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/window/Display.cpp b/src/window/Display.cpp index c638f9a..7b97fda 100644 --- a/src/window/Display.cpp +++ b/src/window/Display.cpp @@ -16,10 +16,6 @@ #include "render/WorldRenderer.h" #include "../render/gui/imgui/imgui_impl_sdl.h" -#define WINDOW_NAME "Tower Defense" -#define WINDOW_WIDTH 800 -#define WINDOW_HEIGHT 600 - #include namespace Display { @@ -27,6 +23,10 @@ namespace Display { static SDL_Window* window; static SDL_GLContext glContext; +static constexpr int WindowWidth = 800; +static constexpr int WindowHeight= 600; +static constexpr const char WindowName[] = "Tower Defense"; + std::unique_ptr renderer = std::make_unique(); std::unique_ptr towerGui; @@ -43,7 +43,7 @@ void windowResizeEvent(int width, int height) { } bool create() { - window = SDL_CreateWindow(WINDOW_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); + window = SDL_CreateWindow(WindowName, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WindowWidth, WindowHeight, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); // Prepare and create context #ifdef __ANDROID__ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); @@ -104,7 +104,7 @@ bool create() { exit(1); } towerGui = std::make_unique(window, glContext, renderer.get()); - windowResizeEvent(WINDOW_WIDTH, WINDOW_HEIGHT); + windowResizeEvent(WindowWidth, WindowHeight); return true; }