feat: add window resize support
Added width/height tracking to the window class via a GLFW resize callback. The callback stores the current size and forwards it to a user-provided std::function. Added context::set_size() to update the GL viewport when the window is resized. Changed scene::render() to accept (int width, int height) parameters so scenes can compute the correct aspect ratio for their projection matrix instead of hardcoding 1280/720. Fixed parameter shadowing in resize_callback_impl (glfw_window instead of window).
This commit is contained in:
@@ -34,6 +34,9 @@ context::context(window const& win) {
|
||||
return;
|
||||
}
|
||||
m_valid = true;
|
||||
|
||||
// Set initial viewport to match window size
|
||||
glViewport(0, 0, win.width(), win.height());
|
||||
}
|
||||
|
||||
context::~context() {}
|
||||
@@ -42,4 +45,8 @@ auto context::valid() const -> bool {
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
auto context::set_size(int width, int height) -> void {
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ public:
|
||||
~context();
|
||||
|
||||
auto valid() const -> bool;
|
||||
auto set_size(int width, int height) -> void;
|
||||
|
||||
private:
|
||||
bool m_valid = false;
|
||||
|
||||
Reference in New Issue
Block a user