Esempio n. 1
0
	/** Sets a texture on the current shader instance. */
	void Shader::SetTexture(u32 index, std::shared_ptr<Texture> texture)
	{
		ID3D11ShaderResourceView* resourceView = texture != nullptr ? texture->GetShaderResourceView() : nullptr;
		ID3D11DeviceContext* context = GetParent()->GetDeviceContext();
		switch(GetType())
		{
		case ShaderType::Compute:
			context->CSSetShaderResources(index, 1, &resourceView);
			break;
		case ShaderType::Domain:
			context->DSSetShaderResources(index, 1, &resourceView);
			break;
		case ShaderType::Geometry:
			context->GSSetShaderResources(index, 1, &resourceView);
			break;
		case ShaderType::Hull:
			context->HSSetShaderResources(index, 1, &resourceView);
			break;
		case ShaderType::Pixel:
			context->PSSetShaderResources(index, 1, &resourceView);
			break;
		case ShaderType::Vertex:
			context->VSSetShaderResources(index, 1, &resourceView);
			break;
		}
	}