我正在尝试使用固定功能管道(没有着色器或效果文件)在 DirectX9 中渲染天空盒。我可以查看立方体渲染。当我设置纹理时,所有的脸都被涂上了一种奇怪的颜色(不是白色或空白)。纹理文件是正确的立方体贴图。我认为某些纹理设置未设置。下面是代码片段
// for creating the cube and the cube texture
HRESULT apiResult = D3DXCreateBox(g_pd3dDevice,1,1,1,&g_pMesh,NULL);
apiResult = D3DXCreateCubeTextureFromFile(g_pd3dDevice,L"cubeMap.dds",&g_pTexture);
两个 API 都返回 S_OK。
// for renderin the skybox
g_pd3dDevice->SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);
// set texture
g_pd3dDevice->SetTexture(0,g_pTexture);
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
g_pMesh->DrawSubset(0);
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
缺少哪个设置?