public void SetupViewProjection() { GL.Viewport( (int)_viewport[0], (int)_viewport[1], (int)_viewport[2], (int)_viewport[3]); GL.Scissor( (int)_viewport[0], (int)_viewport[1], (int)_viewport[2], (int)_viewport[3]); GL.ClearColor(BackgroundColor); GL.Enable(EnableCap.ScissorTest); GL.Clear(ClearBufferMask.ColorBufferBit); GL.Disable(EnableCap.ScissorTest); // Define the view matrix _viewMatrix = Matrix4.LookAt( new Vector3(_wcCenter[0], _wcCenter[1], 10f), new Vector3(_wcCenter[0], _wcCenter[1], 0f), new Vector3(0f, 1f, 0f)); // Define the project matrix float halfWCWidth = 0.5f * _wcWidth; float halfWCHeight = halfWCWidth * _viewport[3] / _viewport[2]; // viewportH/viewportW _projMatrix = Matrix4.CreateOrthographicOffCenter( -halfWCWidth, halfWCWidth, -halfWCHeight, halfWCHeight, _nearPlane, _farPlane); _vpMatrix = _viewMatrix * _projMatrix; }
public Screen(int width, int height, string title) : base(width, height, GraphicsMode.Default, title) { Children = new ArrayList(); projection = Matrix4.CreateOrthographicOffCenter(0.0f, width, 0.0f, height, 0.1f, 100.0f); }