Example #1
0
        public CCRenderTexture(CCSize contentSize, CCSize textureSizeInPixels,
                               CCSurfaceFormat colorFormat = CCSurfaceFormat.Color,
                               CCDepthFormat depthFormat   = CCDepthFormat.None,
                               CCRenderTargetUsage usage   = CCRenderTargetUsage.DiscardContents) : this()
        {
            int textureWidth  = (int)textureSizeInPixels.Width;
            int textureHeight = (int)textureSizeInPixels.Height;

            renderTarget2D = drawManager.CreateRenderTarget(
                textureWidth, textureHeight, colorFormat, depthFormat, usage);

            Texture = new CCTexture2D(renderTarget2D, colorFormat, true, false);
            Texture.IsAntialiased = false;

            Sprite             = new CCSprite(Texture);
            Sprite.ContentSize = contentSize;
            Sprite.BlendFunc   = CCBlendFunc.AlphaBlend;

            CCPoint center = contentSize.Center;

            renderViewMatrix =
                Matrix.CreateLookAt(new CCPoint3(center, 300.0f).XnaVector, new CCPoint3(center, 0.0f).XnaVector, Vector3.Up);
            renderProjMatrix =
                Matrix.CreateOrthographic(contentSize.Width, contentSize.Height, 1024f, -1024);
            renderViewport = new Viewport(0, 0, textureWidth, textureHeight);


            clearColor = CCColor4B.Transparent;
            drawManager.SetRenderTarget(Texture);
            drawManager.Clear(clearColor);
            drawManager.RestoreRenderTarget();
        }
Example #2
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;
            }
        }
Example #3
0
        void OnBegin()
        {
            CCDrawManager drawManager = CCDrawManager.SharedDrawManager;

            drawManager.SetRenderTarget(Texture);

            if (shouldClear)
            {
                drawManager.Clear(clearColor);
                shouldClear = false;
            }
        }
Example #4
0
        public virtual void Begin()
        {
            CCDrawManager drawManager = CCDrawManager.SharedDrawManager;

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

//            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;
            }
        }
Example #5
0
 public void BeforeRender(CCTexture2D texture)
 {
     drawManager.SetRenderTarget(texture);
     drawManager.Clear(CCColor4B.Transparent);
 }