1

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();
    }

}
4

1 回答 1

2

当我使用 dllimport 从 glu.dll 导入命令时,我遇到了和你一样的问题。我没有设法解决它。最后,我在这里找到了 GLU tesselation 的 C# 端口:https ://github.com/speps/LibTessDotNet ,我直接使用它而不是从 dll 导入。

这个库足以满足我的需求。它可能是您的一种解决方案。

于 2013-07-08T15:48:29.013 回答