MainView.MakeCurrent(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Viewport(0, 0, MainView.Width, MainView.Height); GL.LoadIdentity(); GL.Translate(0f, 0f, -6f); GL.Begin(BeginMode.Triangles); //GL.Color3(255, 0, 0); GL.Vertex3(0f, 1f, 0f); //GL.Color3(0, 255, 0); GL.Vertex3(-1f, -1f, 0f); //GL.Color3(0, 0, 255); GL.Vertex3(1f, -1f, 0f); GL.End(); MainView.SwapBuffers();
this code snippet is executed every timer tick. there is no other pre initialization of the control, except the code written by the designer. the resulting window becomes black and i can't see the triangle. i guess something with the GL.Translate is wrong. however, i wrote simple opengl programs years ago and *never* had such mistakes.
my second step was to check the "QuickStart" example. it works just fine as long i don't change the commands in OnResize and OnRenderFrame to something near my above example. i found some crazy matrix things in QuickStart:
Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, Width / (float)Height, 1.0f, 64.0f); GL.MatrixMode(MatrixMode.Projection); GL.LoadMatrix(ref projection);
Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelview);
i'm pretty sure, that my above posted code snippet can run somehow without all this matrix stuff. at least it did years ago.
does anyone see my mistake? it must be something very simple which i didn't see the last 5 hours.