예제 #1
0
        private Texture GetTexture(RenderDevice device)
        {
            if (_textureSource == null)
            {
                return(null);
            }

            uint width  = Width;
            uint height = Height;

            if (_renderTarget == null /* ||
                                       * _renderTarget.Texture.Width != width ||
                                       * _renderTarget.Texture.Height != height*/)
            {
                _renderTarget = device.CreateRenderTarget("MediaPlayer", width, height, 1, false);
            }

            if (_stream != null)
            {
                if (HasNewFrame(_state))
                {
                    Tile tile = new Tile();
                    tile.X      = 0;
                    tile.Y      = 0;
                    tile.Width  = width;
                    tile.Height = height;
                    Tile[] tiles = new Tile[] { tile };

                    device.SetRenderTarget(_renderTarget);

                    RenderFrame(_state);

                    device.ResolveRenderTarget(_renderTarget, tiles);
                }
            }

            return(_renderTarget.Texture);
        }