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

35 lines
1.2 KiB
C++
Raw Normal View History

2023-11-16 22:58:47 +01:00
#include "Window.h"
using namespace Seele;
using namespace Seele::Gfx;
2024-06-09 12:20:04 +02:00
Window::Window() {}
2023-11-16 22:58:47 +01:00
2024-06-09 12:20:04 +02:00
Window::~Window() {}
2023-11-16 22:58:47 +01:00
Viewport::Viewport(PWindow owner, const ViewportCreateInfo& viewportInfo)
2024-06-09 12:20:04 +02:00
: sizeX(std::min(owner->getFramebufferWidth(), viewportInfo.dimensions.size.x)),
sizeY(std::min(owner->getFramebufferHeight(), viewportInfo.dimensions.size.y)), offsetX(viewportInfo.dimensions.offset.x),
2025-03-10 18:35:35 +01:00
offsetY(viewportInfo.dimensions.offset.y), fieldOfView(viewportInfo.fieldOfView), owner(owner) {}
2023-11-16 22:58:47 +01:00
2024-06-09 12:20:04 +02:00
Viewport::~Viewport() {}
2023-11-16 22:58:47 +01:00
2024-06-09 12:20:04 +02:00
Matrix4 Viewport::getProjectionMatrix() const {
if (fieldOfView > 0.0f) {
// 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
//);
2024-09-29 22:28:37 +02:00
return glm::perspective(fieldOfView, sizeX / static_cast<float>(sizeY), 0.1f, 1000.0f);
2024-06-09 12:20:04 +02:00
} else {
2025-01-12 11:26:52 +01:00
return glm::ortho(0.0f, (float)sizeX, (float)sizeY, 0.0f);
2024-06-09 12:20:04 +02:00
}
2023-11-16 22:58:47 +01:00
}