From b55b3e652b976ee311cfeab9ae2bea2b62c81fff Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 14 Aug 2010 21:15:42 +0000 Subject: [PATCH] Minor cleanup in the editor main code. --- src/gtk/editor.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/gtk/editor.cpp b/src/gtk/editor.cpp index 5130ef89..972b8d5d 100644 --- a/src/gtk/editor.cpp +++ b/src/gtk/editor.cpp @@ -50,18 +50,26 @@ static gboolean tick(void *widget) static gint init(GtkWidget *widget) { - /* OpenGL functions can be called only if make_current returns true */ if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) - { - Video::Setup(widget->allocation.width, - widget->allocation.height); - } + Video::Setup(widget->allocation.width, widget->allocation.height); + return TRUE; } +static gint reshape(GtkWidget *widget, GdkEventConfigure *event) +{ + (void)event; + + return init(widget); +} + static gint draw(GtkWidget *widget, GdkEventExpose *event) { - if (event->count == 0 && gtk_gl_area_make_current(GTK_GL_AREA(widget))) + if (event->count > 0) + return TRUE; + + /* OpenGL functions can be called only if make_current returns true */ + if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) { // FIXME: do not do anything if the game tick wasn't called? float const delta_time = 33.33333f; @@ -75,18 +83,6 @@ static gint draw(GtkWidget *widget, GdkEventExpose *event) return TRUE; } -static gint reshape(GtkWidget *widget, GdkEventConfigure *event) -{ - (void)event; - - if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) - { - Video::Setup(widget->allocation.width, - widget->allocation.height); - } - return TRUE; -} - int main(int argc, char **argv) { /* Initialize GTK */