OpenGL in Rhino 6

I use a Rhino.Display.DisplayConduit for both Rhino 5 and 6. In Rhino 5 it behaves completely fine like I would expect. I’m doing some OpenGL calls there and everything looks ok.

Now in Rhino 6 either I cannot see anything or it seems to break the whole visualization. I tried to draw a simple triangle which works in Rhino 5 but not in 6 using the following code:

GL.Color3(Color.Red);
GL.ColorMaterial(GLEnum.FrontAndBack, GLEnum.AmbientAndDiffuse);
GL.Enable(GLEnum.ColorMaterial);

GL.Begin(GLEnum.Triangles);

GL.Vertex3(0, 0, 0);
GL.Vertex3(0, 0, 100);
GL.Vertex3(0, 100, 0);

GL.End();

The GL calls are going to an OpenGL wrapper I provide myself.

When I try to draw more complex stuff I get this result:

Are there any changes to OpenGL support in Rhino 6? How can I solve this?

Rhino doesn’t use OpenGL state anymore since all drawing is shader based. You will need to set up your modelview and projection matrices first. Use the
DisplayPipeline.GetOpenGLWorldToCamera
to get the matrix for setting up your modelview matrix and

DisplayPipeline.GetOpenGLCameraToClip
to get the matrix for setting up your projection matrix

These functions will give you an array of 16 floats that you will then need to call GL.LoadMatrix with for two different GL matrices

That helped a lot, thank you!