public void AddViewport(Viewport viewport) { // If the viewport doesn't have matrix, add this' by default if (!viewport.matrix_set) viewport.setMatrices(projMatrix, zoomMatrix); viewports.Add(viewport); }
private void openGLControl1_Layout(object sender, LayoutEventArgs e) { openGLControl1.viewports.Clear(); int w = openGLControl1.Width; int h = openGLControl1.Height; openGLControl1.default_viewport_size = new Rectangle(0, 0, 2 * w / 3, h); Matrix4 projMatrix = Matrix4.CreateOrthographicOffCenter(-10, 10, -10, 10, 0.5f, 100); Viewport up = new Viewport(2 * w / 3, 2 * h / 3, w / 3, h / 3); up.objects.AddRange(openGLControl1.objects); Matrix4 zoomMatrix = Matrix4.LookAt(new Vector3(0, 0, 10), new Vector3(0, 0.1f, 0), new Vector3(0, 0, 1)); up.setMatrices(projMatrix, zoomMatrix); openGLControl1.AddViewport(up); Viewport front = new Viewport(2 * w / 3, h / 3, w / 3, h / 3); front.objects.AddRange(openGLControl1.objects); zoomMatrix = Matrix4.LookAt(new Vector3(10, 0, 0), new Vector3(0, 0, 0), new Vector3(0, 0, 1)); front.setMatrices(projMatrix, zoomMatrix); openGLControl1.AddViewport(front); Viewport right = new Viewport(2 * w / 3, 0, w / 3, h / 3); right.objects.AddRange(openGLControl1.objects); zoomMatrix = Matrix4.LookAt(new Vector3(0, 10, 0), new Vector3(0, 0, 0), new Vector3(0, 0, 1)); right.setMatrices(projMatrix, zoomMatrix); openGLControl1.AddViewport(right); openGLControl1.Invalidate(); }