From: Barak Itkin Date: Sat, 5 May 2012 14:32:37 +0000 (+0300) Subject: Fix some small compilation errors X-Git-Tag: p2tc-0.1.0~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=11fc8110f25061aa740f40d99f1cab2e45391a42;p=poly2tri-c Fix some small compilation errors --- diff --git a/bin/main.c b/bin/main.c index 5bceab1..68c02f3 100755 --- a/bin/main.c +++ b/bin/main.c @@ -163,6 +163,21 @@ read_points_file (const gchar *path, #define P2TC_MAX_PATH PATH_MAX #endif +/* Calculate a "deterministic random" color for each point + * based on its memory address. Since we know that least-significant bytes + * of the point address will change more than the mor-important ones, we + * make sure to take them into consideration in all the color channels. + */ +static void +test_point_to_color (P2trPoint* point, gfloat *dest, gpointer user_data) +{ + gulong value = (gulong) point; + guchar b1 = value & 0xff, b2 = (value & 0xff00) >> 2, b3 = (value & 0xff0000) >> 4; + dest[0] = b1 / 255.0f; + dest[1] = (b1 ^ b2) / 255.0f; + dest[2] = (b1 ^ b2 ^ b3) / 255.0f; +} + gint main (int argc, char *argv[]) { FILE *out; @@ -244,7 +259,7 @@ gint main (int argc, char *argv[]) im = g_new (gfloat, imc.cpp * imc.x_samples * imc.y_samples); - p2tr_mesh_render_scanline (dt->mesh->mesh, im, &imc, p2tr_test_point_to_color, NULL); + p2tr_mesh_render_scanline (dt->mesh->mesh, im, &imc, test_point_to_color, NULL); p2tr_write_ppm (out, im, &imc); fclose (out); diff --git a/render/svg-plot.c b/render/svg-plot.c index f056de6..6f12fcd 100755 --- a/render/svg-plot.c +++ b/render/svg-plot.c @@ -119,7 +119,7 @@ void p2tr_plot_svg_plot_triangle (P2trTriangle *self, const gchar* color, FILE* outfile) { P2trCircle c; - p2tr_triangle_circumcircle (self, &c); + p2tr_triangle_get_circum_circle (self, &c); p2tr_plot_svg_plot_edge (self->edges[0], color, outfile); p2tr_plot_svg_plot_edge (self->edges[1], color, outfile); p2tr_plot_svg_plot_edge (self->edges[2], color, outfile); @@ -135,7 +135,7 @@ p2tr_plot_svg (P2trMesh *T, FILE *outfile) P2trHashSetIter siter; P2trTriangle *tr; - p2tr_debug ("Starting to write SVG output\n"); + g_debug ("Starting to write SVG output\n"); p2tr_plot_svg_plot_init (outfile); p2tr_hash_set_iter_init (&siter, T->triangles); @@ -143,5 +143,5 @@ p2tr_plot_svg (P2trMesh *T, FILE *outfile) p2tr_plot_svg_plot_triangle (tr, "black", outfile); p2tr_plot_svg_plot_end (outfile); - p2tr_debug ("Finished writing SVG output\n"); -} \ No newline at end of file + g_debug ("Finished writing SVG output\n"); +}