예제 #1
0
 protected override void OnGLRender(object sender, EventArgs args)
 {
     _glsx.SmoothMode  = SmoothMode.Smooth;
     _glsx.StrokeColor = PixelFarm.Drawing.Color.Blue;
     _glsx.Clear(PixelFarm.Drawing.Color.White);
     _glsx.ClearColorBuffer();
     //-------------------------------
     if (!isInit)
     {
         isInit = true;
     }
     _glsx.Clear(PixelFarm.Drawing.Color.Blue);
     painter.StrokeColor = PixelFarm.Drawing.Color.Black;
     painter.StrokeWidth = 2;
     //-------------------------------
     //painter.FillColor = PixelFarm.Drawing.Color.Yellow;
     //painter.FillRenderVx(polygon1);
     //-------------------------------
     //painter.FillColor = PixelFarm.Drawing.Color.Red;
     //painter.FillRenderVx(polygon2);
     //////-------------------------------
     painter.FillColor = PixelFarm.Drawing.Color.Magenta;
     try
     {
         painter.FillRenderVx(polygon3);
         SwapBuffers();
     }
     catch (Exception ex)
     {
     }
 }
예제 #2
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _glsx.SmoothMode  = SmoothMode.Smooth;
            _glsx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _glsx.ClearColorBuffer();
            if (!resInit)
            {
                msdf_bmp = DemoHelper.LoadTexture(RootDemoPath.Path + @"\msdf_75.png");
                sdf_bmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\sdf_75.png");
                resInit  = true;
            }
            _glsx.Clear(PixelFarm.Drawing.Color.White);

            _glsx.DrawImageWithMsdf(msdf_bmp, 0, 400, 6);
            _glsx.DrawImageWithMsdf(msdf_bmp, 100, 500, 0.5f);
            _glsx.DrawImageWithMsdf(msdf_bmp, 100, 520, 0.4f);
            _glsx.DrawImageWithMsdf(msdf_bmp, 100, 550, 0.3f);
            _glsx.DrawImage(msdf_bmp, 150, 400);

            _glsx.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 200, 400, 6);
            _glsx.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 300, 500, 0.5f);
            _glsx.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 300, 520, 0.4f);
            _glsx.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 300, 550, 0.3f);

            //
            _glsx.DrawImageWithMsdf(sdf_bmp, 400, 400, 6);
            _glsx.DrawImageWithMsdf(sdf_bmp, 400, 500, 0.5f);
            _glsx.DrawImageWithMsdf(sdf_bmp, 400, 520, 0.4f);
            _glsx.DrawImageWithMsdf(sdf_bmp, 400, 550, 0.3f);
            _glsx.DrawImage(sdf_bmp, 400, 300);

            SwapBuffers();
        }
 protected override void OnGLRender(object sender, EventArgs args)
 {
     _glsx.SmoothMode  = SmoothMode.Smooth;
     _glsx.StrokeColor = PixelFarm.Drawing.Color.Blue;
     _glsx.Clear(PixelFarm.Drawing.Color.White);
     _glsx.ClearColorBuffer();
     //-------------------------------
     if (!isInit)
     {
         glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.png");
         isInit = true;
     }
     if (frameBuffer.FrameBufferId > 0)
     {
         if (frameBufferNeedUpdate)
         {
             //------------------------------------------------------------------------------------
             //framebuffer
             _glsx.AttachFrameBuffer(frameBuffer);
             //after make the frameBuffer current
             //then all drawing command will apply to frameBuffer
             //do draw to frame buffer here
             _glsx.Clear(PixelFarm.Drawing.Color.Red);
             _glsx.DrawImageWithBlurX(glbmp, 0, 300);
             _glsx.DetachFrameBuffer();
             //------------------------------------------------------------------------------------
             //framebuffer2
             _glsx.AttachFrameBuffer(frameBuffer2);
             GLBitmap bmp2 = new GLBitmap(frameBuffer.TextureId, frameBuffer.Width, frameBuffer.Height);
             bmp2.IsBigEndianPixel = true;
             _glsx.DrawImageWithBlurY(bmp2, 0, 300);
             _glsx.DetachFrameBuffer();
             //------------------------------------------------------------------------------------
             //after release current, we move back to default frame buffer again***
             frameBufferNeedUpdate = false;
         }
         _glsx.DrawFrameBuffer(frameBuffer2, 15, 300);
     }
     else
     {
         _glsx.Clear(PixelFarm.Drawing.Color.Blue);
     }
     //-------------------------------
     SwapBuffers();
 }
