public void SetViewport(ViewportSizing sizing) { SetViewport(sizing, 1.0f); }
public void SetViewport(ViewportSizing sizing, double scale) { GL.Viewport(0, 0, Window.Width, Window.Height); GL.LoadIdentity(); double x, y, w, h; switch (sizing) { // todo: consideration to sampling origin stuff. case ViewportSizing.Pixels: default: x = 0.0d; y = 0.0d; w = Window.Width / scale; h = Window.Height / scale; break; case ViewportSizing.Unit: x = 0.0d; y = 0.0d; w = scale; h = scale; break; case ViewportSizing.GreaterUnit: if (Window.Width > Window.Height) { x = 0.0d; y = 0.0d; w = 1.0d / scale; h = Window.Height / scale / Window.Width; } else { x = 0.0d; y = 0.0d; w = Window.Width / scale / Window.Height; h = 1.0d / scale; } break; case ViewportSizing.LesserUnit: if (Window.Width > Window.Height) { x = 0.0d; y = 0.0d; w = Window.Width / scale / Window.Height; h = 1.0d / scale; } else { x = 0.0d; y = 0.0d; w = 1.0d / scale; h = Window.Height / scale / Window.Width; } break; } GL.Ortho(x, w - x, h - y, y, DEPTH_MIN, DEPTH_MAX); }