
OpenTK.matrices
Posted Friday, 27 August, 2010 - 13:04 by hudrima1 inHi, I have a beginner question:
I changed the ImmediateMode.cs example to understand and test the OpenTK.Matrix4:
I found out that if I use:
OpenTK.Matrix4 r = OpenTK.Matrix4.CreateRotationY(angle);
OpenTK.Matrix4 t = OpenTK.Matrix4.CreateTranslation(1, 0, 0);
GL.MultMatrix(ref r);
GL.MultMatrix(ref t);
instead of:
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
GL.Translate(1, 0, 0);
The framerate is a lot higher. It looks like there is not VSync if I use GL.MultMatrix.
Why is this?
Another question is why do not have to use GL.MultTransposeMatrix?
The matrices r and t are row major matrices and should be first transposed before the can be postmultiplied on the column major matrix of OpenGL.
Regards
Marcus
Here the full example:
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Matrix4 lookat = Matrix4.LookAt(0, 5, 5, 0, 0, 0, 0, 1, 0); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref lookat); angle += 0.1f; OpenTK.Matrix4 r = OpenTK.Matrix4.CreateRotationY(angle); OpenTK.Matrix4 t = OpenTK.Matrix4.CreateTranslation(1, 0, 0); GL.MultMatrix(ref r); GL.MultMatrix(ref t); //GL.Rotate(angle, 0.0f, 1.0f, 0.0f); //GL.Translate(1, 0, 0); DrawCube(); this.SwapBuffers(); Thread.Sleep(1); }

