summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/renderer.cpp19
-rw-r--r--src/renderer.h1
2 files changed, 15 insertions, 5 deletions
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
44void 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
130void Renderer::renderGame( 134void 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:
170private: 170private:
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_;