Пример #1
0
        /// <summary>
        /// Creates a new texture 1D implementation.
        /// </summary>
        /// <param name="width">Width of the texture</param>
        /// <param name="genMipmap">True if mipmaps should be generated</param>
        /// <param name="format">Surface format</param>
        /// <param name="data">DataBuffer to populate from, if null an empty texture and miplevels are generated.</param>
        /// <returns>
        /// Texture 1D implementation
        /// </returns>
        public Texture1DImplementation CreateTexture1DImplementation(int width, bool genMipmap, SurfaceFormat format, DataBuffer data)
        {
            D3D10Texture1DImplementation impl = new D3D10Texture1DImplementation(_renderer, width, genMipmap, format, data);

            SetGraphicsID(impl);
            return(impl);
        }
Пример #2
0
        /// <summary>
        /// Flushes the collection's state to the device, only textures that have been
        /// changed since the last draw call will get sent.
        /// </summary>
        internal void FlushState()
        {
            //Return if we haven't even touched these states, so we don't have to loop over them.
            if (!_shortCircuitUpdate)
            {
                return;
            }

            for (int i = 0; i < _maxTextures; i++)
            {
                //If state is dirty, grab the contents and send to the device
                if (_dirtyMark[i])
                {
                    //Clear the dirty bit
                    _dirtyMark[i] = false;

                    D3D.ShaderResourceView shaderResource = null;
                    Texture value = _textures[i];
                    //Get shader resource
                    if (value != null)
                    {
                        D3D10Helper.CheckDisposed(value);
                        switch (value.Dimensions)
                        {
                        case TextureDimensions.One:
                            D3D10Texture1DImplementation impl1D = value.Implementation as D3D10Texture1DImplementation;
                            shaderResource = impl1D.D3D10ShaderResourceView;
                            break;

                        case TextureDimensions.Two:
                            D3D10Texture2DImplementation impl2D = value.Implementation as D3D10Texture2DImplementation;
                            shaderResource = impl2D.D3D10ShaderResourceView;
                            break;

                        case TextureDimensions.Three:
                            D3D10Texture3DImplementation impl3D = value.Implementation as D3D10Texture3DImplementation;
                            shaderResource = impl3D.D3D10ShaderResourceView;
                            break;

                        case TextureDimensions.Cube:
                            D3D10TextureCubeImplementation implCube = value.Implementation as D3D10TextureCubeImplementation;
                            shaderResource = implCube.D3D10ShaderResourceView;
                            break;
                        }
                    }
                    //Set shader resource (or null)
                    if (_vertexTex)
                    {
                        _graphicsDevice.VertexShader.SetShaderResource(shaderResource, i);
                    }
                    else
                    {
                        _graphicsDevice.PixelShader.SetShaderResource(shaderResource, i);
                    }
                }
            }
            _shortCircuitUpdate = false;
        }