sorry, full code given here…
public static void tesselate(Vector<double[][]> rings, GLU glu) {
// this turns rings into gl primitives.
System.out.println("new Tess!");
GLUtesselator tess = glu.gluNewTess();
glu.gluTessProperty(tess,GLU.GLU_TESS_BOUNDARY_ONLY,GLU.GLU_FALSE);
glu.gluTessProperty(tess,GLU.GLU_TESS_WINDING_RULE,GLU.GLU_TESS_WINDING_ODD);
//set up the call back.
TessCallback callBack = new TessCallback(glu);
glu.gluTessCallback(tess,GLU.GLU_TESS_BEGIN,callBack);
glu.gluTessCallback(tess,GLU.GLU_TESS_VERTEX,callBack);
glu.gluTessCallback(tess,GLU.GLU_TESS_END,callBack);
glu.gluTessCallback(tess,GLU.GLU_TESS_ERROR,callBack);
// load the data into the glu.
glu.gluBeginPolygon(tess);
for (double[][] ring:rings) {
for (double[] coord:ring) {
double[] coord2 = new double[3];
coord2[0] = coord[0];
coord2[1] = coord[1];
coord2[2] = 0;
glu.gluTessVertex(tess,coord2,null);
}
glu.gluNextContour(tess,GLU.GLU_UNKNOWN);
}
glu.gluEndPolygon(tess);
//The callback should have been called a whole heap, we are done.
}
public static class TessCallback extends GLUtesselatorCallbackAdapter {
GLU glu;
public TessCallback(GLU glu) {
this.glu = glu;
}
public void vertex(Object obj) {
double[] coord = (double[]) obj;
if (coord!=null) {
System.out.println("Tess - vertex (" + coord[0] + "," + coord[1] + ")");
} else {
System.out.println("Tess - null vertex");
}
}
public void error(int error) {
System.out.println("Tess - GLU TESS ERROR!!! - " + glu.gluErrorString(error));
}
public void end() {
System.out.println("Tess - end");
}
public void begin(int param) {
System.out.print("Tess - begin");
switch (param) {
case (GL.GL_TRIANGLE_FAN):
System.out.print(" FAN");
break;
case (GL.GL_TRIANGLE_STRIP):
System.out.print(" STRIP");
break;
case (GL.GL_TRIANGLES):
System.out.print(" TRIANGLES");
break;
default :
System.out.print(" ERROR -tess being not reconised");
}
System.out.println();
}
}
the output looks like…
new Tess!
Tess - begin FAN
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - end
Tess - begin STRIP
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - end
Tess - begin STRIP
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - end
Tess - begin TRIANGLES
Tess - null vertex
Tess - null vertex
Tess - null vertex
Tess - end
which is cool except for the vertexs being null.
Does anyone have any ideas whats I’m doing wrong?
— Blair (thanks for any help!)