Пример #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();
        }
Пример #2
0
        public CCRenderTexture(CCSize contentSize, CCSize textureSizeInPixels, 
            CCSurfaceFormat colorFormat=CCSurfaceFormat.Color, 
            CCDepthFormat depthFormat=CCDepthFormat.None, 
            CCRenderTargetUsage usage=CCRenderTargetUsage.DiscardContents)
        {
            int textureWidth = (int)textureSizeInPixels.Width;
            int textureHeight = (int)textureSizeInPixels.Height;

            firstUsage = true;
            renderTarget2D = CCDrawManager.SharedDrawManager.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;

            AddChild(Sprite);
        }
Пример #3
0
 internal RenderTarget2D CreateRenderTarget(int width, int height, CCSurfaceFormat colorFormat, CCRenderTargetUsage usage)
 {
     return(CreateRenderTarget(width, height, colorFormat, CCDepthFormat.None, usage));
 }
Пример #4
0
 public CCRenderTexture()
 {
     PixelFormat = CCSurfaceFormat.Color;
 }
Пример #5
0
 public CCRenderTexture()
 {
     PixelFormat = CCSurfaceFormat.Color;
 }
Пример #6
0
 public CCTexture2D(Texture2D texture, CCSurfaceFormat format, bool premultipliedAlpha = true, bool managed = false)
     : this()
 {
     InitWithTexture(texture, format, premultipliedAlpha, managed);
 }
Пример #7
0
 internal void InitWithRawData <T>(T[] data, CCSurfaceFormat pixelFormat, int pixelsWide, int pixelsHigh, bool premultipliedAlpha, bool mipMap)
     where T : struct
 {
     InitWithRawData(data, pixelFormat, pixelsWide, pixelsHigh, premultipliedAlpha, mipMap, new CCSize(pixelsWide, pixelsHigh));
 }
Пример #8
0
 public CCTexture2D(Stream stream, CCSurfaceFormat pixelFormat = CCSurfaceFormat.Color)
     : this()
 {
     InitWithStream(stream, pixelFormat);
 }
Пример #9
0
 public CCTexture2D(byte[] data, CCSurfaceFormat pixelFormat = CCSurfaceFormat.Color, bool mipMap = false)
     : this()
 {
     InitWithData(data, pixelFormat, mipMap);
 }
Пример #10
0
 public CCTexture2D(int pixelsWide, int pixelsHigh, CCSurfaceFormat pixelFormat = CCSurfaceFormat.Color, bool premultipliedAlpha = true, bool mipMap = false)
     : this(new Texture2D(CCDrawManager.SharedDrawManager.XnaGraphicsDevice, pixelsWide, pixelsHigh, mipMap, (SurfaceFormat)pixelFormat), pixelFormat, premultipliedAlpha)
 {
     cacheInfo.CacheType = CCTextureCacheType.None;
     cacheInfo.Data      = null;
 }
Пример #11
0
        public CCTexture2D AddRawImage <T>(T[] data, int width, int height, string assetName, CCSurfaceFormat format,
                                           bool premultiplied, bool mipMap, CCSize contentSize) where T : struct
        {
            CCTexture2D texture;

            lock (dictLock)
            {
                if (!textures.TryGetValue(assetName, out texture))
                {
                    texture = new CCTexture2D();
                    texture.InitWithRawData(data, format, width, height, premultiplied, mipMap, contentSize);
                    textures.Add(assetName, texture);
                }
            }
            return(texture);
        }
Пример #12
0
 public CCTexture2D AddRawImage <T>(T[] data, int width, int height, string assetName, CCSurfaceFormat format,
                                    bool premultiplied, bool mipMap = false) where T : struct
 {
     return(AddRawImage(data, width, height, assetName, format, premultiplied, mipMap, new CCSize(width, height)));
 }