STR 1373: adds vsync control to OpenGL contexts on macOS
Windows and X11 to follow, no idea about Wayland.
This commit is contained in:
parent
102437f1ee
commit
6817e821af
@ -199,6 +199,8 @@ public:
|
||||
void context(GLContext, int destroy_flag = 0);
|
||||
void make_current();
|
||||
void swap_buffers();
|
||||
void swap_interval(int);
|
||||
int swap_interval() const;
|
||||
void ortho();
|
||||
|
||||
int can_do_overlay();
|
||||
|
@ -161,6 +161,21 @@ void Fl_Gl_Window::swap_buffers() {
|
||||
pGlWindowDriver->swap_buffers();
|
||||
}
|
||||
|
||||
/**
|
||||
Sets the rate at which the GL windows swaps buffers.
|
||||
*/
|
||||
void Fl_Gl_Window::swap_interval(int frames) {
|
||||
pGlWindowDriver->swap_interval(frames);
|
||||
}
|
||||
|
||||
/**
|
||||
Gets the rate at which the GL windows swaps buffers.
|
||||
*/
|
||||
int Fl_Gl_Window::swap_interval() const {
|
||||
return pGlWindowDriver->swap_interval();
|
||||
}
|
||||
|
||||
|
||||
void Fl_Gl_Window::flush() {
|
||||
if (!shown()) return;
|
||||
uchar save_valid = valid_f_ & 1;
|
||||
|
@ -69,6 +69,8 @@ public:
|
||||
virtual void swap_buffers() {}
|
||||
virtual void resize(int /*is_a_resize*/, int /*w*/, int /*h*/) {}
|
||||
virtual char swap_type();
|
||||
virtual void swap_interval(int) { }
|
||||
virtual int swap_interval() { return -1; }
|
||||
virtual int flush_begin(char&) {return 0;}
|
||||
virtual void gl_hide_before(void *&) {} // the default implementation may be enough
|
||||
static Fl_Gl_Choice *find_begin(int m, const int *alistp);
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user