private void GlControlLoad(object sender, EventArgs e) { GL.ClearColor(1, 1, 1, 1); GL.Viewport(0, 0, glControl.Width, glControl.Height); GL.ShadeModel(ShadingModel.Smooth); GL.Hint(HintTarget.PolygonSmoothHint, HintMode.Nicest); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); _graph = new CaptureGraph(); _loaded = true; }
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(); }
public void SetBackgroundColor(float r, float g, float b) { GL.ClearColor(new Color4(r, g, b, 1)); }