This commit is contained in:
2023-11-15 23:13:22 -06:00
parent 99e8c4b5d8
commit e8c1cb24c5
19 changed files with 330 additions and 25 deletions

View File

@ -5,16 +5,24 @@
#include "assert/assert.hpp"
#include "Camera.hpp"
#include "game/Game.hpp"
using namespace Dawn;
void Camera::onInit() {
std::cout << "Camera" << std::endl;
if(renderTarget == nullptr) {
this->setRenderTarget(
getGame()->renderHost.backBufferRenderTarget
);
}
}
void Camera::onDispose() {
std::cout << "~Camera" << std::endl;
// renderTarget = nullptr;
renderTarget = nullptr;
}
std::shared_ptr<RenderTarget> Camera::getRenderTarget() {
return this->renderTarget;
}
glm::mat4 Camera::getProjection() {
@ -44,4 +52,11 @@ glm::mat4 Camera::getProjection() {
float_t Camera::getAspect() {
return 1.0f;
}
void Camera::setRenderTarget(std::shared_ptr<RenderTarget> renderTarget) {
if(this->renderTarget != nullptr) {
}
this->renderTarget = renderTarget;
}

View File

@ -5,6 +5,7 @@
#pragma once
#include "scene/SceneItem.hpp"
#include "display/RenderTarget.hpp"
namespace Dawn {
enum CameraType {
@ -12,7 +13,10 @@ namespace Dawn {
ORTHOGONAL
};
class Camera : public SceneComponent {
class Camera final : public SceneComponent {
private:
std::shared_ptr<RenderTarget> renderTarget;
public:
float_t clipNear = 0.01f;
float_t clipFar = 1000.0f;
@ -25,8 +29,6 @@ namespace Dawn {
float_t orthoBottom = -1.0f;
float_t orthoTop = 1.0f;
// std::shared_ptr<RenderTarget> renderTarget;
void onInit() override;
void onDispose() override;
@ -39,11 +41,25 @@ namespace Dawn {
*/
float_t getAspect();
/**
* Returns the render target for this camera.
*
* @return Render target.
*/
std::shared_ptr<RenderTarget> getRenderTarget();
/**
* Returns the projection matrix for this camera.
*
* @return Projection matrix.
*/
glm::mat4 getProjection();
/**
* Sets the render target for this camera.
*
* @param renderTarget The render target to set.
*/
void setRenderTarget(std::shared_ptr<RenderTarget> renderTarget);
};
}

View File

@ -8,7 +8,7 @@
#include "scene/SceneItem.hpp"
namespace Dawn {
class MeshRenderer : public SceneComponent {
class MeshRenderer final : public SceneComponent {
public:
std::shared_ptr<Mesh> mesh;