Working on RenderTarget example
This commit is contained in:
@ -4,6 +4,8 @@
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "Camera.hpp"
|
||||
#include "scene/Scene.hpp"
|
||||
#include "game/DawnGame.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
@ -34,8 +36,17 @@ void Camera::updateProjection() {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<RenderTarget> Camera::getRenderTarget() {
|
||||
if(this->target == nullptr) {
|
||||
return this->getGame()->renderManager.getBackBuffer();
|
||||
}
|
||||
|
||||
return this->target;
|
||||
}
|
||||
|
||||
float_t Camera::getAspect() {
|
||||
return 16.0f / 9.0f;
|
||||
auto target = this->getRenderTarget();
|
||||
return target->getWidth() / target->getHeight();
|
||||
}
|
||||
|
||||
void Camera::start() {
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "scene/SceneItemComponent.hpp"
|
||||
#include "display/RenderTarget.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
enum CameraType {
|
||||
@ -15,6 +16,7 @@ namespace Dawn {
|
||||
class Camera : public SceneItemComponent {
|
||||
public:
|
||||
glm::mat4 projection;
|
||||
std::shared_ptr<RenderTarget> target = nullptr;
|
||||
|
||||
// Perspective
|
||||
enum CameraType type = CAMERA_TYPE_PERSPECTIVE;
|
||||
@ -42,6 +44,8 @@ namespace Dawn {
|
||||
*/
|
||||
void updateProjection();
|
||||
|
||||
std::shared_ptr<RenderTarget> getRenderTarget();
|
||||
|
||||
/**
|
||||
* Returs the aspect ratio of the camera.
|
||||
*
|
||||
|
Reference in New Issue
Block a user