Beispiel #1
0
        public virtual void Begin()
        {
            CCDrawManager drawManager = CCDrawManager.SharedDrawManager;

            // Save the current matrix
            drawManager.PushMatrix();

            CCSize texSize = Texture.ContentSizeInPixels;

            CCSize size        = Scene.Viewport.ViewportInPixels.Size;
            float  widthRatio  = size.Width / texSize.Width;
            float  heightRatio = size.Height / texSize.Height;

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

            drawManager.MultMatrix(ref projection);

            drawManager.SetRenderTarget(Texture);

            if (firstUsage)
            {
                drawManager.Clear(CCColor4B.Transparent);
                firstUsage = false;
            }
        }
        internal void RenderCustomCommand(CCDrawManager drawManager)
        {
            bool originalDepthTestState = drawManager.DepthTest;

            drawManager.DepthTest = UsingDepthTest;

            drawManager.PushMatrix();
            drawManager.SetIdentityMatrix();

            if (WorldTransform != CCAffineTransform.Identity)
            {
                var worldTrans = WorldTransform.XnaMatrix;
                drawManager.MultMatrix(ref worldTrans);
            }
            Action();

            drawManager.PopMatrix();

            drawManager.DepthTest = originalDepthTestState;
        }