Fixed Matrix4.CreatePerspectiveFieldOfView calls to use radians instead of degrees.

This commit is contained in:
the_fiddler 2009-08-15 17:52:49 +00:00
parent e24402487c
commit 28eec56fa5
8 changed files with 23 additions and 30 deletions

View file

@ -69,7 +69,7 @@ namespace Examples.Tutorial
double aspect_ratio = Width / (double)Height;
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(45, (float)aspect_ratio, 1, 64);
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perspective);
}

View file

@ -91,7 +91,7 @@ namespace Examples.Tutorial
double aspect_ratio = Width / (double)Height;
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(45, (float)aspect_ratio, 1, 64);
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perspective);
}

View file

@ -84,7 +84,7 @@ namespace Examples.Tutorial
GL.Viewport(0, 0, Width, Height);
float aspect_ratio = Width / (float)Height;
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(45, aspect_ratio, 1, 64);
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perpective);
}

View file

@ -78,7 +78,7 @@ namespace Examples.Tutorial
GL.Viewport(0, 0, Width, Height);
float aspect_ratio = Width / (float)Height;
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(45, aspect_ratio, 1, 64);
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perpective);
}

View file

@ -221,7 +221,7 @@ namespace Examples.Tutorial
double aspect_ratio = Width / (double)Height;
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(45, (float)aspect_ratio, 1, 64);
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perspective);

View file

@ -197,7 +197,7 @@ namespace Examples.Tutorial
GL.Viewport(0, 0, Width, Height);
float aspect_ratio = Width / (float)Height;
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(45, aspect_ratio, 1, 64);
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perpective);
}

View file

@ -34,10 +34,11 @@ using System.Threading;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.ES11;
#endregion
#if false
namespace Examples.Tutorial
{
[Example("Immediate mode", ExampleCategory.OpenGLES, "1.1", Documentation = "SimpleES11Window")]
@ -53,7 +54,7 @@ namespace Examples.Tutorial
#region --- Constructor ---
public SimpleES11Window()
: base(800, 600, new GraphicsMode(16, 16))
: base(800, 600, new GraphicsMode(16, 16), "", GameWindowFlags.Default, DisplayDevice.Default, 2, 0, GraphicsContextFlags.Embedded)
{ }
#endregion
@ -64,8 +65,9 @@ namespace Examples.Tutorial
{
base.OnLoad(e);
GL.ClearColor(Color.MidnightBlue);
GL.Enable(EnableCap.DepthTest);
Color color = Color.MidnightBlue;
GL.ClearColor(color.R, color.G, color.B, color.A);
GL.Enable((All)EnableCap.DepthTest);
}
#endregion
@ -85,17 +87,9 @@ namespace Examples.Tutorial
double aspect_ratio = Width / (double)Height;
GL.MatrixMode(MatrixMode.Projection);
if (Keyboard[OpenTK.Input.Key.Space])
{
OpenTK.Matrix4 perspective = OpenTK.Matrix4.Perspective(45, (float)aspect_ratio, 1, 64);
GL.LoadMatrix(ref perspective);
}
else
{
GL.LoadIdentity();
Glu.Perspective(45, (float)aspect_ratio, 1, 64);
}
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)aspect_ratio, 1, 64);
GL.MatrixMode((All)MatrixMode.Projection);
GL.LoadMatrix(ref perspective.Row0.X);
}
#endregion
@ -127,13 +121,11 @@ namespace Examples.Tutorial
/// </summary>
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Clear((uint)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
Glu.LookAt(0.0, 5.0, 5.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
Matrix4 lookat = Matrix4.LookAt(0, 5, 5, 0, 0, 0, 0, 1, 0);
GL.MatrixMode((All)MatrixMode.Modelview);
GL.LoadMatrix(ref lookat.Row0.X);
angle += rotation_speed * (float)e.Time;
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
@ -149,6 +141,7 @@ namespace Examples.Tutorial
private void DrawCube()
{
#if false
GL.Begin(BeginMode.Quads);
GL.Color3(Color.Silver);
@ -189,6 +182,7 @@ namespace Examples.Tutorial
GL.Vertex3(1.0f, -1.0f, 1.0f);
GL.End();
#endif
}
#endregion
@ -201,7 +195,7 @@ namespace Examples.Tutorial
[STAThread]
public static void Main()
{
using (T03_Immediate_Mode_Cube example = new T03_Immediate_Mode_Cube())
using (SimpleES11Window example = new SimpleES11Window())
{
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
@ -211,4 +205,3 @@ namespace Examples.Tutorial
#endregion
}
}
#endif

View file

@ -106,7 +106,7 @@ namespace Examples.WinForms
GL.Viewport(0, 0, c.ClientSize.Width, c.ClientSize.Height);
float aspect_ratio = Width / (float)Height;
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(45, aspect_ratio, 1, 64);
Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref perpective);
}