Esempio n. 1
0
        private void GlControlPaint(object sender, PaintEventArgs e)
        {
            if (!_loaded)
            {
                GL.ClearColor(Color4.LightSteelBlue);
                GL.Clear(ClearBufferMask.ColorBufferBit);
            }

            else if (!_bound)
            {
                GL.ClearColor(Color4.SteelBlue);
                GL.Clear(ClearBufferMask.ColorBufferBit);
            }

            else if (_screenCap)
            {
                _screenCap = false;
                SuspendLayout();

                _graph.HideUI();
                Size tmp = glControl.Size;
                glControl.Size = new Size(2000, 750);
                CanvasManager.ChangeViewportSize(glControl.Size);

                GL.ClearColor(Color4.White);
                GL.Clear(ClearBufferMask.ColorBufferBit);
                _graph.DrawGraph();

                Bitmap     bmp  = new Bitmap(glControl.Width, this.glControl.Height);
                BitmapData data =
                    bmp.LockBits(glControl.ClientRectangle, ImageLockMode.WriteOnly,
                                 System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                GL.Finish();
                GL.ReadPixels(0, 0, this.glControl.Width, this.glControl.Height, PixelFormat.Bgr, PixelType.UnsignedByte, data.Scan0);
                bmp.UnlockBits(data);
                bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
                bmp.Save(_screenCapFile, ImageFormat.Png);

                glControl.Size = tmp;
                CanvasManager.ChangeViewportSize(glControl.Size);
                _graph.ShowUI();

                ResumeLayout();
            }
            else
            {
                GL.ClearColor(Color4.White);
                GL.Clear(ClearBufferMask.ColorBufferBit);
                _graph.DrawGraph();
            }
            glControl.SwapBuffers();
        }
        // Penguin
        private void GlcontrolOnPaint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            this.glcontrol.MakeCurrent();

            GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Projection);
            GL.LoadIdentity();
            float halfWidth  = (float)(this.glcontrol.Width / 2);
            float halfHeight = (float)(this.glcontrol.Height / 2);

            GL.Ortho(-halfWidth, halfWidth, halfHeight, -halfHeight, 1000, -1000);
            GL.Viewport(this.glcontrol.Size);

            this.renderer.Render();

            GL.Finish();

            this.glcontrol.SwapBuffers();

            this.frames++;
        }