Skip to content

Commit

Permalink
Corrected pixel ratio calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Visual-Vincent committed Feb 14, 2022
1 parent 681091a commit 551d0c6
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions Test/TestWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public TestWindow(GameWindowSettings gameWindowSettings, NativeWindowSettings na
NVGcontext vg;
DemoData demoData;

float pixelRatio;
bool blowup = false;

protected override void OnLoad()
Expand Down Expand Up @@ -54,15 +53,9 @@ protected override void OnResize(ResizeEventArgs e)
{
base.OnResize(e);
GL.Viewport(0, 0, e.Width, e.Height);

if(e.Width >= e.Height)
pixelRatio = ClientSize.X / ClientSize.Y;
else
pixelRatio = ClientSize.Y / ClientSize.X;

}

protected override void OnRenderFrame(FrameEventArgs e)
protected unsafe override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);

Expand All @@ -72,7 +65,9 @@ protected override void OnRenderFrame(FrameEventArgs e)
GL.ClearColor(0.3f, 0.3f, 0.3f, 1.0f);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);

vg.BeginFrame(ClientSize.X, ClientSize.Y, pixelRatio);
GLFW.GetFramebufferSize(this.WindowPtr, out int fbWidth, out int fbHeight);

vg.BeginFrame(ClientSize.X, ClientSize.Y, fbWidth / (float)ClientSize.X);

DrawFps(vg, e);
NVGDemo.renderDemo(vg, MouseState.X, MouseState.Y, ClientSize.X, ClientSize.Y, (float)GLFW.GetTime(), blowup, demoData);
Expand Down

0 comments on commit 551d0c6

Please sign in to comment.