Hello,
i'm trying to use the tesselation of GLU but the callback functions are all correct but the vertex one that returns always null. I've tried to debug gluTessVertex and data seems to be loaded, if i change setting (one rettangle, than a rectangle with a hole) it gives different numbers of vertices and primitives. The code is this
GLUtessellatorImpl tess = new GLUtessellatorImpl();
TesselatorCallback callback = new TesselatorCallback();
tess.gluTessCallback(GLU.GLU_TESS_VERTEX, callback);
tess.gluTessCallback(GLU.GLU_TESS_BEGIN, callback);
tess.gluTessCallback(GLU.GLU_TESS_END,
tess.gluTessCallback(GLU.GLU_TESS_ERROR, callback);
tess.gluTessBeginPolygon(null);
tess.gluTessBeginContour();
double[] data = new double[4*3];
// p1
data[0] = 0;
data[1] = 0;
data[2] = 0;
// p2
data[3] = 0;
data[4] = 0;
data[5] = 100;
// p3
data[6] = 100;
data[7] = 0;
data[8] = 100;
// p4
data[9] = 100;
data[10] = 0;
data[11] = 0;
for(int i=0;i<4;i++)
{
tess.gluTessVertex(data, i*3, null);
}
tess.gluTessEndContour();
tess.gluTessEndPolygon();
tess.gluDeleteTess();
the callback class is this
public class TesselatorCallback implements GLUtessellatorCallback
{
@Override
public void begin(int type)
{
if(type == GL11.GL_TRIANGLES)
System.out.println("Tesselator: triangle");
else if(type == GL11.GL_TRIANGLE_FAN)
System.out.println("Tesselator: triangle fan");
else if(type == GL11.GL_TRIANGLE_STRIP)
System.out.println("Tesselator: triangle strip");
else
System.out.println("Tesselator: not handled primitive");
}
@Override
public void beginData(int type, Object polygonData)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void edgeFlag(boolean boundaryEdge)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void edgeFlagData(boolean boundaryEdge, Object polygonData)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void vertex(Object vertexData)
{
System.out.println(vertexData);
}
@Override
public void vertexData(Object vertexData, Object polygonData)
{
System.out.println(vertexData);
}
@Override
public void end()
{
System.out.println("Tesselation: end primitive");
}
@Override
public void endData(Object polygonData)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void combine(double[] coords, Object[] data, float[] weight, Object[] outData)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void combineData(double[] coords, Object[] data, float[] weight, Object[] outData, Object polygonData)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void error(int errnum)
{
System.out.println(System.out.format("Tesselation error: %d\n", errnum));
}
@Override
public void errorData(int errnum, Object polygonData)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}
I've tried to use GLUtessellatorCallbackAdapter but there's no difference, same as with the winding order (anyway something is returned with or without it).