(Temp) UI only renders to backbuffer

This commit is contained in:
2023-05-10 12:48:33 -07:00
parent d643d5f220
commit cdf9b0a35d
6 changed files with 80 additions and 16 deletions

View File

@ -5,9 +5,11 @@
#pragma once
#include "scene/Scene.hpp"
#include "scene/components/display/Camera.hpp"
#include "scene/components/display/CameraTexture.hpp"
#include "prefabs/SimpleSpinningCubePrefab.hpp"
#include "prefabs/VNTextbox.hpp"
#include "display/TextureRenderTarget.hpp"
#include "scene/components/ui/UIImage.hpp"
namespace Dawn {
class HelloWorldScene : public Scene {
@ -15,6 +17,7 @@ namespace Dawn {
Camera *camera;
Camera *camNew;
UICanvas *canvas;
TextureRenderTarget *renderTarget;
Texture text;
int32_t test = 0;
@ -24,17 +27,27 @@ namespace Dawn {
camera = Camera::create(this);
camera->fov = 0.436332f;
camera->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0));
camera->transform->lookAt(glm::vec3(900, 900, 900), glm::vec3(800, 800, 800));
camNew = Camera::create(this);
auto camTexture = camNew->item->addComponent<CameraTexture>();
camNew->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0));
camNew->renderTarget = nullptr;
camTexture->renderTarget.setSize(256, 256);
auto cube = SimpleSpinningCubePrefab::create(this);
auto textbox = VNTextbox::create(this);
textbox->transform.setParent(canvas->transform);
auto uiTest = this->createSceneItem();
uiTest->transform.setParent(canvas->transform);
auto image = uiTest->addComponent<UIImage>();
image->texture = camTexture->renderTarget.getTexture();
image->alignment = glm::vec4(0, 0, 50, 0);
image->alignX = UI_COMPONENT_ALIGN_START;
image->alignUnitRight = UI_COMPONENT_ALIGN_UNIT_PERCENT;
image->alignY = UI_COMPONENT_ALIGN_STRETCH;
struct Color colors[] = {
COLOR_BLUE, COLOR_MAGENTA, COLOR_WHITE,
COLOR_MAGENTA, COLOR_CORNFLOWER_BLUE, COLOR_MAGENTA,