I have some old code that i imported into an OpenTK C# application running on NET 5.0. The rendering uses old fashioned immediate mode and it works on my current computer but nothing renders in the new application. The old application was NET framework 4.7.2 and an older version of OpenTK. When creating the window i request the same OpenGL version as the older application uses.
Did OpenTK remove this functionality in the newer version?
This is code i used to test this:
using OpenTK.Graphics.OpenGL;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
using System;
using OpenTK.Mathematics;
namespace tktest2
{
public class Window : GameWindow
{
private float ClipNear = 0.2f;
private float ClipFar = 10000.0f;
public Matrix4 ProjectionMatrix;
public Matrix4 ViewMatrix;
public Window(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings)
: base(gameWindowSettings, nativeWindowSettings)
{
}
protected override void OnLoad()
{
base.OnLoad();
Console.WriteLine(GL.GetString(StringName.Vendor));
Console.WriteLine(GL.GetString(StringName.Renderer));
Console.WriteLine(GL.GetString(StringName.Version));
Console.WriteLine(GL.GetString(StringName.ShadingLanguageVersion));
GL.Enable(EnableCap.DepthTest);
GL.Disable(EnableCap.Texture2D);
GL.Disable(EnableCap.CullFace);
GL.Disable(EnableCap.Blend);
this.VSync = VSyncMode.On;
}
protected override void OnUnload()
{
base.OnUnload();
}
protected override void OnResize(ResizeEventArgs e)
{
base.OnResize(e);
ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, (float)Size.X / (float)Size.Y, ClipNear, ClipFar);
GL.Viewport(0, 0, Size.X, Size.Y);
}
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);
}
protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
ViewMatrix = Matrix4.LookAt(new Vector3(0, -5, 0), new Vector3(0, 0, 0), Vector3.UnitZ);
GL.Color4(1.0f, 1.0f, 1.0f, 1.0f);
GL.Normal3(Vector3.UnitZ);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref ProjectionMatrix);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref ViewMatrix);
GL.PointSize(10);
GL.Begin(BeginMode.Points);
for (int x = 0; x < 10; x++)
{
GL.Color3(1.0f, 1.0f, x / 10.0f);
GL.Vertex3(x / 10.0f, 0.0f, 0.0f);
}
GL.End();
SwapBuffers();
}
}
}