예제 #4
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _glsx.SmoothMode  = SmoothMode.Smooth;
            _glsx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _glsx.Clear(PixelFarm.Drawing.Color.White);
            _glsx.ClearColorBuffer();
            //-------------------------------
            if (!isInit)
            {
                isInit = true;
            }
            if (frameBuffer.FrameBufferId > 0)
            {
                //------------------------------------------------------------------------------------
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer.FrameBufferId);
                //--------
                //do draw to frame buffer here
                GL.ClearColor(OpenTK.Graphics.Color4.Red);
                GL.Clear(ClearBufferMask.ColorBufferBit);
                //------------------------------------------------------------------------------------



                //------------------------------------------------------------------------------------
                GL.BindTexture(TextureTarget.Texture2D, frameBuffer.TextureId);
                GL.GenerateMipmap(TextureTarget.Texture2D);
                GL.BindTexture(TextureTarget.Texture2D, 0);
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
                //------------------------------------------------------------------------------------

                GLBitmap bmp = new GLBitmap(frameBuffer.TextureId, frameBuffer.Width, frameBuffer.Height);
                bmp.IsBigEndianPixel = true;
                _glsx.DrawImage(bmp, 15, 300);
            }
            else
            {
                _glsx.Clear(PixelFarm.Drawing.Color.Blue);
            }
            //-------------------------------
            SwapBuffers();
        }
예제 #5
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _glsx.SmoothMode  = SmoothMode.Smooth;
            _glsx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _glsx.Clear(PixelFarm.Drawing.Color.White);
            _glsx.ClearColorBuffer();
            //-------------------------------
            if (!isInit)
            {
                glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\leaves.jpg");
                isInit = true;
            }
            if (frameBuffer.FrameBufferId > 0)
            {
                if (frameBufferNeedUpdate)
                {
                    //------------------------------------------------------------------------------------
                    //framebuffer
                    _glsx.AttachFrameBuffer(frameBuffer);
                    //after make the frameBuffer current
                    //then all drawing command will apply to frameBuffer
                    //do draw to frame buffer here
                    _glsx.Clear(PixelFarm.Drawing.Color.Red);
                    _glsx.DrawImageWithConv3x3(glbmp, Mat3x3ConvGen.emboss, 0, 300);
                    _glsx.DetachFrameBuffer();

                    //after release current, we move back to default frame buffer again***
                    frameBufferNeedUpdate = false;
                }
                _glsx.DrawFrameBuffer(frameBuffer, 15, 300);
            }
            else
            {
                _glsx.Clear(PixelFarm.Drawing.Color.Blue);
            }
            //-------------------------------
            SwapBuffers();
        }
예제 #6
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _glsx.SmoothMode  = SmoothMode.Smooth;
            _glsx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _glsx.ClearColorBuffer();
            _glsx.Clear(PixelFarm.Drawing.Color.Red);

            //-------------------------------
            painter.FillColor = PixelFarm.Drawing.Color.Black;
            painter.DrawString("OK", 0, 100);
            painter.DrawString("1234567890", 0, 200);
            //-------------------------------
            SwapBuffers();
        }
예제 #7
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _glsx.SmoothMode  = SmoothMode.Smooth;
            _glsx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            //-----------------------------
            //see:  lazyfoo.net/tutorials/OpenGL/26_the_stencil_buffer/index.php
            //-----------------------------

            _glsx.Clear(PixelFarm.Drawing.Color.White);
            //-------------------
            //disable rendering to color buffer
            GL.ColorMask(false, false, false, false);
            //start using stencil
            GL.Enable(EnableCap.StencilTest);
            //place a 1 where rendered
            GL.StencilFunc(StencilFunction.Always, 1, 1);
            //replace where rendered
            GL.StencilOp(StencilOp.Replace, StencilOp.Replace, StencilOp.Replace);
            //render  to stencill buffer

            painter.FillColor = PixelFarm.Drawing.Color.Black;
            painter.FillRenderVx(stencilPolygon);
            painter.StrokeColor = PixelFarm.Drawing.Color.Black;
            //render color
            GL.ColorMask(true, true, true, true);
            //where a 1 was not rendered
            GL.StencilFunc(StencilFunction.Equal, 1, 1);
            //keep the pixel
            GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Keep);
            //draw
            painter.FillColor = PixelFarm.Drawing.Color.Red;
            painter.FillRenderVx(rectPolygon);
            GL.Disable(EnableCap.StencilTest);
            //-----------------------------------------------------------
            SwapBuffers();
        }