GLUtessVertexProc
使用时在回调中随机遇到访问冲突异常GLUtessellator
,有人可以帮忙吗?非常感谢!这是主要代码:
public partial class Tessellation
{
[UnmanagedFunctionPointerAttribute(CallingConvention.StdCall)]
public delegate void GLUtessVertexProc(IntPtr data);
private List<Vector3> _buf = new List<Vector3>();
private static readonly GLUtessVertexProc tessVertex = data => {
double* dt = (double*)data;
//exception occur...
_buf.Add(new Vector3(dt[0], dt[1], dt[2]));
};
public List<Vector3> Tessellate(List<Vector3> outerBound)
{
_buf.Clear();
GLUtesselator tess = GLU.gluNewTess();
GLU.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, tessBegin);
GLU.gluTessCallback(tess, GLU.GLU_TESS_END, tessEnd);
GLU.gluTessCallback(tess, GLU.GLU_TESS_ERROR, tessError);
GLU.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, tessVertex);
GLU.gluTessCallback(tess, GLU.GLU_TESS_COMBINE, tessCombine);
GLU.gluTessCallback(tess, GLU.GLU_TESS_EDGE_FLAG, tessEdgeFlag);
GLU.gluTessProperty(tess, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_ODD);
GLU.gluTessBeginPolygon(tess, IntPtr.Zero);
//vertex data
GLU.gluTessEndPolygon(tess);
GLU.gluDeleteTess(tess);
return _buf.ToList();
}
}