aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-11 14:36:44 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-11 14:36:44 +0100
commit2bcd6ece912ab0a140f9d925718e8787879d1ed7 (patch)
treeea13906ba7afcd519579639b3b2d620628151fe1 /src/crepe/facade
parente6a5bb579d0969245f34119ef2489f47039c523e (diff)
adjusted aspect ratio
Diffstat (limited to 'src/crepe/facade')
-rw-r--r--src/crepe/facade/SDLContext.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index a0d7f04..0566ecf 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -233,12 +233,14 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const {
const Sprite::Data & data = ctx.sprite.data;
+ float aspect_ratio = (ctx.sprite.aspect_ratio == 0) ? ctx.texture.get_ratio() : ctx.sprite.aspect_ratio;
+
vec2 size = data.size;
if (data.size.x == 0 && data.size.y != 0) {
- size.x = data.size.y * ctx.texture.get_ratio();
+ size.x = data.size.y * aspect_ratio;
}
if (data.size.y == 0 && data.size.x != 0) {
- size.y = data.size.x / ctx.texture.get_ratio();
+ size.y = data.size.x / aspect_ratio;
}
const CameraValues & cam = ctx.cam;
@@ -273,7 +275,6 @@ void SDLContext::draw(const RenderContext & ctx) {
.img_scale = ctx.scale,
});
- cout << srcrect->w << " " << srcrect->h << " " << srcrect->x << " " << srcrect->y << endl;
double angle = ctx.angle + data.angle_offset;
this->set_color_texture(ctx.texture, ctx.sprite.data.color);