GhostTyper's picture

can't get nehe lession 2 working


i tried to follow the instructions of a simple tutorial () but failed. my code looks like:

GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Viewport(0, 0, MainView.Width, MainView.Height);
GL.Translate(0f, 0f, -6f);
//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);

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.LoadMatrix(ref projection);


Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY);
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.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
GhostTyper's picture

I'll solved the Problem. The color wasn't set, and therefore it didn't get visible. Years ago the color was automatically white. XD