Exemplo n.º 1
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);
        }