aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SDLContext.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-08 19:49:41 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-08 19:49:41 +0100
commit519cc5d16e65ff501d330c03eeb35d2d095ead29 (patch)
tree3c7c3a64c922ec248f4136d1282530a6ec6647ac /src/crepe/facade/SDLContext.cpp
parent63bcd54e0e0ea64cfef5950568b4253d5dae5c1e (diff)
made sdlcontext not a singleton anymore
Diffstat (limited to 'src/crepe/facade/SDLContext.cpp')
-rw-r--r--src/crepe/facade/SDLContext.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index 85257d6..82c8c50 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -30,7 +30,7 @@
using namespace crepe;
using namespace std;
-SDLContext::SDLContext(Mediator & mediator) : Manager(mediator){
+SDLContext::SDLContext(Mediator & mediator) : Manager(mediator) {
dbg_trace();
mediator.sdl_context = *this;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
@@ -232,7 +232,7 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const {
const Sprite::Data & data = ctx.sprite.data;
- vec2 size;
+ vec2 size = {data.size.x , data.size.y};
if (data.size.x == 0 && data.size.y != 0) {
size.x = data.size.y * ctx.sprite.aspect_ratio;
}
@@ -258,9 +258,6 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const {
}
void SDLContext::draw(const RenderContext & ctx) {
-
- if (!ctx.texture.loaded) ctx.texture.load(this->texture_from_path(ctx.sprite.source.get_path()));
-
const Sprite::Data & data = ctx.sprite.data;
SDL_RendererFlip render_flip
= (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * data.flip.flip_x)
@@ -274,11 +271,12 @@ void SDLContext::draw(const RenderContext & ctx) {
.img_scale = ctx.scale,
});
+ cout << dstrect.w << " " << dstrect.h << " " << dstrect.x << " " << dstrect.y << endl;
double angle = ctx.angle + data.angle_offset;
this->set_color_texture(ctx.texture, ctx.sprite.data.color);
- SDL_RenderCopyExF(this->game_renderer.get(), ctx.texture.texture.get(), &srcrect,
- &dstrect, angle, NULL, render_flip);
+ int error = SDL_RenderCopyExF(this->game_renderer.get(), ctx.texture.texture.get(),
+ &srcrect, &dstrect, angle, NULL, render_flip);
}
SDLContext::CameraValues SDLContext::set_camera(const Camera & cam) {