Ejemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (this.exampleBase == null)
            {
                base.OnPaint(e);
                return;
            }
            if (!_useGdiPlusOutput)
            {
                exampleBase.Draw(painter);

                Graphics g         = e.Graphics;
                IntPtr   displayDC = g.GetHdc();
                bitmapBackBuffer.UpdateToHardwareSurface(displayDC);
                g.ReleaseHdc(displayDC);
            }
            else
            {
                exampleBase.Draw(painter);
                Graphics g         = e.Graphics;
                IntPtr   displayDC = g.GetHdc();

                sx.RenderTo(displayDC, 0, 0, new PixelFarm.Drawing.Rectangle(0, 0, bufferBmpRect.Width, bufferBmpRect.Height));
                g.ReleaseHdc(displayDC);
            }
            base.OnPaint(e);
        }
Ejemplo n.º 2
0
 protected override void RenderClientContent(DrawBoard d, UpdateArea updateArea)
 {
     //****
     //because our demo may run the 'manual GL code',
     //(out of state-control of the shader share resource/ current program/ render tree/
     //***
     _painter.DetachCurrentShader();
     _demo.Draw(_painter);
 }
Ejemplo n.º 3
0
 public override void CustomDrawToThisCanvas(DrawBoard canvas, Rectangle updateArea)
 {
     //****
     //because our demo may run the 'manual GL code',
     //(out of state-control of the shader share resource/ current program/ render tree/
     //***
     _painter.DetachCurrentShader();
     _demo.Draw(_painter);
 }
Ejemplo n.º 4
0
 protected override void OnPaint(PaintEventArgs e)
 {
     if (this.exampleBase == null)
     {
         base.OnPaint(e);
         return;
     }
     if (!_useGdiPlusOutput)
     {
         exampleBase.Draw(painter);
         bitmapBackBuffer.UpdateToHardwareSurface(e.Graphics);
     }
     else
     {
         UpdateOutput();
     }
     base.OnPaint(e);
 }
Ejemplo n.º 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (this.exampleBase == null)
            {
                base.OnPaint(e);
                return;
            }
            if (!_useGdiPlusOutput)
            {
                exampleBase.Draw(painter);

                Graphics g         = e.Graphics;
                IntPtr   displayDC = g.GetHdc();
                bitmapBackBuffer.UpdateToHardwareSurface(displayDC);
                g.ReleaseHdc(displayDC);
            }
            else
            {
                UpdateOutput();
            }
            base.OnPaint(e);
        }
Ejemplo n.º 6
0
 protected override void OnPaint(PaintEventArgs e)
 {
     if (this.exampleBase == null)
     {
         base.OnPaint(e);
         return;
     }
     //--------------------------------
     exampleBase.Draw(gfx);
     //--------------------------------
     bitmapBackBuffer.UpdateToHardwareSurface(e.Graphics);
     //--------------------------------
     base.OnPaint(e);
 }
Ejemplo n.º 7
0
            public override void CustomDrawToThisCanvas(DrawBoard canvas, Rectangle updateArea)
            {
                //

                //TODO: review here again
                //in pure agg, we could bypass the cache/resolve process
                //and render directly to the target canvas
                //
                //if img changed then clear cache and render again
                MemBitmap.ClearCache(_memBmp);
                MemBitmap.SetCacheInnerImage(_memBmp, _nativeWin32DC, false);//** set to false because the (life-time) owner of the dc is this class (not the memBmp)
                _demo.Draw(_painter);
                //copy from actual image and paint to canvas
                canvas.DrawImage(_memBmp, 0, 0);
            }
Ejemplo n.º 8
0
 void HandleGLPaint(object sender, System.EventArgs e)
 {
     canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
     canvas2d.StrokeColor = PixelFarm.Drawing.Color.Black;
     canvas2d.ClearColorBuffer();
     //example
     canvasPainter.FillColor = PixelFarm.Drawing.Color.Black;
     canvasPainter.FillRectLBWH(20, 20, 150, 150);
     //load bmp image
     //-------------------------------------------------------------------------
     if (exampleBase != null)
     {
         exampleBase.Draw(canvasPainter);
     }
     miniGLControl.SwapBuffers();
 }
Ejemplo n.º 9
0
 void HandleGLPaint(object sender, System.EventArgs e)
 {
     _glsx.SmoothMode  = SmoothMode.Smooth;
     _glsx.StrokeColor = PixelFarm.Drawing.Color.Black;
     _glsx.ClearColorBuffer();
     //example
     canvasPainter.FillColor = PixelFarm.Drawing.Color.Black;
     canvasPainter.FillRect(20, 20, 150, 150);
     //load bmp image
     //-------------------------------------------------------------------------
     if (demobase != null)
     {
         demobase.Draw(canvasPainter);
     }
     glControl.SwapBuffers();
 }
Ejemplo n.º 10
0
        public void LoadExample(DemoBase demoBase)
        {
            _glControl.MakeCurrent();

            _demoBase = demoBase;
            demoBase.Init();

            if (WithGdiPlusDrawBoard)
            {
                _bridgeUI = new GdiOnGLESUIElement(_myWidth, _myHeight);
            }
            else
            {
                //pure agg's cpu blit
                _bridgeUI = new CpuBlitGLESUIElement(_myWidth, _myHeight);
            }
            //
            _bridgeUI.SetUpdateCpuBlitSurfaceDelegate((p, updateArea) => _demoBase.Draw(p));

            DemoBase.InvokePainterReady(_demoBase, _bridgeUI.GetAggPainter());
            //
            //use existing GLRenderSurface and GLPainter
            //see=>UISurfaceViewportControl.InitRootGraphics()

            GLPainterContext pcx       = _surfaceViewport.GetGLRenderSurface();
            GLPainter        glPainter = _surfaceViewport.GetGLPainter();

            _bridgeUI.CreatePrimaryRenderElement(pcx, glPainter, _rootGfx);
            //-----------------------------------------------
            demoBase.SetEssentialGLHandlers(
                () => _glControl.SwapBuffers(),
                () => _glControl.GetEglDisplay(),
                () => _glControl.GetEglSurface()
                );
            //-----------------------------------------------
            DemoBase.InvokeGLPainterReady(demoBase, pcx, glPainter);
            //Add to RenderTree
            _rootGfx.AddChild(_bridgeUI.GetPrimaryRenderElement(_rootGfx));
            //-----------------------------------------------
            //***
            GeneralEventListener genEvListener = new GeneralEventListener();

            genEvListener.MouseDown += e =>
            {
                _demoBase.MouseDown(e.X, e.Y, e.Button == UIMouseButtons.Right);
                _bridgeUI.InvalidateGraphics();
            };
            genEvListener.MouseMove += e =>
            {
                if (e.IsDragging)
                {
                    _bridgeUI.InvalidateGraphics();
                    _demoBase.MouseDrag(e.X, e.Y);
                    _bridgeUI.InvalidateGraphics();
                }
            };
            genEvListener.MouseUp += e =>
            {
                _demoBase.MouseUp(e.X, e.Y);
            };
            //-----------------------------------------------
            _bridgeUI.AttachExternalEventListener(genEvListener);
        }