From 561031b42185cff56fee8c7a59fea5654bac7bb7 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 20 Mar 2022 13:27:11 -0400 Subject: fixed fullscreen mode on windows --- CMakeLists.txt | 1 + src/renderer.cpp | 19 ++++++++++++++----- src/renderer.h | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fbf023..c4d77f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ IF(MSVC) set(SDL2IMAGEDIR "${Ether_SOURCE_DIR}/vendor/SDL2_Image") set(SDL2_TTF_PATH "${Ether_SOURCE_DIR}/vendor/SDL2_ttf") set(APP_ICON_RESOURCE_WINDOWS "${Ether_SOURCE_DIR}/res/appicon.rc") + add_compile_definitions(MSVC) ENDIF(MSVC) find_package(SDL2 REQUIRED) diff --git a/src/renderer.cpp b/src/renderer.cpp index 09bddc9..5d6ac08 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -33,6 +33,15 @@ Renderer::Renderer() throw sdl_error(); } + loadAllTextures(); + + font_ = font_ptr(TTF_OpenFont(Runtime::getResourcePath("softsquare.ttf").c_str(), 45)); + if (!font_) { + throw ttf_error(); + } +} + +void Renderer::loadAllTextures() { texture_ptr origFade; loadTextureFromFile("lighting.png", origFade); @@ -120,11 +129,6 @@ Renderer::Renderer() loadTextureFromFile("title3.png", titles_[2]); SDL_QueryTexture(titles_[2].get(), nullptr, nullptr, &titleWidths_[2], &titleHeights_[2]); - - font_ = font_ptr(TTF_OpenFont(Runtime::getResourcePath("softsquare.ttf").c_str(), 45)); - if (!font_) { - throw ttf_error(); - } } void Renderer::renderGame( @@ -689,4 +693,9 @@ void Renderer::toggleFullscreen() { } else { SDL_SetWindowFullscreen(win_.get(), 0); } + +#ifdef MSVC + loadAllTextures(); + menu_.reset(); +#endif } diff --git a/src/renderer.h b/src/renderer.h index 8a74c3c..f650736 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -170,6 +170,7 @@ public: private: void loadTextureFromFile(std::string_view path, texture_ptr& texture); + void loadAllTextures(); sdl_wrapper sdl_; img_wrapper img_; -- cgit 1.4.1