/// <summary> /// Creates a new texture 3D implementation. /// </summary> /// <param name="width">Width of the texture</param> /// <param name="height">Height of the texture</param> /// <param name="depth">Depth 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 is generated.</param> /// <returns> /// Texture 3D implementation /// </returns> public Texture3DImplementation CreateTexture3DImplementation(int width, int height, int depth, bool genMipmap, SurfaceFormat format, DataBuffer data) { D3D10Texture3DImplementation impl = new D3D10Texture3DImplementation(_renderer, width, height, depth, genMipmap, format, data); SetGraphicsID(impl); return(impl); }
/// <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; }