diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-11-28 16:35:39 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-11-28 16:35:39 +0100 |
| commit | 82e838f1fdadd7dd346f4bce51c6ebdd1e26dd35 (patch) | |
| tree | e1f5dcedcfa6d15fa1b8956defbda7b97549f958 /src/drivers/Wayland | |
| parent | 59bdb455668a896d9989f08446e24313f5de48d6 (diff) | |
Adds OpenGL swap_interval for Wayland and X11.
Diffstat (limited to 'src/drivers/Wayland')
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H | 2 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H index 83b13e155..df321fc10 100644 --- a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H @@ -46,6 +46,8 @@ private: 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() const 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/Wayland/Fl_Wayland_Gl_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx index 4553c1a0e..ac625fe6f 100644 --- a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx @@ -63,6 +63,9 @@ struct gl_start_support { // to support use of gl_start / gl_finish static EGLConfig wld_egl_conf = NULL; +static EGLint swap_interval_ = 1; +static EGLint max_swap_interval = 1000; +static EGLint min_swap_interval = 0; EGLDisplay Fl_Wayland_Gl_Window_Driver::egl_display = EGL_NO_DISPLAY; @@ -170,6 +173,9 @@ Fl_Gl_Choice *Fl_Wayland_Gl_Window_Driver::find(int m, const int *alistp) Fl::fatal("failed to choose an EGL config\n"); } + eglGetConfigAttrib(egl_display, g->egl_conf, EGL_MAX_SWAP_INTERVAL, &max_swap_interval); + eglGetConfigAttrib(egl_display, g->egl_conf, EGL_MIN_SWAP_INTERVAL, &min_swap_interval); + first = g; return g; } @@ -431,6 +437,18 @@ void Fl_Wayland_Gl_Window_Driver::gl_start() { glClear(GL_COLOR_BUFFER_BIT); } +void Fl_Wayland_Gl_Window_Driver::swap_interval(int interval) { + if (interval < min_swap_interval) interval = min_swap_interval; + if (interval > max_swap_interval) interval = max_swap_interval; + if (egl_display && eglSwapInterval(egl_display, interval)) + swap_interval_ = interval; + // printf("swap_interval_=%d\n",swap_interval_); +} + + +int Fl_Wayland_Gl_Window_Driver::swap_interval() const { + return swap_interval_; +} FL_EXPORT EGLContext fl_wl_glcontext(GLContext rc) { return (EGLContext)rc; } |
