adding proper window close functionality
This commit is contained in:
Vendored
+1
-1
Submodule external/vcpkg updated: ce35b1a53a...f9a99aa79c
@@ -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]); }
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user