Files
Seele/src/Engine/Graphics/RenderTarget.cpp
T

84 lines
2.2 KiB
C++
Raw Normal View History

2023-10-26 18:37:29 +02:00
#include "RenderTarget.h"
using namespace Seele;
using namespace Seele::Gfx;
RenderTargetLayout::RenderTargetLayout()
: inputAttachments()
, colorAttachments()
, depthAttachment()
2023-11-05 10:36:01 +01:00
, width(0)
, height(0)
2023-10-26 18:37:29 +02:00
{
}
2023-11-05 10:36:01 +01:00
RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment depthAttachment)
2023-10-26 18:37:29 +02:00
: inputAttachments()
, colorAttachments()
2023-11-05 10:36:01 +01:00
, depthAttachment(depthAttachment)
2023-10-26 18:37:29 +02:00
, width(depthAttachment->getTexture()->getSizeX())
, height(depthAttachment->getTexture()->getSizeY())
{
}
2023-11-05 10:36:01 +01:00
RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment colorAttachment, PRenderTargetAttachment depthAttachment)
2023-10-26 18:37:29 +02:00
: inputAttachments()
2023-11-05 10:36:01 +01:00
, depthAttachment(depthAttachment)
2023-10-26 18:37:29 +02:00
, width(depthAttachment->getTexture()->getSizeX())
, height(depthAttachment->getTexture()->getSizeY())
{
colorAttachments.add(colorAttachment);
}
2023-11-05 10:36:01 +01:00
RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment)
2023-10-26 18:37:29 +02:00
: inputAttachments()
2023-11-05 10:36:01 +01:00
, colorAttachments(colorAttachments)
, depthAttachment(depthAttachment)
2023-10-26 18:37:29 +02:00
, width(depthAttachment->getTexture()->getSizeX())
, height(depthAttachment->getTexture()->getSizeY())
{
}
2023-11-05 10:36:01 +01:00
RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> inputAttachments, Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment)
: inputAttachments(inputAttachments)
, colorAttachments(colorAttachments)
, depthAttachment(depthAttachment)
2023-10-26 18:37:29 +02:00
, width(depthAttachment->getTexture()->getSizeX())
, height(depthAttachment->getTexture()->getSizeY())
{
}
Window::Window(const WindowCreateInfo& createInfo)
: windowState(createInfo)
{
}
Window::~Window()
{
}
Viewport::Viewport(PWindow owner, const ViewportCreateInfo& viewportInfo)
2023-11-11 13:56:12 +01:00
: sizeX(std::min(owner->getSizeX(), viewportInfo.dimensions.size.x))
, sizeY(std::min(owner->getSizeY(), viewportInfo.dimensions.size.y))
2023-10-26 18:37:29 +02:00
, offsetX(viewportInfo.dimensions.offset.x)
, offsetY(viewportInfo.dimensions.offset.y)
, fieldOfView(viewportInfo.fieldOfView)
, owner(owner)
{
}
Viewport::~Viewport()
{
}
Matrix4 Viewport::getProjectionMatrix() const
{
if (fieldOfView > 0.0f)
{
return glm::perspective(fieldOfView, sizeX / static_cast<float>(sizeY), 0.1f, 1000.0f);
}
else
{
return glm::ortho(0.0f, (float)sizeX, (float)sizeY, 0.0f);
}
}