mirror of
https://github.com/fltk/fltk.git
synced 2026-05-25 00:53:39 +08:00
Wayland platform: add support of gl_start() / gl_finish().
This commit is contained in:
@@ -170,6 +170,12 @@ GLContext Fl_Wayland_Gl_Window_Driver::create_gl_context(Fl_Window* window, cons
|
|||||||
//fprintf(stderr, "eglCreateContext=%p shared_ctx=%p\n", ctx, shared_ctx);
|
//fprintf(stderr, "eglCreateContext=%p shared_ctx=%p\n", ctx, shared_ctx);
|
||||||
if (ctx)
|
if (ctx)
|
||||||
add_context(ctx);
|
add_context(ctx);
|
||||||
|
if (!egl_surface) { // useful for gl_start()
|
||||||
|
struct wld_window *xid = fl_xid(window);
|
||||||
|
float s = Fl::screen_scale(window->screen_num());
|
||||||
|
egl_window = wl_egl_window_create(xid->wl_surface, window->w() * s, window->h() * s);
|
||||||
|
egl_surface = eglCreateWindowSurface(egl_display, ((Fl_Wayland_Gl_Choice*)g)->egl_conf, egl_window, NULL);
|
||||||
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,10 +355,21 @@ char Fl_Wayland_Gl_Window_Driver::swap_type() {
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Fl_Wayland_Gl_Window_Driver::waitGL() {
|
void Fl_Wayland_Gl_Window_Driver::waitGL() {
|
||||||
|
struct wld_window *window = fl_xid(Fl_Window::current());
|
||||||
|
window->buffer->draw_buffer_needs_commit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Fl_Wayland_Gl_Window_Driver::gl_start() {
|
void Fl_Wayland_Gl_Window_Driver::gl_start() {
|
||||||
|
struct wld_window *win = fl_xid(Fl_Window::current());
|
||||||
|
float f = Fl::screen_scale(Fl_Window::current()->screen_num());
|
||||||
|
int W = Fl_Window::current()->w() * f;
|
||||||
|
int H = Fl_Window::current()->h() * f;
|
||||||
|
int W2, H2;
|
||||||
|
wl_egl_window_get_attached_size(egl_window, &W2, &H2);
|
||||||
|
if (W2 != W || H2 != H) wl_egl_window_resize(egl_window, W, H, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ struct fl_wld_buffer *Fl_Wayland_Graphics_Driver::create_shm_buffer(int width, i
|
|||||||
|
|
||||||
|
|
||||||
void Fl_Wayland_Graphics_Driver::buffer_commit(struct wld_window *window) {
|
void Fl_Wayland_Graphics_Driver::buffer_commit(struct wld_window *window) {
|
||||||
|
if (!window->buffer->draw_buffer_needs_commit) return;
|
||||||
cairo_surface_t *surf = cairo_get_target(window->buffer->cairo_);
|
cairo_surface_t *surf = cairo_get_target(window->buffer->cairo_);
|
||||||
cairo_surface_flush(surf);
|
cairo_surface_flush(surf);
|
||||||
memcpy(window->buffer->data, window->buffer->draw_buffer, window->buffer->data_size);
|
memcpy(window->buffer->data, window->buffer->draw_buffer, window->buffer->data_size);
|
||||||
|
|||||||
Reference in New Issue
Block a user