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

52 lines
1.1 KiB
C++
Raw Normal View History

2023-11-16 22:58:47 +01:00
#include "Window.h"
using namespace Seele;
using namespace Seele::Gfx;
Window::Window()
{
}
Window::~Window()
{
}
Viewport::Viewport(PWindow owner, const ViewportCreateInfo& viewportInfo)
: sizeX(std::min(owner->getFramebufferWidth(), viewportInfo.dimensions.size.x))
, sizeY(std::min(owner->getFramebufferHeight(), viewportInfo.dimensions.size.y))
, offsetX(viewportInfo.dimensions.offset.x)
, offsetY(viewportInfo.dimensions.offset.y)
, fieldOfView(viewportInfo.fieldOfView)
2023-12-04 16:36:02 +01:00
, samples(viewportInfo.numSamples)
2023-11-16 22:58:47 +01:00
, owner(owner)
{
}
Viewport::~Viewport()
{
}
Matrix4 Viewport::getProjectionMatrix() const
{
if (fieldOfView > 0.0f)
{
2024-05-06 18:36:16 +02:00
//float h = 1.0 / tan(fieldOfView * 0.5);
//float w = h / (sizeX / static_cast<float>(sizeY));
//float zFar = 1000.0f;
//float zNear = 0.1f;
//float a = -zNear / (zFar - zNear);
//float b = (zNear * zFar) / (zFar - zNear);
//return Matrix4(
// w, 0, 0, 0,
// 0, -h, 0, 0,
// 0, 0, a, b,
// 0, 0, 1, 0
//);
2023-12-28 21:42:18 +01:00
return glm::perspective(fieldOfView, sizeX / static_cast<float>(sizeY), 0.1f, 10000.0f);
2023-11-16 22:58:47 +01:00
}
else
{
return glm::ortho(0.0f, (float)sizeX, (float)sizeY, 0.0f);
}
}