aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SDLContext.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-08 17:31:25 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-08 17:31:25 +0100
commit91a277c69fd5f8ba814adc1006a49c7415ff65be (patch)
tree5545e9a9374e017a45ea56a81c2b7e24091cbcc2 /src/crepe/facade/SDLContext.cpp
parentcb6aae1751a95a29bc04d805d9cc9135b5c54c1e (diff)
updated to satisfy the code review
Diffstat (limited to 'src/crepe/facade/SDLContext.cpp')
-rw-r--r--src/crepe/facade/SDLContext.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index 9a2d15a..cedb7b8 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -7,6 +7,7 @@
#include <cmath>
#include <cstddef>
#include <iostream>
+#include <string>
#include "../api/Sprite.h"
#include "../api/Texture.h"
@@ -98,13 +99,15 @@ void SDLContext::handle_events(bool & running) {
*/
}
-void SDLContext::clear_screen() const { SDL_RenderClear(this->game_renderer); }
-void SDLContext::present_screen() const { SDL_RenderPresent(this->game_renderer); }
+void SDLContext::clear_screen() { SDL_RenderClear(this->game_renderer); }
+void SDLContext::present_screen() {
+ SDL_RenderPresent(this->game_renderer);
+}
void SDLContext::draw(const Sprite & sprite, const Transform & transform,
- const Camera & cam) const {
+ const Camera & cam) {
- static SDL_RendererFlip render_flip
+ SDL_RendererFlip render_flip
= (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * sprite.flip.flip_x)
| (SDL_FLIP_VERTICAL * sprite.flip.flip_y));
@@ -147,10 +150,10 @@ void SDLContext::camera(const Camera & cam) {
const uint64_t SDLContext::get_ticks() const { return SDL_GetTicks64(); }
-SDL_Texture * SDLContext::texture_from_path(const char * path) const {
- dbg_trace();
+//TODO: make this RAII
+SDL_Texture * SDLContext::texture_from_path(const std::string & path) {
- SDL_Surface * tmp = IMG_Load(path);
+ SDL_Surface * tmp = IMG_Load(path.c_str());
if (!tmp) {
std::cerr << "Error surface " << IMG_GetError << std::endl;
}