From a26fa5153b7a16d6026050250bddb52fa0577361 Mon Sep 17 00:00:00 2001 From: bailwillharr Date: Tue, 1 Aug 2023 16:32:47 +0100 Subject: [PATCH] add text to demo --- include/scene.h | 2 +- test/src/game.cpp | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/scene.h b/include/scene.h index 5552e04..2855b28 100644 --- a/include/scene.h +++ b/include/scene.h @@ -31,7 +31,7 @@ class Scene { /* ecs stuff */ - uint32_t CreateEntity(const std::string& tag, uint32_t parent = 0, const glm::vec3& pos = {}); + uint32_t CreateEntity(const std::string& tag, uint32_t parent = 0, const glm::vec3& pos = glm::vec3{0.0f, 0.0f, 0.0f}); uint32_t GetEntity(const std::string& tag, uint32_t parent = 0); diff --git a/test/src/game.cpp b/test/src/game.cpp index 04212b5..918b610 100644 --- a/test/src/game.cpp +++ b/test/src/game.cpp @@ -125,23 +125,26 @@ void PlayGame(GameSettings settings) { my_scene, app.GetResourcePath("models/cobble_house/cobble_house.dae")); my_scene->GetComponent(cobbleHouse)->position += glm::vec3{33.0f, 0.1f, 35.0f}; - auto cobbleCustom = my_scene->AddComponent(cobbleHouse); + auto cobbleCustom = + my_scene->AddComponent(cobbleHouse); cobbleCustom->onInit = [](void) { LOG_INFO("Cobble house spin component initialised!"); }; cobbleCustom->onUpdate = [&](float ts) { - static auto t = my_scene->GetComponent(cobbleHouse); + static auto t = + my_scene->GetComponent(cobbleHouse); t->rotation *= glm::angleAxis(ts, glm::vec3{0.0f, 0.0f, 1.0f}); }; /* some text */ { int width, height; - auto bitmap = app.GetResource("builtin.mono") - ->GetTextBitmap("ABCDEFGHIJKLMNOPQRSTUVWXYZ12345", - 1080.0f, width, height); + auto bitmap = + app.GetResource("builtin.mono") + ->GetTextBitmap("Welcome 2 my gaem", 128.0f, width, height); - uint32_t textbox = my_scene->CreateEntity("textbox"); + uint32_t textbox = + my_scene->CreateEntity("textbox", 0, glm::vec3{0.0f, 0.8f, 0.0f}); auto textbox_renderable = my_scene->AddComponent(textbox); textbox_renderable->material = @@ -152,8 +155,11 @@ void PlayGame(GameSettings settings) { &app.render_data_, bitmap->data(), width, height, engine::resources::Texture::Filtering::kAnisotropic); textbox_renderable->mesh = GenSphereMesh(app.gfxdev(), 1.0f, 5); - my_scene->GetComponent(textbox)->scale.y = - (float)height / (float)width; + auto textTransform = + my_scene->GetComponent(textbox); + textTransform->scale.y = + (static_cast(height) / static_cast(width)); + textTransform->scale *= 0.5f; textbox_renderable->shown = true; auto textboxComponent =