This makes the normal constructor thread-safe so they don't need to be
created from a callback, the same should eventually be done for the icon
markers.
marker->label = g_strdup(label);
marker->label = g_strdup(label);
marker->outline = 2;
marker->radius = 3;
marker->outline = 2;
marker->radius = 3;
/* this is the surface size, a guess really */
marker->width = marker->icon_width + 128;
marker->height = marker->icon_height + 64;
/* this is the surface size, a guess really */
marker->width = marker->icon_width + 128;
marker->height = marker->icon_height + 64;
marker->yoff = marker->height/2;
marker->cairo = cairo_create(cairo_image_surface_create(
CAIRO_FORMAT_ARGB32, marker->width, marker->height));
marker->yoff = marker->height/2;
marker->cairo = cairo_create(cairo_image_surface_create(
CAIRO_FORMAT_ARGB32, marker->width, marker->height));
/* clear the surface just in case */
cairo_set_operator(marker->cairo, CAIRO_OPERATOR_SOURCE);
//cairo_set_source_rgba(marker->cairo, 1.0, 0.0, 0.0, 0.3); // debug
/* clear the surface just in case */
cairo_set_operator(marker->cairo, CAIRO_OPERATOR_SOURCE);
//cairo_set_source_rgba(marker->cairo, 1.0, 0.0, 0.0, 0.3); // debug
gdouble width = cairo_image_surface_get_width(surface);
gdouble height = cairo_image_surface_get_height(surface);
gdouble width = cairo_image_surface_get_width(surface);
gdouble height = cairo_image_surface_get_height(surface);
+ if (!marker->tex)
+ render_all(marker);
+
if (marker->ortho) {
gdouble px, py, pz;
grits_viewer_project(GRITS_VIEWER(opengl),
if (marker->ortho) {
gdouble px, py, pz;
grits_viewer_project(GRITS_VIEWER(opengl),
{
//g_debug("GritsMarker: finalize - %s", marker->label);
GritsMarker *marker = GRITS_MARKER(_marker);
{
//g_debug("GritsMarker: finalize - %s", marker->label);
GritsMarker *marker = GRITS_MARKER(_marker);
- glDeleteTextures(1, &marker->tex);
- cairo_surface_t *surface = cairo_get_target(marker->cairo);
- cairo_surface_destroy(surface);
- cairo_destroy(marker->cairo);
+ if (marker->tex)
+ glDeleteTextures(1, &marker->tex);
+ if (marker->cairo) {
+ cairo_surface_t *surface = cairo_get_target(marker->cairo);
+ cairo_surface_destroy(surface);
+ cairo_destroy(marker->cairo);
+ }
- glDeleteTextures(1, &marker->tex);
}
static void grits_marker_class_init(GritsMarkerClass *klass)
}
static void grits_marker_class_init(GritsMarkerClass *klass)
gint xoff, yoff; /* center point offset */
gint icon_width, icon_height; /* size of icon for offsets */
gchar *label;
gint xoff, yoff; /* center point offset */
gint icon_width, icon_height; /* size of icon for offsets */
gchar *label;
cairo_t *cairo;
guint tex;
gboolean ortho;
cairo_t *cairo;
guint tex;
gboolean ortho;