예제 #1
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying implementation fails or the render
        /// system is not set.</exception>
        public override void Read(ISavableReader input)
        {
            IRenderSystemProvider renderSystem = input.RenderSystem;

            if (renderSystem == null)
            {
                Dispose();
                throw new TeslaException("Render system provider not set, cannot create graphics resource implementation.");
            }

            base.RenderSystem = renderSystem;

            String        name     = input.ReadString();
            SurfaceFormat format   = input.ReadEnum <SurfaceFormat>();
            int           size     = input.ReadInt();
            int           mipCount = input.ReadInt();

            try {
                _impl = renderSystem.CreateTextureCubeImplementation(size, mipCount > 1, format, null);
                for (int i = 0; i < 6; i++)
                {
                    for (int j = 0; j < mipCount; j++)
                    {
                        byte[] byteBuffer = input.ReadByteArray();
                        _impl.SetData <byte>((CubeMapFace)i, byteBuffer, j, null, 0, byteBuffer.Length);
                    }
                }
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }
예제 #2
0
        /// <summary>
        /// Creates a new instance of <see cref="TextureCube"/>.
        /// </summary>
        /// <param name="renderSystem">Render system used to create the underlying implementation.</param>
        /// <param name="size">The size (width/height) of each cube face.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if the render system is null.</exception>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying texture fails.</exception>
        public TextureCube(IRenderSystemProvider renderSystem, int size)
        {
            if (renderSystem == null)
            {
                Dispose();
                throw new ArgumentNullException("renderSystem", "Render system cannot be null.");
            }

            base.RenderSystem = renderSystem;

            try {
                _impl = renderSystem.CreateTextureCubeImplementation(size, false, SurfaceFormat.Color, null);
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }
예제 #3
0
        /// <summary>
        /// Creates a new instance of <see cref="TextureCube"/>.
        /// </summary>
        /// <param name="renderSystem">Render system used to create the underlying implementation.</param>
        /// <param name="size">The size (width/height) of each cube face.</param>
        /// <param name="genMipMap">True if mip levels should be generated.</param>
        /// <param name="format">The surface format.</param>
        /// <param name="initialData">The initial data for the first mip level.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if the render system is null.</exception>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating or writing to the underlying texture fails.</exception>
        public TextureCube(IRenderSystemProvider renderSystem, int size, bool genMipMap, SurfaceFormat format, DataBuffer[] initialData)
        {
            if (renderSystem == null)
            {
                Dispose();
                throw new ArgumentNullException("renderSystem", "Render system cannot be null.");
            }

            base.RenderSystem = renderSystem;

            try {
                _impl = renderSystem.CreateTextureCubeImplementation(size, genMipMap, format, initialData);
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }
예제 #4
0
        /// <summary>
        /// Creates a new instance of <see cref="TextureCube"/>.
        /// </summary>
        /// <param name="size">The size (width/height) of each cube face.</param>
        /// <param name="genMipMap">True if mip levels should be generated.</param>
        /// <param name="format">The surface format.</param>
        /// <param name="initialData">The initial data for the first mip level.</param>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying texture fails or the render
        /// system was not initialized.</exception>
        public TextureCube(int size, bool genMipMap, SurfaceFormat format, DataBuffer[] initialData)
        {
            IRenderSystemProvider renderSystem = Engine.Services.GetService <IRenderSystemProvider>();

            if (renderSystem == null)
            {
                Dispose();
                throw new TeslaException("Render system provider not set, cannot create graphics resource implementation.");
            }

            base.RenderSystem = renderSystem;

            try {
                _impl = renderSystem.CreateTextureCubeImplementation(size, genMipMap, format, initialData);
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }