Font Testing

This commit is contained in:
2022-10-24 13:48:17 -07:00
parent 2764a2ac42
commit ab725fcdc5
14 changed files with 270 additions and 93 deletions

View File

@ -4,9 +4,13 @@
// https://opensource.org/licenses/MIT
#include "DawnPokerGame.hpp"
#include "asset/assets/TextureAsset.hpp"
using namespace Dawn;
std::shared_ptr<TrueTypeAsset> asset;
std::shared_ptr<TextureAsset> assetTexture;
DawnGame::DawnGame(DawnHost &host) :
host(host),
renderManager(*this)
@ -23,14 +27,32 @@ int32_t DawnGame::init() {
auto camera = cameraObject->addComponent<Camera>();
camera->transform.lookAt(glm::vec3(5, 5, 5), glm::vec3(0, 0, 0));
auto canvas = UICanvas::createCanvas(this->scene);
auto test = canvas->addElement<UISprite>();
test->setTransform(
UI_COMPONENT_ALIGN_START,
UI_COMPONENT_ALIGN_START,
glm::vec4(0, 0, 32, 32),
0
);
// auto canvas = UICanvas::createCanvas(this->scene);
// auto test = canvas->addElement<UISprite>();
// test->setTransform(
// UI_COMPONENT_ALIGN_START,
// UI_COMPONENT_ALIGN_START,
// glm::vec4(0, 0, 32, 32),
// 0
// );
asset = this->assetManager.load<TrueTypeAsset>("truetype_ark");
assetTexture = this->assetManager.load<TextureAsset>("texture_test");
while(!asset->loaded || !assetTexture->loaded) {
this->assetManager.update();
}
auto text = this->scene->createSceneItem();
auto meshRenderer = text->addComponent<MeshRenderer>();
auto material = text->addComponent<Material>();
meshRenderer->mesh = std::make_shared<Mesh>();
// meshRenderer->mesh->createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT);
// QuadMesh::bufferQuadMesh(*meshRenderer->mesh, glm::vec2(0, 0), glm::vec2(0, 0), glm::vec2(1, 1), glm::vec2(1, 1), 0, 0);
struct FontMeasure measure;
asset->font.buffer("Test", 16.0f, -1, *meshRenderer->mesh, &measure);
material->textureValues[material->getShader()->getParameterByName("u_Text")] = std::shared_ptr<Texture>(&asset->font.getTexture());
return DAWN_GAME_INIT_RESULT_SUCCESS;
}

View File

@ -6,4 +6,5 @@
#pragma once
#include "game/DawnGame.hpp"
#include "scene/components/Components.hpp"
#include "ui/UISprite.hpp"
#include "ui/UISprite.hpp"
#include "asset/assets/TrueTypeAsset.hpp"