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

74 lines
2.7 KiB
C++
Raw Normal View History

2023-11-16 22:58:47 +01:00
#pragma once
#include "Initializer.h"
#include "Texture.h"
2024-06-09 10:44:24 +02:00
#include <functional>
2023-11-16 22:58:47 +01:00
2024-06-09 12:20:04 +02:00
namespace Seele {
namespace Gfx {
class Window {
public:
2023-11-16 22:58:47 +01:00
Window();
virtual ~Window();
2025-02-28 16:56:51 +09:00
virtual void show() = 0;
2023-12-28 21:42:18 +01:00
virtual void pollInput() = 0;
2023-11-16 22:58:47 +01:00
virtual void beginFrame() = 0;
virtual void endFrame() = 0;
virtual void onWindowCloseEvent() = 0;
2024-04-10 08:43:56 +02:00
virtual PTexture2D getBackBuffer() const = 0;
2023-11-16 22:58:47 +01:00
virtual void setKeyCallback(std::function<void(KeyCode, InputAction, KeyModifier)> callback) = 0;
virtual void setMouseMoveCallback(std::function<void(double, double)> callback) = 0;
virtual void setMouseButtonCallback(std::function<void(MouseButton, InputAction, KeyModifier)> callback) = 0;
virtual void setScrollCallback(std::function<void(double, double)> callback) = 0;
virtual void setFileCallback(std::function<void(int, const char**)> callback) = 0;
virtual void setCloseCallback(std::function<void()> callback) = 0;
2023-11-18 11:04:30 +01:00
virtual void setResizeCallback(std::function<void(uint32, uint32)> callback) = 0;
2024-06-09 12:20:04 +02:00
constexpr SeFormat getSwapchainFormat() const { return framebufferFormat; }
constexpr uint32 getFramebufferWidth() const { return framebufferWidth; }
constexpr uint32 getFramebufferHeight() const { return framebufferHeight; }
2025-01-08 19:15:12 +01:00
constexpr float getContentScaleX() const { return contentScaleX; }
constexpr float getContentScaleY() const { return contentScaleY; }
2024-06-09 12:20:04 +02:00
constexpr bool isPaused() const { return paused; }
protected:
2023-11-16 22:58:47 +01:00
SeFormat framebufferFormat;
uint32 framebufferWidth;
uint32 framebufferHeight;
2025-01-08 19:15:12 +01:00
float contentScaleX;
float contentScaleY;
2023-12-28 21:42:18 +01:00
bool paused = false;
2023-11-16 22:58:47 +01:00
};
DEFINE_REF(Window)
2024-06-09 12:20:04 +02:00
class Viewport {
public:
2023-11-16 22:58:47 +01:00
Viewport(PWindow owner, const ViewportCreateInfo& createInfo);
virtual ~Viewport();
virtual void resize(uint32 newX, uint32 newY) = 0;
virtual void move(uint32 newOffsetX, uint32 newOffsetY) = 0;
constexpr PWindow getOwner() const { return owner; }
constexpr uint32 getWidth() const { return sizeX; }
constexpr uint32 getHeight() const { return sizeY; }
constexpr uint32 getOffsetX() const { return offsetX; }
constexpr uint32 getOffsetY() const { return offsetY; }
2025-01-08 19:15:12 +01:00
constexpr float getContentScaleX() const { return owner->getContentScaleX(); }
constexpr float getContentScaleY() const { return owner->getContentScaleY(); }
2023-11-16 22:58:47 +01:00
Matrix4 getProjectionMatrix() const;
2025-04-04 14:44:53 +02:00
URect getRenderArea() const {
return URect{
.size = {sizeX, sizeY},
.offset = {offsetX, offsetY},
};
}
2024-06-09 12:20:04 +02:00
protected:
2023-11-16 22:58:47 +01:00
uint32 sizeX;
uint32 sizeY;
uint32 offsetX;
uint32 offsetY;
float fieldOfView;
PWindow owner;
};
DEFINE_REF(Viewport)
2024-06-09 12:20:04 +02:00
} // namespace Gfx
2025-02-28 16:56:51 +09:00
} // namespace Seele