]> Pileus Git - grits/blobdiff - src/gis-opengl.c
Avoid excess updates
[grits] / src / gis-opengl.c
index ba0f9139f22fab238c36452735fe89de795b27a1..8f03e8df4cc9c95f568877dfc2c1d7d7ce7ad625 100644 (file)
@@ -233,6 +233,9 @@ static void _draw_marker(GisOpenGL *opengl, GisMarker *marker)
        gis_viewer_project(GIS_VIEWER(opengl),
                        point->lat, point->lon, point->elev,
                        &px, &py, &pz);
+       gint win_width  = GTK_WIDGET(opengl)->allocation.width;
+       gint win_height = GTK_WIDGET(opengl)->allocation.height;
+       py = win_height - py;
        if (pz > 1)
                return;
 
@@ -244,8 +247,7 @@ static void _draw_marker(GisOpenGL *opengl, GisMarker *marker)
 
        glMatrixMode(GL_PROJECTION); glLoadIdentity();
        glMatrixMode(GL_MODELVIEW);  glLoadIdentity();
-       glOrtho(0, GTK_WIDGET(opengl)->allocation.width,
-               0, GTK_WIDGET(opengl)->allocation.height, -1, 1);
+       glOrtho(0, win_width, win_height, 0, -1, 1);
        glTranslated(px - marker->xoff,
                     py - marker->yoff, 0);
 
@@ -254,11 +256,12 @@ static void _draw_marker(GisOpenGL *opengl, GisMarker *marker)
        glDisable(GL_DEPTH_TEST);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, marker->tex);
+       glDisable(GL_CULL_FACE);
        glBegin(GL_QUADS);
-       glTexCoord2f(1, 1); glVertex3f(width, 0     , 0);
-       glTexCoord2f(1, 0); glVertex3f(width, height, 0);
-       glTexCoord2f(0, 0); glVertex3f(0    , height, 0);
-       glTexCoord2f(0, 1); glVertex3f(0    , 0     , 0);
+       glTexCoord2f(1, 0); glVertex3f(width, 0     , 0);
+       glTexCoord2f(1, 1); glVertex3f(width, height, 0);
+       glTexCoord2f(0, 1); glVertex3f(0    , height, 0);
+       glTexCoord2f(0, 0); glVertex3f(0    , 0     , 0);
        glEnd();
 }
 
@@ -462,9 +465,11 @@ static gboolean on_key_press(GisOpenGL *opengl, GdkEventKey *event, gpointer _)
        return FALSE;
 }
 
-static gboolean _update_errors_cb(gpointer sphere)
+static gboolean _update_errors_cb(gpointer _opengl)
 {
-       roam_sphere_update_errors(sphere);
+       GisOpenGL *opengl = _opengl;
+       roam_sphere_update_errors(opengl->sphere);
+       opengl->ue_source = 0;
        return FALSE;
 }
 static void on_view_changed(GisOpenGL *opengl,
@@ -473,8 +478,9 @@ static void on_view_changed(GisOpenGL *opengl,
        g_debug("GisOpenGL: on_view_changed");
        _set_visuals(opengl);
 #ifndef ROAM_DEBUG
-       opengl->ue_source = g_idle_add_full(G_PRIORITY_HIGH_IDLE+30,
-                       _update_errors_cb, opengl->sphere, NULL);
+       if (!opengl->ue_source)
+               opengl->ue_source = g_idle_add_full(G_PRIORITY_HIGH_IDLE+30,
+                               _update_errors_cb, opengl, NULL);
        //roam_sphere_update_errors(opengl->sphere);
 #endif
 }