diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-11-26 12:37:59 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-11-26 12:37:59 +0100 |
| commit | 6817e821af9d69363466025f17ee367cfaa4550e (patch) | |
| tree | 0ccee8a354141b7e5eefac83da657c030e1a9f9e /src/drivers | |
| parent | 102437f1eedce8589d947bf8791d6d5f413d445b (diff) | |
STR 1373: adds vsync control to OpenGL contexts on macOS
Windows and X11 to follow, no idea about Wayland.
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.H | 2 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.mm | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.H index 79b93e6df..21a3a4589 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.H +++ b/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.H @@ -38,6 +38,8 @@ class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver { void swap_buffers() FL_OVERRIDE; void resize(int is_a_resize, int w, int h) FL_OVERRIDE; char swap_type() FL_OVERRIDE; + void swap_interval(int) FL_OVERRIDE; + int swap_interval() FL_OVERRIDE; Fl_Gl_Choice *find(int m, const int *alistp) FL_OVERRIDE; GLContext create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g) FL_OVERRIDE; void set_gl_context(Fl_Window* w, GLContext context) FL_OVERRIDE; diff --git a/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.mm b/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.mm index a2c8e7578..43bc2d480 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.mm +++ b/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.mm @@ -355,6 +355,21 @@ void Fl_Cocoa_Gl_Window_Driver::swap_buffers() { char Fl_Cocoa_Gl_Window_Driver::swap_type() {return copy;} +void Fl_Cocoa_Gl_Window_Driver::swap_interval(int n) { + GLint interval = (GLint)n; + NSOpenGLContext* ctx = (NSOpenGLContext*)pWindow->context(); + if (ctx) + [ctx setValues:&interval forParameter:NSOpenGLContextParameterSwapInterval]; +} + +int Fl_Cocoa_Gl_Window_Driver::swap_interval() { + GLint interval = (GLint)-1; + NSOpenGLContext* ctx = (NSOpenGLContext*)pWindow->context(); + if (ctx) + [ctx getValues:&interval forParameter:NSOpenGLContextParameterSwapInterval]; + return interval; +} + void Fl_Cocoa_Gl_Window_Driver::resize(int is_a_resize, int w, int h) { if (pWindow->shown()) apply_scissor(); [(NSOpenGLContext*)pWindow->context() update]; |
