Beispiel #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           width    = input.ReadInt();
            int           height   = input.ReadInt();
            int           mipCount = input.ReadInt();

            try {
                _impl = renderSystem.CreateTexture2DImplementation(width, height, mipCount > 1, format, null);
                for (int i = 0; i < mipCount; i++)
                {
                    byte[] byteBuffer = input.ReadByteArray();
                    _impl.SetData <byte>(byteBuffer, i, null, 0, byteBuffer.Length);
                }
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        public void Read(ISavableReader input)
        {
            _vertexStride = input.ReadInt();
            int count = input.ReadInt();

            _elements = new VertexElement[count];
            for (int i = 0; i < count; i++)
            {
                VertexSemantic semantic      = input.ReadEnum <VertexSemantic>();
                int            semanticIndex = input.ReadInt();
                VertexFormat   format        = input.ReadEnum <VertexFormat>();
                int            offset        = input.ReadInt();
                _elements[i] = new VertexElement(semantic, semanticIndex, format, offset);
            }
            GetHashCode();
        }
Beispiel #3
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 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();
            VertexDeclaration decl    = input.ReadSavable <VertexDeclaration>();
            int           vertexCount = input.ReadInt();
            ResourceUsage usage       = input.ReadEnum <ResourceUsage>();

            byte[] byteBuffer = input.ReadByteArray();

            try {
                _impl      = renderSystem.CreateVertexBufferImplementation(decl, vertexCount, usage);
                _impl.Name = name;
                SetData <byte>(byteBuffer);
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }
Beispiel #4
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 state 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;
            try {
                _impl = renderSystem.CreateRasterizerStateImplementation();
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }

            _impl.Cull                       = input.ReadEnum <CullMode>();
            _impl.VertexWinding              = input.ReadEnum <VertexWinding>();
            _impl.Fill                       = input.ReadEnum <FillMode>();
            _impl.DepthBias                  = input.ReadInt();
            _impl.SlopeScaledDepthBias       = input.ReadSingle();
            _impl.EnableMultiSampleAntiAlias = input.ReadBoolean();
            _impl.EnableScissorTest          = input.ReadBoolean();
        }
Beispiel #5
0
 /// <summary>
 /// Deserializes this SceneHints.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public void Read(ISavableReader input)
 {
     _cullHint   = input.ReadEnum <CullHint>();
     _pickHint   = input.ReadEnum <PickingHint>();
     _lightHint  = input.ReadEnum <LightCombineHint>();
     _transHint  = input.ReadEnum <TransparencyType>();
     _bucketType = input.ReadEnum <RenderBucketType>();
     _orthoOrder = input.ReadInt();
 }
Beispiel #6
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 state 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;
            try {
                _impl = renderSystem.CreateSamplerStateImplementation();
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
            _impl.AddressU = input.ReadEnum <TextureAddressMode>();
            _impl.AddressV = input.ReadEnum <TextureAddressMode>();
            _impl.AddressW = input.ReadEnum <TextureAddressMode>();
            _impl.Filter   = input.ReadEnum <TextureFilter>();
            _impl.MipMapLevelOfDetailBias = input.ReadSingle();
            _impl.MaxAnisotropy           = input.ReadInt();
        }