Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for VSync #151

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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

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