diff --git a/src/dawn/display/RenderPipeline.cpp b/src/dawn/display/RenderPipeline.cpp index 32a3b6ef..a631a3b2 100644 --- a/src/dawn/display/RenderPipeline.cpp +++ b/src/dawn/display/RenderPipeline.cpp @@ -60,7 +60,10 @@ void RenderPipeline::renderScene(Scene *scene) { // Leave the backbuffer camera(s) to last, so we skip them. we do this so // that children framebuffers contain the CURRENT frame, not LAST frame. - if(cameraTarget == backBuffer) { + if(cameraTarget == nullptr) { + ++it; + continue; + } else if(cameraTarget == backBuffer) { backBufferCamera = *it; } else { this->renderSceneCamera(scene, *it); diff --git a/src/dawn/scene/components/display/Camera.cpp b/src/dawn/scene/components/display/Camera.cpp index 42fefc6a..54820199 100644 --- a/src/dawn/scene/components/display/Camera.cpp +++ b/src/dawn/scene/components/display/Camera.cpp @@ -10,7 +10,7 @@ using namespace Dawn; Camera::Camera(SceneItem *item) : SceneItemComponent(item), - renderTarget(nullptr), + renderTarget(item->scene->game->renderManager.getBackBuffer()), fov(0.785398f),// 45 degrees, type(CAMERA_TYPE_PERSPECTIVE), orthoLeft(0.0f), @@ -52,10 +52,6 @@ glm::mat4 Camera::getProjection() { } RenderTarget * Camera::getRenderTarget() { - auto v = this->renderTarget; - if(this->renderTarget == nullptr) { - return this->getGame()->renderManager.getBackBuffer(); - } return (RenderTarget*)this->renderTarget; } @@ -80,6 +76,11 @@ void Camera::onStart() { useEffectWithTeardown([&]{ auto rt = this->getRenderTarget(); this->projectionNeedsUpdating = true; + if(rt == nullptr) { + return evtResized = [&]{ + + }; + } this->eventRenderTargetResized.invoke(rt->getWidth(), rt->getHeight()); // Subscribe to new render target resized. @@ -100,6 +101,7 @@ void Camera::onStart() { // Sub to evt legacy, we don't invoke the useTeardown to avoid invoking // the state event for this camera when we don't need to. + if(!this->getRenderTarget()) return; evtResized = useEventLegacy([&](RenderTarget *rt, float_t w, float_t h){ this->projectionNeedsUpdating = true; this->eventRenderTargetResized.invoke(w, h); diff --git a/src/dawn/scene/components/ui/UIBorder.cpp b/src/dawn/scene/components/ui/UIBorder.cpp index 73b2a946..f9f79691 100644 --- a/src/dawn/scene/components/ui/UIBorder.cpp +++ b/src/dawn/scene/components/ui/UIBorder.cpp @@ -53,8 +53,6 @@ void UIBorder::onStart() { UIComponent::onStart(); auto rebufferQuad = [&] { - std::cout << "W" << this->getWidth() << std::endl; - std::cout << "H" << this->getHeight() << std::endl; glm::vec2 tSize = glm::vec2(1, 1) / 3.0f; glm::vec2 bSize = (glm::vec2)borderSize; glm::vec2 iSize = glm::vec2(this->getWidth(), this->getHeight()) - ( bSize * 2.0f ); diff --git a/src/dawn/scene/components/ui/UILabel.cpp b/src/dawn/scene/components/ui/UILabel.cpp index 27f070d7..6248e1b7 100644 --- a/src/dawn/scene/components/ui/UILabel.cpp +++ b/src/dawn/scene/components/ui/UILabel.cpp @@ -13,7 +13,7 @@ UILabel::UILabel(SceneItem *item) : text(""), fontSize(10.0f), font(&item->scene->game->renderManager.defaultFont), - maxWidth(UI_LABEL_MAX_WIDTH_NONE) + maxWidth(UI_LABEL_MAX_WIDTH_ALIGN) { } diff --git a/src/dawnliminal/scenes/HelloWorldScene.hpp b/src/dawnliminal/scenes/HelloWorldScene.hpp index b7073ac4..3b24c175 100644 --- a/src/dawnliminal/scenes/HelloWorldScene.hpp +++ b/src/dawnliminal/scenes/HelloWorldScene.hpp @@ -13,6 +13,7 @@ namespace Dawn { class HelloWorldScene : public Scene { protected: Camera *camera; + Camera *camNew; UICanvas *canvas; Texture text; @@ -25,6 +26,10 @@ namespace Dawn { camera->fov = 0.436332f; camera->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0)); + camNew = Camera::create(this); + camNew->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0)); + camNew->renderTarget = nullptr; + auto cube = SimpleSpinningCubePrefab::create(this); auto textbox = VNTextbox::create(this);