69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
|
|
// Copyright (c) 2023 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#include "scene/SceneList.hpp"
|
|
#include "component/display/Camera.hpp"
|
|
#include "prefab/SimpleSpinningCube.hpp"
|
|
#include "display/font/TrueTypeTexture.hpp"
|
|
#include "component/display/material/SimpleTexturedMaterial.hpp"
|
|
#include "display/mesh/QuadMesh.hpp"
|
|
|
|
#include "component/ui/UICanvas.hpp"
|
|
#include "ui/UIRectangle.hpp"
|
|
#include "ui/UILabel.hpp"
|
|
|
|
#include <ft2build.h>
|
|
#include FT_FREETYPE_H
|
|
|
|
using namespace Dawn;
|
|
|
|
std::shared_ptr<TrueTypeTexture> texture;
|
|
|
|
void Dawn::helloWorldScene(Scene &s) {
|
|
std::string font = "ysabeau_medium";
|
|
texture = s.getGame()->assetManager.get<TrueTypeTexture>(font, 24);
|
|
|
|
while(!s.getGame()->assetManager.isLoaded(font)) {
|
|
s.getGame()->assetManager.update();
|
|
}
|
|
|
|
auto cameraItem = s.createSceneItem();
|
|
auto camera = cameraItem->addComponent<Camera>();
|
|
cameraItem->lookAt({ 120, 0, 300 }, { 120, 0, 0 }, { 0, 1, 0 });
|
|
camera->clipFar = 99999.99f;
|
|
|
|
// auto quad = s.createSceneItem();
|
|
// auto quadMesh = std::make_shared<Mesh>();
|
|
|
|
// glm::vec2 position = { 0, 0 };
|
|
// glm::vec2 size = texture->bufferStringToMesh(
|
|
// quadMesh,
|
|
// L"Hello World!",
|
|
// position,
|
|
// true
|
|
// );
|
|
|
|
// auto quadRenderer = quad->addComponent<MeshRenderer>();
|
|
// quadRenderer->mesh = quadMesh;
|
|
|
|
// auto quadMaterial = quad->addComponent<SimpleTexturedMaterial>();
|
|
// quadMaterial->setTexture(texture->texture);
|
|
|
|
auto uiCanvasItem = s.createSceneItem();
|
|
auto uiCanvas = uiCanvasItem->addComponent<UICanvas>();
|
|
|
|
auto rect = std::make_shared<UIRectangle>();
|
|
rect->position = { 32, 32 };
|
|
rect->size = { texture->texture->getWidth(), texture->texture->getHeight() };
|
|
rect->color = COLOR_MAGENTA;
|
|
rect->texture = texture->texture;
|
|
uiCanvas->components.push_back(rect);
|
|
|
|
auto label = std::make_shared<UILabel>();
|
|
label->setFont(texture);
|
|
label->position = { 32, 650 };
|
|
uiCanvas->components.push_back(label);
|
|
} |