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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions include/nanogui/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,28 @@ extern NANOGUI_EXPORT void leave();
/// Return whether or not a main loop is currently active
extern NANOGUI_EXPORT bool active();

/**
* \brief Function to enable or disable vertical synchronization.
*
* Changes how the main loop is called and when redraws occur.
*
* Solves screen tearing and provides fluid operation on all monitors, instead of just looking about-right on 60Hz displays.
*
* Results in higher system load compared to it being disabled due to the more frequent update and draw calls.
*
* Default disabled - set_vsync(false) is called in nanogui::init()
* @remark Some extensions used by GLFW do not allow the vsync mode to be disabled once it has been enabled.
*
* @remark Some GPU drivers do not honor this setting, either
* because of a user setting that overrides the application's request or due to
* bugs in the driver.
* \param enabled True to enable VSYNC, false to disable it.
*/
extern NANOGUI_EXPORT void set_vsync(bool enabled);

/// Return true or false if vsync is enabled (set with set_vsync)
extern NANOGUI_EXPORT bool vsync_enabled();

/**
* \brief Enqueue a function to be executed executed before
* the application is redrawn the next time.
Expand Down
3 changes: 3 additions & 0 deletions include/nanogui/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ class NANOGUI_EXPORT Screen : public Widget {
void move_window_to_front(Window *window);
void draw_widgets();

// Checks if the current widget under the mouse pointer has a different cursor than the one which is set (useful when dynamically changing widget cursors)
void update_cursor();

protected:
GLFWwindow *m_glfw_window = nullptr;
NVGcontext *m_nvg_context = nullptr;
Expand Down
Loading