adding proper window close functionality

This commit is contained in:
2026-03-09 22:28:21 +01:00
parent 61dcb0430a
commit 661c91401f
6 changed files with 12 additions and 5 deletions
+1 -1
+4 -1
View File
@@ -143,7 +143,10 @@ void Window::endFrame() {
// graphics->waitDeviceIdle();
}
void Window::onWindowCloseEvent() {}
bool Window::shouldClose() const {
std::cout << "Checking if window should close: " << glfwWindowShouldClose((GLFWwindow*)windowHandle) << std::endl;
return glfwWindowShouldClose((GLFWwindow*)windowHandle);
}
Gfx::PTexture2D Window::getBackBuffer() const { return PTexture2D(swapChainTextures[currentImageIndex]); }
+1 -1
View File
@@ -16,7 +16,7 @@ class Window : public Gfx::Window {
virtual void beginFrame() override;
virtual void endFrame() override;
virtual Gfx::PTexture2D getBackBuffer() const override;
virtual void onWindowCloseEvent() override;
virtual bool shouldClose() const override;
virtual void setKeyCallback(std::function<void(KeyCode, InputAction, KeyModifier)> callback) override;
virtual void setMouseMoveCallback(std::function<void(double, double)> callback) override;
virtual void setMouseButtonCallback(std::function<void(MouseButton, InputAction, KeyModifier)> callback) override;
+2 -1
View File
@@ -13,7 +13,7 @@ class Window {
virtual void pollInput() = 0;
virtual void beginFrame() = 0;
virtual void endFrame() = 0;
virtual void onWindowCloseEvent() = 0;
virtual bool shouldClose() const = 0;
virtual PTexture2D getBackBuffer() const = 0;
virtual void setKeyCallback(std::function<void(KeyCode, InputAction, KeyModifier)> callback) = 0;
virtual void setMouseMoveCallback(std::function<void(double, double)> callback) = 0;
@@ -36,6 +36,7 @@ class Window {
float contentScaleX;
float contentScaleY;
bool paused = false;
bool closing = false;
};
DEFINE_REF(Window)
+3 -1
View File
@@ -40,7 +40,9 @@ void Window::setFocused(PView view) {
gfxHandle->setMouseButtonCallback(mouseButtonFunction);
gfxHandle->setScrollCallback(scrollFunction);
gfxHandle->setFileCallback(fileFunction);
gfxHandle->setCloseCallback([this]() { owner->notifyWindowClosed(this); });
gfxHandle->setCloseCallback([this]() {
owner->notifyWindowClosed(this);
});
}
void Window::onResize(uint32 width, uint32 height) {
+1
View File
@@ -17,6 +17,7 @@ class Window {
void setFocused(PView view);
void onResize(uint32 width, uint32 height);
constexpr bool isPaused() const { return gfxHandle->isPaused(); }
constexpr bool shouldClose() const { return gfxHandle->shouldClose(); }
protected:
PWindowManager owner;