Blit() public abstract method

Blit the rendered data to the supplied device context.
public abstract Blit ( IntPtr deviceContext ) : void
deviceContext System.IntPtr The HDC.
return void
Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            RenderContext renderContext = this.renderContext;

            if (renderContext == null)
            {
                base.OnPaint(e);
                return;
            }

            stopWatch.Reset();
            stopWatch.Start();

            //	Make sure it's our instance of openSharpGL that's active.
            renderContext.MakeCurrent();

            if (this.designMode)
            {
                try
                {
                    DesignModeRender();
                }
                catch (Exception)
                {
                }
            }
            else
            {
                //	If there is a draw handler, then call it.
                DoOpenGLDraw(e);
            }

            //	Blit our offscreen bitmap.
            Graphics graphics      = e.Graphics;
            IntPtr   deviceContext = graphics.GetHdc();

            renderContext.Blit(deviceContext);
            graphics.ReleaseHdc(deviceContext);

            stopWatch.Stop();

            {
                ErrorCode error = (ErrorCode)OpenGL.GetError();
                if (error != ErrorCode.NoError)
                {
                    Debug.WriteLine(string.Format("{0}: OpenGL error: {1}", this.fullname, error));
                }
            }

            this.FPS = 1000.0 / stopWatch.Elapsed.TotalMilliseconds;
        }
Esempio n. 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            RenderContext renderContext = this.renderContext;

            if (renderContext == null)
            {
                base.OnPaint(e);
                return;
            }

            stopWatch.Restart();

            //	Make sure it's our instance of openSharpGL that's active.
            renderContext.MakeCurrent();

            if (this.designMode)
            {
                // 天蓝色背景
                OpenGL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);

                GLCanvasHelper.ResizeGL(this.Width, this.Height);

                GLCanvasHelper.DrawPyramid();
            }
            else
            {
                //	If there is a draw handler, then call it.
                DoOpenGLDraw(e);
            }

            //	Blit our offscreen bitmap.
            Graphics graphics      = e.Graphics;
            IntPtr   deviceContext = graphics.GetHdc();

            renderContext.Blit(deviceContext);
            graphics.ReleaseHdc(deviceContext);

            stopWatch.Stop();

            this.FPS = 1000.0 / stopWatch.Elapsed.TotalMilliseconds;
        }