From e5b57f6a0aadf4f5ca597e4ffa3e557eec87b54b Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Fri, 20 Dec 2024 15:26:51 +0100 Subject: add world space to text rendering and removedlayers on text --- src/example/rendering_particle.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/example') diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index 5440fdd..0a2f946 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -7,8 +7,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -27,6 +27,7 @@ public: Color color(255, 255, 255, 255); + /* Asset img{"asset/texture/square.png"}; Sprite & test_sprite = game_object.add_component( @@ -49,6 +50,7 @@ public: .position_offset = {0, -1}, .world_space = false, }); + */ auto & cam = game_object.add_component(ivec2{1280, 720}, vec2{5, 5}, Camera::Data{ @@ -56,21 +58,25 @@ public: .postion_offset = {1000, 1000}, }); - /* - game_object.add_component(vec2{1, 1}, vec2{0, -0.5}, "ComicSansMS", - Text::Data{.text_color = Color::RED}, "test TEST"); + game_object.add_component(vec2{1, 1}, vec2{0, -1}, "ComicSansMS", + Text::Data{ + .text_color = Color::RED, + }, + "test TEST"); - game_object.add_component(vec2{1, 1}, vec2{0, 0.5}, "ComicSansMS", - Text::Data{.text_color = Color::BLACK}, "TEST test"); - */ + game_object.add_component(vec2{1, 1}, vec2{0, 1}, "Ariel", + Text::Data{ + .text_color = Color::BLACK, + }, + "TEST test").world_space = true; } string get_name() const { return "TestScene"; }; }; int main(int argc, char * argv[]) { - LoopManager engine; + Engine engine; engine.add_scene(); - engine.start(); + engine.main(); return 0; } -- cgit v1.2.3 From fd09501a1f010126bda5816f17e6e21e204e79cb Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Fri, 20 Dec 2024 15:27:15 +0100 Subject: make format --- src/example/rendering_particle.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/example') diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index 0a2f946..c8db499 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -64,11 +64,14 @@ public: }, "test TEST"); - game_object.add_component(vec2{1, 1}, vec2{0, 1}, "Ariel", - Text::Data{ - .text_color = Color::BLACK, - }, - "TEST test").world_space = true; + game_object + .add_component(vec2{1, 1}, vec2{0, 1}, "Ariel", + Text::Data{ + .text_color = Color::BLACK, + }, + "TEST test") + .world_space + = true; } string get_name() const { return "TestScene"; }; -- cgit v1.2.3 From 631975d4a03642271f80baeb4494dd01bda9c76e Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Fri, 20 Dec 2024 15:32:19 +0100 Subject: moved sdl hint to draw sprites and added another to text with 0 instead of 2 beacause otherwise its blurry --- src/crepe/facade/SDLContext.cpp | 3 ++- src/example/rendering_particle.cpp | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/example') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 9c45089..672d55a 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -68,7 +68,6 @@ SDLContext::SDLContext(Mediator & mediator) { throw runtime_error(format("SDL_ttf initialization failed: {}", TTF_GetError())); } - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2"); mediator.sdl_context = *this; } @@ -173,6 +172,7 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const { } void SDLContext::draw(const RenderContext & ctx) { + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2"); const Sprite::Data & data = ctx.sprite.data; SDL_RendererFlip render_flip = (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * data.flip.flip_x) @@ -203,6 +203,7 @@ void SDLContext::draw(const RenderContext & ctx) { } void SDLContext::draw_text(const RenderText & data) { + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); const Text & text = data.text; const Font & font = data.font; diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index c8db499..5eae00d 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -27,7 +27,6 @@ public: Color color(255, 255, 255, 255); - /* Asset img{"asset/texture/square.png"}; Sprite & test_sprite = game_object.add_component( @@ -50,7 +49,6 @@ public: .position_offset = {0, -1}, .world_space = false, }); - */ auto & cam = game_object.add_component(ivec2{1280, 720}, vec2{5, 5}, Camera::Data{ -- cgit v1.2.3 From 76f6c4d3e36b653aec79438ae4053ea24560236c Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Sun, 22 Dec 2024 13:56:17 +0100 Subject: make format --- src/crepe/system/InputSystem.cpp | 2 +- src/crepe/system/InputSystem.h | 2 +- src/example/rendering_particle.cpp | 24 ++++++++++++++---------- 3 files changed, 16 insertions(+), 12 deletions(-) (limited to 'src/example') diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp index a366d34..91c9c64 100644 --- a/src/crepe/system/InputSystem.cpp +++ b/src/crepe/system/InputSystem.cpp @@ -1,8 +1,8 @@ #include "../api/Button.h" +#include "../api/Config.h" #include "../facade/SDLContext.h" #include "../manager/ComponentManager.h" #include "../manager/EventManager.h" -#include "../api/Config.h" #include "InputSystem.h" diff --git a/src/crepe/system/InputSystem.h b/src/crepe/system/InputSystem.h index 21a3dfb..be62367 100644 --- a/src/crepe/system/InputSystem.h +++ b/src/crepe/system/InputSystem.h @@ -1,8 +1,8 @@ #pragma once -#include "../facade/EventData.h" #include "../api/Event.h" #include "../api/Metadata.h" +#include "../facade/EventData.h" #include "../types.h" #include "System.h" diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index 9093fd5..8be781a 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -62,18 +62,22 @@ public: } ); - game_object.add_component(vec2{1, 1}, vec2{0, -1}, "ComicSansMS", - Text::Data{ - .text_color = Color::RED, - }, - "test TEST"); + game_object.add_component( + vec2 {1, 1}, vec2 {0, -1}, "ComicSansMS", + Text::Data { + .text_color = Color::RED, + }, + "test TEST" + ); game_object - .add_component(vec2{1, 1}, vec2{0, 1}, "Ariel", - Text::Data{ - .text_color = Color::BLACK, - }, - "TEST test") + .add_component( + vec2 {1, 1}, vec2 {0, 1}, "Ariel", + Text::Data { + .text_color = Color::BLACK, + }, + "TEST test" + ) .world_space = true; } -- cgit v1.2.3