Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ public static void Render(Rectangle ClientRectangle, int Width, int Height, GLCo
TriCount = 0;
VertexCount = 0;
GL.Viewport(ClientRectangle.X, ClientRectangle.Y, RenderPanel.Width, RenderPanel.Height);
projection = cam.GetViewMatrix() * Matrix4.CreatePerspectiveFieldOfView(1.0f, Width / (float)Height, 0.00000001f, 0.001f);
float aspectRatio = Width / (float)Height;
float aspectRatioY = 1.0f;
if (aspectRatio < aspectRatioY)
{
aspectRatioY = aspectRatioY / aspectRatio;
}
projection = cam.GetViewMatrix() * Matrix4.CreatePerspectiveFieldOfView(2.0f * (float)Math.Atan((float)Math.Tan(1.0f / 2.0f) / aspectRatioY), aspectRatio, 0.00000001f, 0.001f);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref projection);
InitialiseView();
Expand Down Expand Up @@ -115,7 +121,13 @@ public static void Render(Rectangle ClientRectangle, int Width, int Height, GLCo
public static void RenderColourBuffer(Rectangle ClientRectangle, int Width, int Height, GLControl RenderPanel)
{
GL.Viewport(ClientRectangle.X, ClientRectangle.Y, RenderPanel.Width, RenderPanel.Height);
projection = cam.GetViewMatrix() * Matrix4.CreatePerspectiveFieldOfView(1.0f, Width / (float)Height, 0.00000001f, 0.001f);
float aspectRatio = Width / (float)Height;
float aspectRatioY = 1.0f;
if (aspectRatio < aspectRatioY)
{
aspectRatioY = aspectRatioY / aspectRatio;
}
projection = cam.GetViewMatrix() * Matrix4.CreatePerspectiveFieldOfView(2.0f * (float)Math.Atan((float)Math.Tan(1.0f / 2.0f) / aspectRatioY), aspectRatio, 0.00000001f, 0.001f);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref projection);
InitialiseView();
Expand Down