Allow camera render target to be null
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<UIBorder
|
<UIBorder
|
||||||
ref="border"
|
ref="border"
|
||||||
borderSize="8, 8"
|
borderSize="16, 16"
|
||||||
alignment="50, 0, 0, 0"
|
alignment="50, 0, 0, 0"
|
||||||
alignUnitLeft="UI_COMPONENT_ALIGN_UNIT_PERCENT"
|
alignUnitLeft="UI_COMPONENT_ALIGN_UNIT_PERCENT"
|
||||||
ref="border"
|
ref="border"
|
||||||
@ -12,8 +12,11 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<UILabel text="bruh" font="font_main" fontSize="32"
|
<UILabel
|
||||||
alignment="16, 16, -1, -1"
|
text="This shows how I can now make UI elements align based on percentages of the screen."
|
||||||
|
font="font_main"
|
||||||
|
fontSize="32"
|
||||||
|
alignment="16, 16, 0, 0"
|
||||||
alignX="UI_COMPONENT_ALIGN_STRETCH"
|
alignX="UI_COMPONENT_ALIGN_STRETCH"
|
||||||
alignY="UI_COMPONENT_ALIGN_STRETCH"
|
alignY="UI_COMPONENT_ALIGN_STRETCH"
|
||||||
/>
|
/>
|
||||||
|
@ -60,7 +60,10 @@ void RenderPipeline::renderScene(Scene *scene) {
|
|||||||
|
|
||||||
// Leave the backbuffer camera(s) to last, so we skip them. we do this so
|
// 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.
|
// that children framebuffers contain the CURRENT frame, not LAST frame.
|
||||||
if(cameraTarget == backBuffer) {
|
if(cameraTarget == nullptr) {
|
||||||
|
++it;
|
||||||
|
continue;
|
||||||
|
} else if(cameraTarget == backBuffer) {
|
||||||
backBufferCamera = *it;
|
backBufferCamera = *it;
|
||||||
} else {
|
} else {
|
||||||
this->renderSceneCamera(scene, *it);
|
this->renderSceneCamera(scene, *it);
|
||||||
|
@ -10,7 +10,7 @@ using namespace Dawn;
|
|||||||
|
|
||||||
Camera::Camera(SceneItem *item) :
|
Camera::Camera(SceneItem *item) :
|
||||||
SceneItemComponent(item),
|
SceneItemComponent(item),
|
||||||
renderTarget(nullptr),
|
renderTarget(item->scene->game->renderManager.getBackBuffer()),
|
||||||
fov(0.785398f),// 45 degrees,
|
fov(0.785398f),// 45 degrees,
|
||||||
type(CAMERA_TYPE_PERSPECTIVE),
|
type(CAMERA_TYPE_PERSPECTIVE),
|
||||||
orthoLeft(0.0f),
|
orthoLeft(0.0f),
|
||||||
@ -52,10 +52,6 @@ glm::mat4 Camera::getProjection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RenderTarget * Camera::getRenderTarget() {
|
RenderTarget * Camera::getRenderTarget() {
|
||||||
auto v = this->renderTarget;
|
|
||||||
if(this->renderTarget == nullptr) {
|
|
||||||
return this->getGame()->renderManager.getBackBuffer();
|
|
||||||
}
|
|
||||||
return (RenderTarget*)this->renderTarget;
|
return (RenderTarget*)this->renderTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +76,11 @@ void Camera::onStart() {
|
|||||||
useEffectWithTeardown([&]{
|
useEffectWithTeardown([&]{
|
||||||
auto rt = this->getRenderTarget();
|
auto rt = this->getRenderTarget();
|
||||||
this->projectionNeedsUpdating = true;
|
this->projectionNeedsUpdating = true;
|
||||||
|
if(rt == nullptr) {
|
||||||
|
return evtResized = [&]{
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
this->eventRenderTargetResized.invoke(rt->getWidth(), rt->getHeight());
|
this->eventRenderTargetResized.invoke(rt->getWidth(), rt->getHeight());
|
||||||
|
|
||||||
// Subscribe to new render target resized.
|
// 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
|
// 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.
|
// 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){
|
evtResized = useEventLegacy([&](RenderTarget *rt, float_t w, float_t h){
|
||||||
this->projectionNeedsUpdating = true;
|
this->projectionNeedsUpdating = true;
|
||||||
this->eventRenderTargetResized.invoke(w, h);
|
this->eventRenderTargetResized.invoke(w, h);
|
||||||
|
@ -53,8 +53,6 @@ void UIBorder::onStart() {
|
|||||||
UIComponent::onStart();
|
UIComponent::onStart();
|
||||||
|
|
||||||
auto rebufferQuad = [&] {
|
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 tSize = glm::vec2(1, 1) / 3.0f;
|
||||||
glm::vec2 bSize = (glm::vec2)borderSize;
|
glm::vec2 bSize = (glm::vec2)borderSize;
|
||||||
glm::vec2 iSize = glm::vec2(this->getWidth(), this->getHeight()) - ( bSize * 2.0f );
|
glm::vec2 iSize = glm::vec2(this->getWidth(), this->getHeight()) - ( bSize * 2.0f );
|
||||||
|
@ -13,7 +13,7 @@ UILabel::UILabel(SceneItem *item) :
|
|||||||
text(""),
|
text(""),
|
||||||
fontSize(10.0f),
|
fontSize(10.0f),
|
||||||
font(&item->scene->game->renderManager.defaultFont),
|
font(&item->scene->game->renderManager.defaultFont),
|
||||||
maxWidth(UI_LABEL_MAX_WIDTH_NONE)
|
maxWidth(UI_LABEL_MAX_WIDTH_ALIGN)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ namespace Dawn {
|
|||||||
class HelloWorldScene : public Scene {
|
class HelloWorldScene : public Scene {
|
||||||
protected:
|
protected:
|
||||||
Camera *camera;
|
Camera *camera;
|
||||||
|
Camera *camNew;
|
||||||
UICanvas *canvas;
|
UICanvas *canvas;
|
||||||
Texture text;
|
Texture text;
|
||||||
|
|
||||||
@ -25,6 +26,10 @@ namespace Dawn {
|
|||||||
camera->fov = 0.436332f;
|
camera->fov = 0.436332f;
|
||||||
camera->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0));
|
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 cube = SimpleSpinningCubePrefab::create(this);
|
||||||
|
|
||||||
auto textbox = VNTextbox::create(this);
|
auto textbox = VNTextbox::create(this);
|
||||||
|
Reference in New Issue
Block a user