diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-18 13:38:54 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-18 13:38:54 +0100 |
commit | d8e6773be7206994716c29e1ee8195b10f094bdf (patch) | |
tree | 055b1011f35d495d66225611ca0fdf4db29bd98b /src | |
parent | 36f941aa1cdea5faeec20a0dc793e0538ccd6d15 (diff) |
added transform scale and rotation in the drawing text component
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/facade/SDLContext.cpp | 5 | ||||
-rw-r--r-- | src/example/rendering_particle.cpp | 4 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 9a122f5..f350250 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -11,7 +11,6 @@ #include <array> #include <cmath> #include <cstddef> -#include <cstdint> #include <functional> #include <memory> #include <stdexcept> @@ -221,7 +220,7 @@ void SDLContext::draw_text(const RenderText & data) { font_texture = {tmp_font_texture, [](SDL_Texture * texture) { SDL_DestroyTexture(texture); }}; - vec2 size = text.dimensions * cam_aux_data.render_scale; + vec2 size = text.dimensions * cam_aux_data.render_scale * transform.scale; vec2 screen_pos = (transform.position + text.offset - cam_aux_data.cam_pos + (cam_aux_data.zoomed_viewport) / 2) * cam_aux_data.render_scale @@ -234,7 +233,7 @@ void SDLContext::draw_text(const RenderText & data) { .h = size.y, }; - SDL_RenderCopyExF(this->game_renderer.get(), font_texture.get(), NULL, &dstrect, 0, NULL, + SDL_RenderCopyExF(this->game_renderer.get(), font_texture.get(), NULL, &dstrect, transform.rotation, NULL, SDL_FLIP_NONE); } diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index e8b3775..4430d75 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -40,11 +40,11 @@ public: .position_offset = {0, 0}, }); - auto & cam = game_object.add_component<Camera>(ivec2{1280, 720}, vec2{400, 400}, + auto & cam = game_object.add_component<Camera>(ivec2{1280, 720}, vec2{4000, 4000}, Camera::Data{ .bg_color = Color::WHITE, }); - game_object.add_component<Text>(vec2{400, 400}, vec2{0, 0}, "ComicSansMS", + game_object.add_component<Text>(vec2{4000, 400}, vec2{0, 0}, "ComicSansMS", Text::Data{.text_color = Color::RED}, "TEST test"); } |