(Temp) UI only renders to backbuffer
This commit is contained in:
		@@ -12,6 +12,7 @@ target_sources(${DAWN_TARGET_NAME}
 | 
			
		||||
    PixelPerfectCamera.cpp
 | 
			
		||||
    TiledSprite.cpp
 | 
			
		||||
    SimpleRenderTargetQuad.cpp
 | 
			
		||||
    CameraTexture.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
add_subdirectory(mesh)
 | 
			
		||||
							
								
								
									
										24
									
								
								src/dawn/scene/components/display/CameraTexture.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/dawn/scene/components/display/CameraTexture.cpp
									
									
									
									
									
										Normal 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)();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										22
									
								
								src/dawn/scene/components/display/CameraTexture.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/dawn/scene/components/display/CameraTexture.hpp
									
									
									
									
									
										Normal 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;
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user