Exemplo n.º 1
0
        public virtual void Begin()
        {
            // Save the current matrix
            CCDrawManager.PushMatrix();

            CCSize texSize = m_pTexture.ContentSizeInPixels;

            // Calculate the adjustment ratios based on the old and new projections
            CCDirector director    = CCDirector.SharedDirector;
            CCSize     size        = director.WinSizeInPixels;
            float      widthRatio  = size.Width / texSize.Width;
            float      heightRatio = size.Height / texSize.Height;

            CCDrawManager.SetRenderTarget(m_pTexture);

            CCDrawManager.SetViewPort(0, 0, (int)texSize.Width, (int)texSize.Height);

            Matrix projection = Matrix.CreateOrthographicOffCenter(
                -1.0f / widthRatio, 1.0f / widthRatio,
                -1.0f / heightRatio, 1.0f / heightRatio,
                -1, 1
                );

            CCDrawManager.MultMatrix(ref projection);

            if (m_bFirstUsage)
            {
                CCDrawManager.Clear(Color.Transparent);
                m_bFirstUsage = false;
            }
        }
Exemplo n.º 2
0
        public void Set2DProjection()
        {
            CCSize size = m_pTexture.ContentSizeInPixels;

            CCDrawManager.SetViewPort(0, 0,
                                      (int)(size.Width * CCMacros.CCContentScaleFactor()),
                                      (int)(size.Height * CCMacros.CCContentScaleFactor())
                                      );

            /*
             * CCDrawManager.ProjectionMatrix = Matrix.Identity;
             *
             * Matrix orthoMatrix = Matrix.CreateOrthographicOffCenter(
             *  0, size.width * ccMacros.CC_CONTENT_SCALE_FACTOR(),
             *  0, size.height * ccMacros.CC_CONTENT_SCALE_FACTOR(),
             *  -1, 1
             *  );
             *
             * CCDrawManager.MultMatrix(ref orthoMatrix);
             */

            CCDrawManager.ViewMatrix       = Matrix.Identity;
            CCDrawManager.ProjectionMatrix = Matrix.Identity;

            Matrix projection      = Matrix.CreateOrthographicOffCenter(0, size.Width, 0, size.Height, -1024.0f, 1024.0f);
            Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);

            CCDrawManager.WorldMatrix = (halfPixelOffset * projection);


            /*
             * CCDirector *director = CCDirector::sharedDirector();
             *
             * CCSize    size = director->getWinSizeInPixels();
             *
             * glViewport(0, 0, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) );
             * kmGLMatrixMode(KM_GL_PROJECTION);
             * kmGLLoadIdentity();
             *
             * kmMat4 orthoMatrix;
             * kmMat4OrthographicProjection(&orthoMatrix, 0, size.width * CC_CONTENT_SCALE_FACTOR(), 0, size.height * CC_CONTENT_SCALE_FACTOR(), -1, 1);
             * kmGLMultMatrix( &orthoMatrix );
             *
             * kmGLMatrixMode(KM_GL_MODELVIEW);
             * kmGLLoadIdentity();
             *
             *
             * ccSetProjectionMatrixDirty();
             */
        }
Exemplo n.º 3
0
        public void Set2DProjection()
        {
            CCSize size = m_pTexture.ContentSizeInPixels;

            CCDrawManager.SetViewPort(0, 0, (int)size.Width, (int)size.Height);

            CCDrawManager.ViewMatrix       = Matrix.Identity;
            CCDrawManager.ProjectionMatrix = Matrix.Identity;

            Matrix projection      = Matrix.CreateOrthographicOffCenter(0, size.Width, 0, size.Height, -1024.0f, 1024.0f);
            Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);

            CCDrawManager.WorldMatrix = (halfPixelOffset * projection);
        }