Esempio n. 1
0
        protected void ResizeViewTo(GLTextuer2D inc, GLTextuer2D o, int owidth, int oheight, int nwidth, int nheight)
        {
            float wp = (float)nwidth / (float)owidth;
            float hp = (float)nheight / (float)oheight;

            float fp = wp < hp ? wp : hp;

            Matrix4 proj        = Matrix4.CreateOrthographic(nwidth, nheight, 0.03f, 1000f);
            Matrix4 translation = Matrix4.CreateTranslation(0, 0, 0);
            //half width/height for scale as it is centered based
            Matrix4 sm    = Matrix4.CreateScale(fp * (float)(owidth * 0.5f), -fp * (float)(oheight * 0.5f), 1);
            Matrix4 model = sm * translation;
            Matrix4 view  = Matrix4.LookAt(new Vector3(0, 0, 1), Vector3.Zero, Vector3.UnitY);

            resizeProcessor.Model      = model;
            resizeProcessor.View       = view;
            resizeProcessor.Projection = proj;

            resizeProcessor.Bind(inc);

            if (renderQuad != null)
            {
                renderQuad.Draw();
            }

            resizeProcessor.Unbind();

            o.Bind();
            o.CopyFromFrameBuffer(nwidth, nheight);
            GLTextuer2D.Unbind();
        }
Esempio n. 2
0
        protected void ApplyTransformNoAuto(GLTextuer2D inc, GLTextuer2D o, int owidth, int oheight, MVector translation, MVector scale, float angle, MVector pivot)
        {
            Matrix4 proj    = Matrix4.CreateOrthographic(owidth, oheight, 0.03f, 1000f);
            Matrix4 pTrans  = Matrix4.CreateTranslation(-pivot.X, -pivot.Y, 0);
            Matrix4 iPTrans = Matrix4.CreateTranslation(pivot.X, pivot.Y, 0);
            Matrix4 trans   = Matrix4.CreateTranslation(translation.X, translation.Y, 0);
            Matrix4 sm      = Matrix4.CreateScale(scale.X, scale.Y, 1);
            Matrix4 rot     = Matrix4.CreateRotationZ(angle);
            Matrix4 model   = pTrans * sm * rot * iPTrans * trans;

            Matrix4 view = Matrix4.LookAt(new Vector3(0, 0, 1), Vector3.Zero, Vector3.UnitY);

            IGL.Primary.Viewport(0, 0, owidth, oheight);

            resizeProcessor.Model      = model;
            resizeProcessor.View       = view;
            resizeProcessor.Projection = proj;
            resizeProcessor.Luminosity = Luminosity;

            resizeProcessor.Bind(inc);

            inc.ClampToEdge();

            if (renderQuad != null)
            {
                renderQuad.Draw();
            }

            inc.Repeat();
            resizeProcessor.Unbind();

            o.Bind();
            o.Repeat();
            GLTextuer2D.Unbind();

            Blit(o, owidth, oheight);

            /*o.Bind();
             * o.Repeat();
             * o.CopyFromFrameBuffer(owidth, oheight);
             * GLTextuer2D.Unbind();*/
        }