protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
Matrix4 modelview = Matrix4.LookAt(0, 0, 1,
0, 0, 0,
0, 1, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref modelview);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, 320, 0, 480, 1, 2);
GL.Begin(BeginMode.Quads);
GL.Color3(0f, .8f, 0f);
GL.Vertex2(0, 10);
GL.Vertex2(10, 10);
GL.Vertex2(10, 0);
GL.Vertex2(0, 0);
GL.End();
SwapBuffers();
}
My understanding of the LootAt function's call is that afterwards my camera would be floating one unit above the origin looking straight down at the origin. So when I first rendered my green square I expected it to be near the center of my window since that is where the origin is (one of its vertexes is (0,0)). But it wasn't, it was in the lower left corner window. So then I thought maybe that because of the calls to LoadIdentity and Orthoro all vertices would be rendered in terms of an offset to the lower left hand corner of my window and that the concepts of my eye and the camera would no longer apply. However, if I place my eye's starting coordinates at say (2,2) the green square appears to translate. So that makes me think the eye/camera concept still applies.
So now I'm just confused...
Can you explain to me what is going on?
Thanks
If you set the Projection matrix to an orthographic one(GL.Ortho) it will render everything to the screen space dictated by the parameters:
(left, right, bottom, top, nearVal, farVal);
Your screen is probably larger than this area so this will be the bottom left of the screen, it renders what the camera can see to this square. I'm geussing the camera can only see that green square and that when you translate the square it goes outside the camera view so isn't drawn fully inside this area.
If you wanted to draw to the middle of the screen you could move the viewport by changing the parameters.