diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/renderer.cpp | 19 | ||||
-rw-r--r-- | 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) | |||
11 | set(SDL2IMAGEDIR "${Ether_SOURCE_DIR}/vendor/SDL2_Image") | 11 | set(SDL2IMAGEDIR "${Ether_SOURCE_DIR}/vendor/SDL2_Image") |
12 | set(SDL2_TTF_PATH "${Ether_SOURCE_DIR}/vendor/SDL2_ttf") | 12 | set(SDL2_TTF_PATH "${Ether_SOURCE_DIR}/vendor/SDL2_ttf") |
13 | set(APP_ICON_RESOURCE_WINDOWS "${Ether_SOURCE_DIR}/res/appicon.rc") | 13 | set(APP_ICON_RESOURCE_WINDOWS "${Ether_SOURCE_DIR}/res/appicon.rc") |
14 | add_compile_definitions(MSVC) | ||
14 | ENDIF(MSVC) | 15 | ENDIF(MSVC) |
15 | 16 | ||
16 | find_package(SDL2 REQUIRED) | 17 | 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() | |||
33 | throw sdl_error(); | 33 | throw sdl_error(); |
34 | } | 34 | } |
35 | 35 | ||
36 | loadAllTextures(); | ||
37 | |||
38 | font_ = font_ptr(TTF_OpenFont(Runtime::getResourcePath("softsquare.ttf").c_str(), 45)); | ||
39 | if (!font_) { | ||
40 | throw ttf_error(); | ||
41 | } | ||
42 | } | ||
43 | |||
44 | void Renderer::loadAllTextures() { | ||
36 | texture_ptr origFade; | 45 | texture_ptr origFade; |
37 | loadTextureFromFile("lighting.png", origFade); | 46 | loadTextureFromFile("lighting.png", origFade); |
38 | 47 | ||
@@ -120,11 +129,6 @@ Renderer::Renderer() | |||
120 | 129 | ||
121 | loadTextureFromFile("title3.png", titles_[2]); | 130 | loadTextureFromFile("title3.png", titles_[2]); |
122 | SDL_QueryTexture(titles_[2].get(), nullptr, nullptr, &titleWidths_[2], &titleHeights_[2]); | 131 | SDL_QueryTexture(titles_[2].get(), nullptr, nullptr, &titleWidths_[2], &titleHeights_[2]); |
123 | |||
124 | font_ = font_ptr(TTF_OpenFont(Runtime::getResourcePath("softsquare.ttf").c_str(), 45)); | ||
125 | if (!font_) { | ||
126 | throw ttf_error(); | ||
127 | } | ||
128 | } | 132 | } |
129 | 133 | ||
130 | void Renderer::renderGame( | 134 | void Renderer::renderGame( |
@@ -689,4 +693,9 @@ void Renderer::toggleFullscreen() { | |||
689 | } else { | 693 | } else { |
690 | SDL_SetWindowFullscreen(win_.get(), 0); | 694 | SDL_SetWindowFullscreen(win_.get(), 0); |
691 | } | 695 | } |
696 | |||
697 | #ifdef MSVC | ||
698 | loadAllTextures(); | ||
699 | menu_.reset(); | ||
700 | #endif | ||
692 | } | 701 | } |
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: | |||
170 | private: | 170 | private: |
171 | 171 | ||
172 | void loadTextureFromFile(std::string_view path, texture_ptr& texture); | 172 | void loadTextureFromFile(std::string_view path, texture_ptr& texture); |
173 | void loadAllTextures(); | ||
173 | 174 | ||
174 | sdl_wrapper sdl_; | 175 | sdl_wrapper sdl_; |
175 | img_wrapper img_; | 176 | img_wrapper img_; |