{
g_debug("GisOpenGL: on_realize");
_set_visuals(self);
+ g_mutex_lock(self->sphere_lock);
roam_sphere_update_errors(self->sphere);
+ g_mutex_unlock(self->sphere_lock);
}
static gboolean on_configure(GisOpenGL *self, GdkEventConfigure *event, gpointer _)
{
gluPerspective(rad2deg(ang)*2, width/height, 1, 10*EARTH_R);
#ifndef ROAM_DEBUG
+ g_mutex_lock(self->sphere_lock);
roam_sphere_update_errors(self->sphere);
+ g_mutex_unlock(self->sphere_lock);
#endif
_gis_opengl_end(self);
//g_debug("GisOpenGL: on_idle");
gdk_threads_enter();
_gis_opengl_begin(self);
+ g_mutex_lock(self->sphere_lock);
if (roam_sphere_split_merge(self->sphere))
gtk_widget_queue_draw(GTK_WIDGET(self));
+ g_mutex_unlock(self->sphere_lock);
_gis_opengl_end(self);
gdk_threads_leave();
return TRUE;
if (!tile)
return;
/* TODO: get points? */
+ g_mutex_lock(self->sphere_lock);
GList *triangles = roam_sphere_get_intersect(self->sphere, TRUE,
tile->edge.n, tile->edge.s, tile->edge.e, tile->edge.w);
for (GList *cur = triangles; cur; cur = cur->next) {
}
}
g_list_free(triangles);
+ g_mutex_unlock(self->sphere_lock);
}
static void _gis_opengl_clear_height_func_rec(RoamTriangle *root)
self->objects = g_tree_new(_objects_cmp);
self->sphere = roam_sphere_new(self);
+ self->sphere_lock = g_mutex_new();
#ifndef ROAM_DEBUG
self->sm_source[0] = g_timeout_add_full(G_PRIORITY_HIGH_IDLE+30, 33, (GSourceFunc)on_idle, self, NULL);
{
g_debug("GisViewer: finalize");
GisOpenGL *self = GIS_OPENGL(_self);
+ g_mutex_free(self->sphere_lock);
G_OBJECT_CLASS(gis_opengl_parent_class)->finalize(_self);
}
static void gis_opengl_class_init(GisOpenGLClass *klass)
return g_list_prepend(list, tri);
}
}
+/* Warning: This grabs pointers to triangles which can be changed by other
+ * calls, e.g. split_merge. If you use this, you need to do some locking to
+ * prevent the returned list from becomming stale. */
GList *roam_sphere_get_intersect(RoamSphere *self, gboolean all,
gdouble n, gdouble s, gdouble e, gdouble w)
{