Skip to content

Conversation

@TwentyPast4
Copy link

@TwentyPast4 TwentyPast4 commented Jun 18, 2023

In most situations, you want vsync to have fluid and responsive animations and to avoid screen tearing.
It's a must-gave for a game and that's why it feels wrong not to have it in the common set of application function (imo).
I've added vsync support to nanogui to make it as easy to use as possible while keeping the code as similar as possible and avoiding branching out two mainloop() functions.

Intended usage:

nanogui::init();
nanogui::set_vsync(true);

// the following is an example, but the vsync logic is done nanogui::mainloop
// if you have a custom main loop, see code for reference to how vsync is handled
{
ref<MyApp> app = new MyApp();
app->draw_all();
app->set_visible(true);
nanogui::mainloop();
}
nanogui::shutdown();

Also contains a small addition to nanogui Screen which updates the currently displayed cursor. This is in place to solve a bug where a widget dynamically changes its cursor , but nanogui does not update it, because it only changes the cursor on mouse move.
Same thing happens when a widget position or size changes such that the widget under the cursor is not the same anymore.

Code is probably not formatted correctly as there is no clang_format or similar that I could use

@wjakob wjakob force-pushed the master branch 9 times, most recently from 654b8a5 to 1cbff2e Compare August 29, 2025 18:29
@wjakob wjakob force-pushed the master branch 19 times, most recently from 2f2e29f to 9d91e56 Compare September 1, 2025 22:08
@wjakob wjakob force-pushed the master branch 6 times, most recently from c75898b to 1bbd038 Compare September 6, 2025 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant