From 933120ed85e0d8842e86f99f5c34339643df735d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Thu, 25 Jun 2020 23:47:00 +0200 Subject: [PATCH] GtkGraphView: Add relaize signal callback to gl area to setup opengl stuff --- lib/src/gtk-graph-view.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/src/gtk-graph-view.c b/lib/src/gtk-graph-view.c index 3b300cc..fdd8b15 100644 --- a/lib/src/gtk-graph-view.c +++ b/lib/src/gtk-graph-view.c @@ -16,6 +16,7 @@ #include #include +#include struct _GtkGraphView { GtkBox super; @@ -24,7 +25,7 @@ struct _GtkGraphView { typedef struct { /** * @brief The gl area displaying the graph view. - * @note This variable is not referenced, because the gl_area is tightly bound to the GrapgView widget itself. + * @note This variable is not referenced, because the gl_area is tightly bound to the GraphView widget itself. */ GtkWidget *gl_area; GdkRGBA background_color; @@ -111,6 +112,13 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *klass) g_object_class_install_properties(oclass, N_PROPERTIES, gtk_graph_view_properties); } +static void gl_area_realize(GtkGLArea *area, gpointer data) +{ + (void)data; + gtk_gl_area_make_current(area); + +} + /** * @brief Init a new GtkGraphView GObject * @param obj Object to initialize @@ -124,6 +132,7 @@ static void gtk_graph_view_init(GtkGraphView *obj) /* Create new GTK GL_Area as only child of the box */ priv->gl_area = gtk_gl_area_new(); g_signal_connect(priv->gl_area, "render", G_CALLBACK(gl_render), obj); + g_signal_connect(priv->gl_area, "realize", G_CALLBACK(gl_area_realize), obj); gtk_container_add(GTK_CONTAINER(obj), priv->gl_area); gtk_box_set_child_packing(GTK_BOX(obj), priv->gl_area, TRUE, TRUE, 0, GTK_PACK_START); gtk_widget_show(priv->gl_area);