Fixed Matrix4.CreatePerspectiveFieldOfView calls to use radians instead of degrees.
This commit is contained in:
parent
e24402487c
commit
28eec56fa5
8 changed files with 23 additions and 30 deletions
|
@ -69,7 +69,7 @@ namespace Examples.Tutorial
|
||||||
|
|
||||||
double aspect_ratio = Width / (double)Height;
|
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.MatrixMode(MatrixMode.Projection);
|
||||||
GL.LoadMatrix(ref perspective);
|
GL.LoadMatrix(ref perspective);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace Examples.Tutorial
|
||||||
|
|
||||||
double aspect_ratio = Width / (double)Height;
|
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.MatrixMode(MatrixMode.Projection);
|
||||||
GL.LoadMatrix(ref perspective);
|
GL.LoadMatrix(ref perspective);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ namespace Examples.Tutorial
|
||||||
GL.Viewport(0, 0, Width, Height);
|
GL.Viewport(0, 0, Width, Height);
|
||||||
|
|
||||||
float aspect_ratio = Width / (float)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.MatrixMode(MatrixMode.Projection);
|
||||||
GL.LoadMatrix(ref perpective);
|
GL.LoadMatrix(ref perpective);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace Examples.Tutorial
|
||||||
GL.Viewport(0, 0, Width, Height);
|
GL.Viewport(0, 0, Width, Height);
|
||||||
|
|
||||||
float aspect_ratio = Width / (float)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.MatrixMode(MatrixMode.Projection);
|
||||||
GL.LoadMatrix(ref perpective);
|
GL.LoadMatrix(ref perpective);
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,7 @@ namespace Examples.Tutorial
|
||||||
|
|
||||||
double aspect_ratio = Width / (double)Height;
|
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.MatrixMode(MatrixMode.Projection);
|
||||||
GL.LoadMatrix(ref perspective);
|
GL.LoadMatrix(ref perspective);
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ namespace Examples.Tutorial
|
||||||
GL.Viewport(0, 0, Width, Height);
|
GL.Viewport(0, 0, Width, Height);
|
||||||
|
|
||||||
float aspect_ratio = Width / (float)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.MatrixMode(MatrixMode.Projection);
|
||||||
GL.LoadMatrix(ref perpective);
|
GL.LoadMatrix(ref perpective);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,11 @@ using System.Threading;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
using OpenTK.Graphics.ES11;
|
using OpenTK.Graphics.ES11;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#if false
|
|
||||||
namespace Examples.Tutorial
|
namespace Examples.Tutorial
|
||||||
{
|
{
|
||||||
[Example("Immediate mode", ExampleCategory.OpenGLES, "1.1", Documentation = "SimpleES11Window")]
|
[Example("Immediate mode", ExampleCategory.OpenGLES, "1.1", Documentation = "SimpleES11Window")]
|
||||||
|
@ -53,7 +54,7 @@ namespace Examples.Tutorial
|
||||||
#region --- Constructor ---
|
#region --- Constructor ---
|
||||||
|
|
||||||
public SimpleES11Window()
|
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
|
#endregion
|
||||||
|
@ -64,8 +65,9 @@ namespace Examples.Tutorial
|
||||||
{
|
{
|
||||||
base.OnLoad(e);
|
base.OnLoad(e);
|
||||||
|
|
||||||
GL.ClearColor(Color.MidnightBlue);
|
Color color = Color.MidnightBlue;
|
||||||
GL.Enable(EnableCap.DepthTest);
|
GL.ClearColor(color.R, color.G, color.B, color.A);
|
||||||
|
GL.Enable((All)EnableCap.DepthTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -85,17 +87,9 @@ namespace Examples.Tutorial
|
||||||
|
|
||||||
double aspect_ratio = Width / (double)Height;
|
double aspect_ratio = Width / (double)Height;
|
||||||
|
|
||||||
GL.MatrixMode(MatrixMode.Projection);
|
OpenTK.Matrix4 perspective = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)aspect_ratio, 1, 64);
|
||||||
if (Keyboard[OpenTK.Input.Key.Space])
|
GL.MatrixMode((All)MatrixMode.Projection);
|
||||||
{
|
GL.LoadMatrix(ref perspective.Row0.X);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -127,13 +121,11 @@ namespace Examples.Tutorial
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void OnRenderFrame(FrameEventArgs e)
|
protected override void OnRenderFrame(FrameEventArgs e)
|
||||||
{
|
{
|
||||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
GL.Clear((uint)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));
|
||||||
|
|
||||||
GL.MatrixMode(MatrixMode.Modelview);
|
Matrix4 lookat = Matrix4.LookAt(0, 5, 5, 0, 0, 0, 0, 1, 0);
|
||||||
GL.LoadIdentity();
|
GL.MatrixMode((All)MatrixMode.Modelview);
|
||||||
Glu.LookAt(0.0, 5.0, 5.0,
|
GL.LoadMatrix(ref lookat.Row0.X);
|
||||||
0.0, 0.0, 0.0,
|
|
||||||
0.0, 1.0, 0.0);
|
|
||||||
|
|
||||||
angle += rotation_speed * (float)e.Time;
|
angle += rotation_speed * (float)e.Time;
|
||||||
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
|
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
|
||||||
|
@ -149,6 +141,7 @@ namespace Examples.Tutorial
|
||||||
|
|
||||||
private void DrawCube()
|
private void DrawCube()
|
||||||
{
|
{
|
||||||
|
#if false
|
||||||
GL.Begin(BeginMode.Quads);
|
GL.Begin(BeginMode.Quads);
|
||||||
|
|
||||||
GL.Color3(Color.Silver);
|
GL.Color3(Color.Silver);
|
||||||
|
@ -189,6 +182,7 @@ namespace Examples.Tutorial
|
||||||
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||||
|
|
||||||
GL.End();
|
GL.End();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -201,7 +195,7 @@ namespace Examples.Tutorial
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
using (T03_Immediate_Mode_Cube example = new T03_Immediate_Mode_Cube())
|
using (SimpleES11Window example = new SimpleES11Window())
|
||||||
{
|
{
|
||||||
Utilities.SetWindowTitle(example);
|
Utilities.SetWindowTitle(example);
|
||||||
example.Run(30.0, 0.0);
|
example.Run(30.0, 0.0);
|
||||||
|
@ -211,4 +205,3 @@ namespace Examples.Tutorial
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
|
@ -106,7 +106,7 @@ namespace Examples.WinForms
|
||||||
GL.Viewport(0, 0, c.ClientSize.Width, c.ClientSize.Height);
|
GL.Viewport(0, 0, c.ClientSize.Width, c.ClientSize.Height);
|
||||||
|
|
||||||
float aspect_ratio = Width / (float)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.MatrixMode(MatrixMode.Projection);
|
||||||
GL.LoadMatrix(ref perpective);
|
GL.LoadMatrix(ref perpective);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue