Inheritance: SimpleRectTextureShader
Esempio n. 1
0
        internal GLRenderSurface(int width, int height)
        {
            //-------------
            //y axis points upward (like other OpenGL)
            //x axis points to right.
            //please NOTE: left lower corner of the canvas is (0,0)
            //-------------

            this._width  = width;
            this._height = height;
            //setup viewport size,
            //we need W:H ratio= 1:1 , square viewport
            int max = Math.Max(width, height);

            orthoView = MyMat4.ortho(0, max, 0, max, 0, 1); //this make our viewport W:H =1:1

            flipVerticalView = MyMat4.scale(1, -1) * MyMat4.translate(new OpenTK.Vector3(0, -height, 0));
            orthoAndFlip     = orthoView * flipVerticalView;
            //-----------------------------------------------------------------------
            _shareRes           = new ShaderSharedResource();
            _shareRes.OrthoView = orthoView;
            //-----------------------------------------------------------------------
            basicFillShader     = new BasicFillShader(_shareRes);
            smoothLineShader    = new SmoothLineShader(_shareRes);
            rectFillShader      = new RectFillShader(_shareRes);
            gdiImgTextureShader = new GdiImageTextureShader(_shareRes);
            gdiImgTextureWithWhiteTransparentShader = new GdiImageTextureWithWhiteTransparentShader(_shareRes);
            glyphStencilShader        = new GlyphImageStecilShader(_shareRes);
            textureSubPixRendering    = new ImageTextureWithSubPixelRenderingShader(_shareRes);
            blurShader                = new BlurShader(_shareRes);
            glesTextureShader         = new OpenGLESTextureShader(_shareRes);
            invertAlphaFragmentShader = new InvertAlphaLineSmoothShader(_shareRes); //used with stencil  ***

            conv3x3TextureShader        = new Conv3x3TextureShader(_shareRes);
            msdfShader                  = new DrawingGL.MultiChannelSdf(_shareRes);
            msdfSubPixelRenderingShader = new DrawingGL.MultiChannelSubPixelRenderingSdf(_shareRes);
            sdfShader = new DrawingGL.SingleChannelSdf(_shareRes);
            //-----------------------------------------------------------------------
            //tools

            tessTool = new TessTool();
            //-----------------------------------------------------------------------


            //GL.Enable(EnableCap.CullFace);
            //GL.FrontFace(FrontFaceDirection.Cw);
            //GL.CullFace(CullFaceMode.Back);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);//original **

            //GL.BlendFunc(BlendingFactorSrc.SrcColor, BlendingFactorDest.One);// not apply alpha to src
            //GL.BlendFuncSeparate(BlendingFactorSrc.SrcColor, BlendingFactorDest.OneMinusSrcAlpha,
            //                     BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            //GL.BlendFuncSeparate(BlendingFactorSrc.SrcColor, BlendingFactorDest.OneMinusSrcColor, BlendingFactorSrc.SrcAlpha, BlendingFactorDest.Zero);

            GL.ClearColor(1, 1, 1, 1);
            //-------------------------------------------------------------------------------
            GL.Viewport(0, 0, width, height);
        }
Esempio n. 2
0
        FrameBuffer _currentFrameBuffer;//default = null, system provide frame buffer


        internal CanvasGL2d(int canvasW, int canvasH)
        {
            this.canvasW = canvasW;
            this.canvasH = canvasH;
            ////setup viewport size
            int max = Math.Max(canvasW, canvasH);

            ////square viewport
            orthoView        = MyMat4.ortho(0, max, 0, max, 0, 1);
            flipVerticalView = MyMat4.scale(1, -1) * MyMat4.translate(new OpenTK.Vector3(0, -max, 0));
            orthoAndFlip     = orthoView * flipVerticalView;
            //-----------------------------------------------------------------------
            shaderRes           = new CanvasToShaderSharedResource();
            shaderRes.OrthoView = orthoView;
            //-----------------------------------------------------------------------
            basicFillShader     = new BasicFillShader(shaderRes);
            smoothLineShader    = new SmoothLineShader(shaderRes);
            rectFillShader      = new RectFillShader(shaderRes);
            gdiImgTextureShader = new GdiImageTextureShader(shaderRes);
            gdiImgTextureWithWhiteTransparentShader = new GdiImageTextureWithWhiteTransparentShader(shaderRes);
            textureSubPixRendering    = new ImageTextureWithSubPixelRenderingShader(shaderRes);
            blurShader                = new BlurShader(shaderRes);
            glesTextureShader         = new OpenGLESTextureShader(shaderRes);
            invertAlphaFragmentShader = new InvertAlphaLineSmoothShader(shaderRes); //used with stencil  ***
            // tessListener.Connect(tess,
            //Tesselate.Tesselator.WindingRuleType.Odd, true);
            conv3x3TextureShader = new Conv3x3TextureShader(shaderRes);
            msdfShader           = new DrawingGL.MultiChannelSdf(shaderRes);


            msdfSubPixelRenderingShader = new DrawingGL.MultiChannelSubPixelRenderingSdf(shaderRes);
            sdfShader = new DrawingGL.SingleChannelSdf(shaderRes);
            //----
            Tesselator tess = new Tesselator();

            tess.WindingRule = Tesselator.WindingRuleType.Odd;
            tessTool         = new TessTool(tess);
            //-----------------------------------------------------------------------


            //GL.Enable(EnableCap.CullFace);
            //GL.FrontFace(FrontFaceDirection.Cw);
            //GL.CullFace(CullFaceMode.Back);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);//original **

            //GL.BlendFunc(BlendingFactorSrc.SrcColor, BlendingFactorDest.One);// not apply alpha to src
            //GL.BlendFuncSeparate(BlendingFactorSrc.SrcColor, BlendingFactorDest.OneMinusSrcAlpha,
            //                     BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            //GL.BlendFuncSeparate(BlendingFactorSrc.SrcColor, BlendingFactorDest.OneMinusSrcColor, BlendingFactorSrc.SrcAlpha, BlendingFactorDest.Zero);

            GL.ClearColor(1, 1, 1, 1);
            //-------------------------------------------------------------------------------
            GL.Viewport(0, 0, canvasW, canvasH);
        }
Esempio n. 3
0
        FrameBuffer _currentFrameBuffer;//default = null, system provide frame buffer 


        internal CanvasGL2d(int canvasW, int canvasH)
        {
            this.canvasW = canvasW;
            this.canvasH = canvasH;
            ////setup viewport size
            int max = Math.Max(canvasW, canvasH);
            ////square viewport 
            orthoView = MyMat4.ortho(0, max, 0, max, 0, 1);
            //-----------------------------------------------------------------------
            shaderRes = new CanvasToShaderSharedResource();
            shaderRes.OrthoView = orthoView;
            //-----------------------------------------------------------------------


            basicFillShader = new BasicFillShader(shaderRes);
            smoothLineShader = new SmoothLineShader(shaderRes);
            rectFillShader = new RectFillShader(shaderRes);
            gdiImgTextureShader = new GdiImageTextureShader(shaderRes);
            gdiImgTextureWithWhiteTransparentShader = new GdiImageTextureWithWhiteTransparentShader(shaderRes);
            blurShader = new BlurShader(shaderRes);
            glesTextureShader = new OpenGLESTextureShader(shaderRes);
            invertAlphaFragmentShader = new InvertAlphaLineSmoothShader(shaderRes); //used with stencil  ***
            // tessListener.Connect(tess,          
            //Tesselate.Tesselator.WindingRuleType.Odd, true);
            conv3x3TextureShader = new Conv3x3TextureShader(shaderRes);
            msdfShader = new DrawingGL.MultiChannelSdf(shaderRes);


            msdfSubPixelRenderingShader = new DrawingGL.MultiChannelSubPixelRenderingSdf(shaderRes);
            sdfShader = new DrawingGL.SingleChannelSdf(shaderRes);
            //----
            Tesselator tess = new Tesselator();
            tess.WindingRule = Tesselator.WindingRuleType.Odd;
            tessTool = new TessTool(tess);
            //-----------------------------------------------------------------------


            //GL.Enable(EnableCap.CullFace);
            //GL.FrontFace(FrontFaceDirection.Cw);
            //GL.CullFace(CullFaceMode.Back); 

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.ClearColor(1, 1, 1, 1);
            //-------------------------------------------------------------------------------

            GL.Viewport(0, 0, canvasW, canvasH);
        }