(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

@ -130,21 +130,23 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
}
// UI Elements
auto canvases = scene->findComponents<UICanvas>();
auto itCanvas = canvases.begin();
while(itCanvas != canvases.end()) {
auto canvas = *itCanvas;
glm::mat4 projection;
glm::mat4 view;
canvas->getProjectionAndView(&projection, &view);
if(renderTarget == this->renderManager->getBackBuffer()) {
auto canvases = scene->findComponents<UICanvas>();
auto itCanvas = canvases.begin();
while(itCanvas != canvases.end()) {
auto canvas = *itCanvas;
glm::mat4 projection;
glm::mat4 view;
canvas->getProjectionAndView(&projection, &view);
auto renderables = canvas->item->findChildrenDeep<UIComponentRenderable>();
auto itChild = renderables.begin();
while(itChild != renderables.end()) {
vectorAppend(&shaderPassItems,(*itChild)->getPassItems(projection, view));
++itChild;
auto renderables = canvas->item->findChildrenDeep<UIComponentRenderable>();
auto itChild = renderables.begin();
while(itChild != renderables.end()) {
vectorAppend(&shaderPassItems,(*itChild)->getPassItems(projection, view));
++itChild;
}
++itCanvas;
}
++itCanvas;
}
// Debug Lines

View File

@ -12,6 +12,7 @@ target_sources(${DAWN_TARGET_NAME}
PixelPerfectCamera.cpp
TiledSprite.cpp
SimpleRenderTargetQuad.cpp
CameraTexture.cpp
)
add_subdirectory(mesh)

View File

@ -0,0 +1,24 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "CameraTexture.hpp"
using namespace Dawn;
CameraTexture::CameraTexture(SceneItem *item) :
SceneItemComponent(item),
camera(nullptr),
renderTarget(32.0f, 32.0f)
{
}
void CameraTexture::onStart() {
if(this->camera == nullptr) this->camera = item->getComponent<Camera>();
useEffect([&]{
if(this->camera == nullptr) return;
this->camera->renderTarget = &this->renderTarget;
}, this->camera)();
}

View File

@ -0,0 +1,22 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/components/display/Camera.hpp"
#include "display/TextureRenderTarget.hpp"
namespace Dawn {
class CameraTexture : public SceneItemComponent {
protected:
public:
StateProperty<Camera*> camera;
TextureRenderTarget renderTarget;
CameraTexture(SceneItem *item);
void onStart() override;
};
}

View File

@ -37,6 +37,8 @@ void UIComponent::updateAlignment() {
auto dimensional = this->getParentDimensional();
auto translate = this->transform->getLocalPosition();
assertNotNull(dimensional);
float_t parentWidth, parentHeight;
parentWidth = dimensional->getWidth();
parentHeight = dimensional->getHeight();