
OpenGL programming guide example 1
Posted Tuesday, 16 March, 2010 - 16:20 by rakkarage in#include <whateverYouNeed.h> main() { InitializeAWindowPlease(); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); glBegin(GL_POLYGON); glVertex3f(0.25, 0.25, 0.0); glVertex3f(0.75, 0.25, 0.0); glVertex3f(0.75, 0.75, 0.0); glVertex3f(0.25, 0.75, 0.0); glEnd(); glFlush(); UpdateTheWindowAndCheckForEvents(); }
i am trying to make this first example from the red book work in opentk, i edited QuickStart and put that code in OnRenderFrame but does not seem to work... can anyone tell me what i am doing wrong? thanks
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); GL.ClearColor(Color.Black); GL.Color3(Color.White); GL.Clear(ClearBufferMask.ColorBufferBit); GL.Ortho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); GL.Begin(BeginMode.Polygon); GL.Vertex3(0.25, 0.25, 0.0); GL.Vertex3(0.75, 0.25, 0.0); GL.Vertex3(0.75, 0.75, 0.0); GL.Vertex3(0.25, 0.75, 0.0); GL.End(); SwapBuffers(); }


Comments
Re: OpenGL programming guide example 1
GL.Orthomultiplies the current matrix with a matrix representing an orthographic projection. In most cases, you need to reset your projection matrix before multiplying withGL.Ortho:Re: OpenGL programming guide example 1
thank you. that fixed it... but is this a difference between using OpenTK and not using it? the redbook omits that step because Projection matrix is identity by default? but in OpenTK its not?
thanks
Re: OpenGL programming guide example 1
No, this is the difference between:
and
OnRenderFrame in OpenTK is called in a loop. The main function in the redbook example is called only once. If you move to the later redbook examples, you'll see that they use LoadIdentity, too.
Re: OpenGL programming guide example 1
thanks :)