luca-piccioni / OpenGL.Net

Modern OpenGL bindings for C#.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gl.Frustum funtion is not working.

akamotaco opened this issue · comments

Hi,
I am trying to make a simple program with OpenGL.Net (0.7.1) and dotnet core (2.1.4).
In the my program, Gl.Ortho is working but Gl.Frustum is not.
How can I solve the problem?
Here is the error message and my codes.

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at OpenGL.Gl.Frustum(Single left, Single right, Single bottom, Single top, Single near, Single far) in C:\OpenGL.Net\OpenGL.Net\Gl.VERSION_ES_CM_1_0.cs:line 111
at opengl.Program.Render(Singleton instance, NativeWindowEventArgs e) in

Gl.Clear(ClearBufferMask.ColorBufferBit);
Gl.ClearDepth(1.0f);

Gl.MatrixMode(MatrixMode.Projection);
Gl.LoadIdentity();
// Gl.Ortho(0.0, 1.0f, 0.0, 1.0, 0.0, 1.0); // working
Gl.Frustum(-1,1, -1, 1, 10, 100); // not working
Gl.MatrixMode(MatrixMode.Modelview);
Gl.LoadIdentity();

Gl.Begin(PrimitiveType.Triangles);
Gl.Color3(1.0f, 0.0f, 0.0f); Gl.Vertex2(0.0f, 0.0f);
Gl.Color3(0.0f, 1.0f, 0.0f); Gl.Vertex2(0.5f, 1.0f);
Gl.Color3(0.0f, 0.0f, 1.0f); Gl.Vertex2(1.0f, 0.0f);
Gl.End();

Use the override with the double floating-point arguments: the one with single floating-point that you're using is for GLES 1 only.

See the wiki/common mistake.