trying to fix the clipping bugs
[meshfrac] / main.c
diff --git a/main.c b/main.c
index 2218f45..258cbd5 100644 (file)
--- a/main.c
+++ b/main.c
@@ -116,12 +116,21 @@ static int init(void)
        glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 60);
 
        mesh = cmesh_alloc();
-       gen_torus(mesh, 2, 0.8, 24, 12, 1, 1);
+       //gen_torus(mesh, 2, 0.8, 24, 12, 1, 1);
+       //gen_sphere(mesh, 2, 12, 6, 1, 1);
+       gen_box(mesh, 2, 2, 2, 0, 0);
 
        if(frac_init(&frac) == -1) {
                return -1;
        }
        frac_mesh(&frac, mesh);
+       frac.cell_gap = 0.1;
+
+       //frac_gen_points(&frac, 16);
+       frac_point(&frac, -5, 0, 0);
+       frac_point(&frac, 5, 0, 0);
+       show_points = 1;
+       cur = 1;
 
        return 0;
 }
@@ -138,7 +147,7 @@ static void update(void)
                switch(cur) {
                case 0:
                        printf("Generate points...\n");
-                       if(frac_gen_points(&frac, 16) != -1) {
+                       if(frac_gen_points(&frac, 2) != -1) {
                                cur++;
                        } else {
                                pending = cur;
@@ -199,13 +208,16 @@ static void display(void)
        glMatrixMode(GL_MODELVIEW);
        glLoadMatrixf(view_mat);
 
+       bind_program(0);
+       glShadeModel(GL_FLAT);
+
        if(show_orig) {
-               bind_program(sdr);
+               //bind_program(sdr);
                cmesh_draw(mesh);
+               bind_program(0);
        }
        if(show_points) {
                num = frac_num_cells(&frac);
-               bind_program(0);
 
                glPushAttrib(GL_ENABLE_BIT);
                glDisable(GL_LIGHTING);
@@ -229,8 +241,6 @@ static void display(void)
        }
 
        if(show_planes) {
-               bind_program(0);
-
                glPushAttrib(GL_ENABLE_BIT);
                glDisable(GL_LIGHTING);
 
@@ -249,8 +259,9 @@ static void display(void)
        }
 
        if(show_shell) {
-               bind_program(sdr);
+               //bind_program(sdr);
                cmesh_draw(frac.cells[cur_cell].mesh);
+               bind_program(0);
        }
 
        assert(glGetError() == GL_NO_ERROR);