0

I'm working on making a c# wrapper for freeglut and it was going smoothly until I hit an issue.

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

Other methods work such as GL.CreateWindow and that works but for some reason GL.DrawPolygon doesn't work. the couting works and give the expected output, but nothing is appearing on the window.

PS. This is a learning experience

William
  • 21
  • 2
  • https://msdn.microsoft.com/en-us/library/bd99e6zt.aspx – Ray Jan 30 '18 at 17:13
  • its not the array that's messing up. if I uncomment the `std::cout << points[i].x << " " << points[i].y << " ";` I would get the expected result printed – William Jan 30 '18 at 18:09

0 Answers0