dibyendu
dibyendu

Reputation: 321

How to load background of GtkGLArea on a Cairo Surface in Gtk 4.12?

Can someone tell me, how to load the background of a GtkGLArea on a Cairo surface? For the gtk version 4.8.3, I did it this way--

GtkWidget *GLArea = gtk_gl_area_new ();
/* draw shape on GLArea */

GtkStyleContext *glContext = gtk_widget_get_style_context (GTK_WIDGET(GLArea));
cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, height, height);
cairo_t *cr = cairo_create (surface);

gtk_render_background(glContext, cr, 0 ,0, height, height);
 

But functiongtk_widget_get_style_context and gtk_render_background is deprecated since 4.10. In gtk 4.12, how to do it?

Upvotes: 1

Views: 60

Answers (1)

Holger
Holger

Reputation: 1020

In March 2018 Benjamin Otte wrote in GTK Development Blog:

" With GTK4, we’ve been trying to find better solution for image data. In GTK3 the objects we used for this were pixbufs and Cairo surfaces. But they don’t fit the bill anymore, so now we have GdkTexture and GdkPaintable."

Cairo should be replaced. I would conclude from this that GTK4 / GTK5 will no longer provide a chance to load the background of GtkGLArea into a Cairo surface.

The path would then be to store the surface of GtkGLArea in a framebuffer, then read it out and transfer it at byte level so that it can be loaded into a Cairo surface.

Sorry.

Upvotes: 1

Related Questions