Exemplo n.º 1
0
        protected override void OnTimerTick(object sender, EventArgs e)
        {
            if (!isGLInit)
            {
                return;
            }


            float dt = 0.5f;

            mRotation = (float)fmod(mRotation + (dt * 40.0f), 360.0f);
            //Matrix4 perspectiveMatrix = Matrix4::perspective(60.0f, float(getWindow()->getWidth()) / getWindow()->getHeight(),
            //                                                 1.0f, 20.0f);
            MyMat4 perspectiveMat = MyMat4.perspective(60.0f, (float)Width / (float)Height, 1.0f, 20.0f);
            //Matrix4 modelMatrix = Matrix4::translate(Vector3(0.0f, 0.0f, -2.0f)) *
            //                      Matrix4::rotate(mRotation, Vector3(1.0f, 0.0f, 1.0f));

            MyMat4 modelMat = MyMat4.translate(new Vector3(0f, 0f, -2f)) *
                              MyMat4.rotate(mRotation, new Vector3(1, 0, 1));
            MyMat4 viewMatrix = MyMat4.GetIdentityMat();
            MyMat4 mvpMatrix  = perspectiveMat * viewMatrix * modelMat;

            //// Load the matrices
            //glUniformMatrix4fv(mMVPMatrixLoc, 1, GL_FALSE, mvpMatrix.data);
            GL.UniformMatrix4(mMVPMatrixLoc, 1, false, mvpMatrix.data);
        }
Exemplo n.º 2
0
        public SimpleCanvas(int view_width, int view_height)
        {
            FillColor   = Color.Black;
            StrokeColor = Color.Black;

            //dimension
            _view_width  = view_width;
            _view_height = view_height;
            _max         = Math.Max(view_width, view_height);
            //------------
            //matrix
            ////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;
            //-----------------------------------------------------------------------
            //shader
            _shaderRes           = new CanvasToShaderSharedResource();
            _shaderRes.OrthoView = _orthoView;
            //
            _fillShader = new GlyphFillShader(_shaderRes);
            //------------
            //tools
            Tesselate.Tesselator tt = new Tesselate.Tesselator();
            _tessTool       = new TessTool(tt);
            _curveFlattener = new SimpleCurveFlattener();
            ClearColor      = Color.White;
            //--------
            //set blend mode
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
        }