2023-11-16 22:58:47 +01:00
|
|
|
#include "Window.h"
|
2025-08-14 11:06:43 +02:00
|
|
|
#include "Math/Matrix.h"
|
2023-11-16 22:58:47 +01:00
|
|
|
|
|
|
|
|
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)
|
2025-04-04 14:44:53 +02:00
|
|
|
: sizeX(viewportInfo.dimensions.size.x), sizeY(viewportInfo.dimensions.size.y), offsetX(viewportInfo.dimensions.offset.x),
|
2025-05-06 19:36:43 +02:00
|
|
|
offsetY(viewportInfo.dimensions.offset.y), fieldOfView(viewportInfo.fieldOfView), orthoLeft(viewportInfo.left),
|
2025-05-10 22:52:46 +02:00
|
|
|
orthoRight(viewportInfo.right), orthoTop(viewportInfo.top), orthoBottom(viewportInfo.bottom), owner(owner) {
|
2025-04-06 09:57:47 +02:00
|
|
|
if (owner != nullptr) {
|
|
|
|
|
sizeX = std::min(owner->getFramebufferWidth(), sizeX);
|
|
|
|
|
sizeY = std::min(owner->getFramebufferHeight(), sizeY);
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
2025-05-06 19:36:43 +02:00
|
|
|
Matrix4 Viewport::getProjectionMatrix(float nearPlane, float farPlane) const {
|
2024-06-09 12:20:04 +02:00
|
|
|
if (fieldOfView > 0.0f) {
|
2025-08-14 11:06:43 +02:00
|
|
|
return perspectiveProjection(fieldOfView, static_cast<float>(sizeX) / sizeY, nearPlane, farPlane);
|
2024-06-09 12:20:04 +02:00
|
|
|
} else {
|
2025-08-14 11:06:43 +02:00
|
|
|
return orthographicProjection(orthoLeft, orthoRight, orthoBottom, orthoTop, nearPlane, farPlane);
|
2024-06-09 12:20:04 +02:00
|
|
|
}
|
2023-11-16 22:58:47 +01:00
|
|
|
}
|