[retro-gtk/wip/aplazas/gl-display] Test



commit 642467ccf35c0f56ed393486a348813b56654c7c
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Nov 17 15:26:37 2017 +0100

    Test

 retro-gtk/retro-gl-display.c |   47 ++++++++++++++++++++---------------------
 1 files changed, 23 insertions(+), 24 deletions(-)
---
diff --git a/retro-gtk/retro-gl-display.c b/retro-gtk/retro-gl-display.c
index 872bfc5..b370c9a 100644
--- a/retro-gtk/retro-gl-display.c
+++ b/retro-gtk/retro-gl-display.c
@@ -176,14 +176,17 @@ retro_gl_display_draw_texture (RetroGLDisplay  *self,
 }
 
 static void
-retro_gl_display_realize (RetroGLDisplay *self)
+retro_gl_display_realize (GtkWidget *widget)
 {
   GLuint vertex_buffer_object;
   GLuint vertex_array_object;
   GLuint element_buffer_object;
   RetroVideoFilter filter;
+  RetroGLDisplay *self = (RetroGLDisplay *) widget;
   GError *inner_error = NULL;
 
+  GTK_WIDGET_CLASS (retro_gl_display_parent_class)->realize (widget);
+
   gtk_gl_area_make_current (GTK_GL_AREA (self));
 
   glGenBuffers (1, &vertex_buffer_object);
@@ -247,8 +250,9 @@ retro_gl_display_realize (RetroGLDisplay *self)
 }
 
 static void
-retro_gl_display_unrealize (RetroGLDisplay *self)
+retro_gl_display_unrealize (GtkWidget *widget)
 {
+  RetroGLDisplay *self = (RetroGLDisplay *) widget;
   RetroVideoFilter filter;
 
   gtk_gl_area_make_current (GTK_GL_AREA (self));
@@ -259,11 +263,15 @@ retro_gl_display_unrealize (RetroGLDisplay *self)
   self->texture = 0;
   for (filter = 0; filter < RETRO_VIDEO_FILTER_COUNT; filter++)
     g_clear_object (&self->glsl_filter[filter]);
+
+  GTK_WIDGET_CLASS (retro_gl_display_parent_class)->unrealize (widget);
 }
 
 static gboolean
-retro_gl_display_render (RetroGLDisplay *self)
+retro_gl_display_render (GtkGLArea    *glarea,
+                        GdkGLContext *context)
 {
+  RetroGLDisplay *self = (RetroGLDisplay *) glarea;
   RetroVideoFilter filter;
 
   g_return_val_if_fail (self != NULL, FALSE);
@@ -373,11 +381,18 @@ static void
 retro_gl_display_class_init (RetroGLDisplayClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+  GtkGLAreaClass *glarea_class = GTK_GL_AREA_CLASS (klass);
 
   object_class->finalize = retro_gl_display_finalize;
   object_class->get_property = retro_gl_display_get_property;
   object_class->set_property = retro_gl_display_set_property;
 
+  widget_class->realize = retro_gl_display_realize;
+  widget_class->unrealize = retro_gl_display_unrealize;
+
+  glarea_class->render = retro_gl_display_render;
+
   properties[PROP_PIXBUF] =
     g_param_spec_object ("pixbuf",
                          "Pixbuf",
@@ -395,30 +410,12 @@ queue_draw (GObject    *sender,
             GParamSpec *pspec,
             gpointer    self)
 {
-  gtk_widget_queue_draw (GTK_WIDGET (self));
+  gtk_gl_area_queue_render (self);
 }
 
 static void
 retro_gl_display_init (RetroGLDisplay *self)
 {
-  g_signal_connect_object (G_OBJECT (self),
-                           "realize",
-                           (GCallback) retro_gl_display_realize,
-                           GTK_WIDGET (self),
-                           0);
-
-  g_signal_connect_object (G_OBJECT (self),
-                           "unrealize",
-                           (GCallback) retro_gl_display_unrealize,
-                           GTK_WIDGET (self),
-                           0);
-
-  g_signal_connect_object (G_OBJECT (self),
-                           "render",
-                           (GCallback) retro_gl_display_render,
-                           GTK_WIDGET (self),
-                           0);
-
   self->filter = RETRO_VIDEO_FILTER_SMOOTH;
 
   g_signal_connect_object (G_OBJECT (self),
@@ -519,7 +516,7 @@ retro_gl_display_set_pixbuf (RetroGLDisplay *self,
     self->pixbuf = g_object_ref (pixbuf);
     if (self->tick_id == 0)
       self->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (self),
-                                                    retro_gl_display_on_tick,
+                                                    (GtkTickCallback) retro_gl_display_on_tick,
                                                     self,
                                                     NULL);
   }
@@ -593,5 +590,7 @@ retro_gl_display_get_coordinates_on_display (RetroGLDisplay *self,
 RetroGLDisplay *
 retro_gl_display_new (void)
 {
-  return g_object_new (RETRO_TYPE_GL_DISPLAY, NULL);
+  return g_object_new (RETRO_TYPE_GL_DISPLAY,
+                       "auto-render", FALSE,
+                       NULL);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]