Allow camera render target to be null
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
|
||||
<UIBorder
|
||||
ref="border"
|
||||
borderSize="8, 8"
|
||||
borderSize="16, 16"
|
||||
alignment="50, 0, 0, 0"
|
||||
alignUnitLeft="UI_COMPONENT_ALIGN_UNIT_PERCENT"
|
||||
ref="border"
|
||||
@ -12,8 +12,11 @@
|
||||
/>
|
||||
|
||||
<child>
|
||||
<UILabel text="bruh" font="font_main" fontSize="32"
|
||||
alignment="16, 16, -1, -1"
|
||||
<UILabel
|
||||
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"
|
||||
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
|
||||
// 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);
|
||||
|
@ -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);
|
||||
|
@ -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 );
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user