我正在为freeglut制作一个c#包装器,它一直顺利进行直到遇到问题。
nativeGL.cpp:
extern "C"
{
FREEGLUTNATIVE_API void GL_DRAW_POLY(Vector2 *points, int count)
{
glBegin(GL_POLYGON);
glColor3b(0,255,255);
std::cout << count << " ";
for (int i = 0; i < count; i++)
{
//std::cout << points[i].x << " " << points[i].y << " ";
glVertex3d(points[i].x, points[i].y, 0);
}
std::cout << std::endl;
glEnd();
}
}
GL.cs:
public static class GL
{
[DllImport(dllName: "FREEGLUTNATIVE.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void GL_DRAW_POLY(Vector2[] points, int count);
public static void DrawPolygon(Vector2[] points) {
GL_DRAW_POLY(points, points.Length);
}
}
GL.CreateWindow等其他方法可以正常工作,但由于某种原因GL.DrawPolygon不起作用。 cout
ing工作并给出预期的输出,但窗口上没有任何内容。
PS。 这是一次学习经历