Search code examples
c#openglopentk

How to get the Polygon mode with OpenTK?


I'm setting the Polygon Mode like this in order to draw the wireframe:

GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Point);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);

I believe that there is a GL function that returns the Polygon mode, like this:

glGetIntegerv(GL_POLYGON_MODE, &polygonMode);

Does OpenTK offer something similar?


Solution

  • I managed to get the PolygonMode by using the GL.GetInteger function, as shown below:

        PolygonMode pm = (PolygonMode) GL.GetInteger(GetPName.PolygonMode);
        if (pm == PolygonMode.Line)
        {
            Console.WriteLine("LINE");
        }
    

    I didn't find it at first because I was trying to use GetIndexedPName instead of GetPName, so be careful in case you are not finding the PolygonMode constant.

    Thanks anyway for your help