/** Binds the texture for the given mesh-key.
	- Returns false if not cached in */
bool D3D11GraphicsEngineTest::BindShaderForKey(const MeshKey& key)
{
	zCTexture* tx = key.Texture;

	if(!tx)
		return false; // FIXME: Gregs hat has this! Returning here causes it to not render at all

	// Bind texture
	if(tx->CacheIn(0.6f) == zRES_CACHED_IN) // FIXME: Don't always use a texture in a z-pre-pass!
	{
		MyDirectDrawSurface7* surface = tx->GetSurface();
		ID3D11ShaderResourceView* srv[2];

		// Get diffuse and normalmap
		srv[0] = ((D3D11Texture *)surface->GetEngineTexture())->GetShaderResourceView();
		srv[1] = surface->GetNormalmap() ? ((D3D11Texture *)surface->GetNormalmap())->GetShaderResourceView() : NULL;

		// Bind both
		Context->PSSetShaderResources(0,2, srv);

		if(RenderingStage == DES_Z_PRE_PASS)
		{
			// Force alphatest on vobs for now
			BindShaderForTexturePrePass(tx, true);
		}else
		{
			BindShaderForTextureDiffusePass(tx);
		}

		// Get and update info if neccessary
		MaterialInfo* info = key.Info;
		if(!info->Constantbuffer)
			info->UpdateConstantbuffer();

		// Bind info to pixel shader
		info->Constantbuffer->BindToPixelShader(2);
	}
}