]> Pileus Git - grits/commitdiff
Debugging and code formatting
authorAndy Spencer <andy753421@gmail.com>
Sat, 23 Jan 2010 19:25:41 +0000 (19:25 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 25 Jan 2010 09:29:11 +0000 (09:29 +0000)
examples/sorting/mkfile
examples/sorting/sort.c

index e65f26d264a1ca8b768424aa461bc625d38537fc..9e83961b6a09d6e52d69f6415fad6adcf2c10e9e 100644 (file)
@@ -1,7 +1,8 @@
 MKSHELL=/usr/lib/plan9/bin/rc
 PROGS=sort tes
-LIBS=`{pkg-config --libs gtkglext-1.0}
-CFLAGS=-Wall -g '--std=c99' `{pkg-config --cflags gtkglext-1.0}
+PKGS=gtkglext-1.0
 
-default:V: tes-run
+sort_cflags=-p -pg -O3
+
+default:V: sort-run
 <$HOME/lib/mkcommon
index 745e1fc28afe09c589fa32aee4f16eb0f4125bcf..9ad01fa376dd9df830d0c32bdc0f6f8453161214 100644 (file)
@@ -33,7 +33,7 @@ static gfloat *sort_start()
 static void sort_end(gfloat *data)
 {
        int vertsize = sizeof(vert_t)/sizeof(gfloat);
-       int count = glRenderMode(GL_RENDER);
+       int nvals = glRenderMode(GL_RENDER);
 
        /* Set up screen coords */
        gint view[4];
@@ -49,12 +49,12 @@ static void sort_end(gfloat *data)
 
        /* Sort the vertexes (this only works with all-triangles */
        int trisize = 2*sizeof(gfloat) + 3*sizeof(vert_t);
-       int ntris   = count / trisize;
+       int ntris   = nvals*sizeof(gfloat) / trisize;
        g_print("%d, %d, %d\n", sizeof(gfloat), trisize, ntris);
-       qsort(data, ntris*4, trisize, sort_cmp);
+       qsort(data, ntris, trisize, sort_cmp);
 
        /* Draw the data */
-       for (int i = 0; i < count;) {
+       for (int i = 0; i < nvals;) {
                gfloat token = data[i++];
                if (token == GL_POLYGON_TOKEN) {
                        gfloat n = data[i++];
@@ -84,6 +84,7 @@ static void sort_end(gfloat *data)
                        g_error("Unknown token: %f\n", token);
                }
        }
+       g_free(data);
 }
 
 static gboolean on_expose(GtkWidget *drawing, GdkEventExpose *event, gpointer _)