Original Post
Hi
I am implementing a skybox into my game using the cube method.
I''ve wrote some code to load the relevant bitmaps as shown below.
Bitmaps I want to load for my textures...
char* filenames[] = {
{"c:\\Clouds\\SnowCliffLeft.bmp"},
{"c:\\Clouds\\SnowCliffRight.bmp"},
{"c:\\Clouds\\SnowCliffFront.bmp"},
{"c:\\Clouds\\SnowCliffBack.bmp"},
{"c:\\Clouds\\SnowCliffTop.bmp"},
{"c:\\Clouds\\SnowCliffBottom.bmp"},
};
in game initialisation.....
r = d3dManager.LoadSkyBoxTextures(&filenames[0]);
if(FAILED(r))
{
d3dManager.SetError("Failed to load textures");
return E_FAIL;
}
// Set pointer to skybox textures
pSkyBoxTextures = d3dManager.GetSkyBoxTexture();
Method to load the textures and store them...
HRESULT CD3DManager::LoadSkyBoxTextures(char **pFilenames)
{
HRESULT r = 0;
for (int i=0; i<6; i++)
{
if(m_pSkyBoxTexture)
m_pSkyBoxTexture[i]->Release();
ShowInfo("Loading Textures...");
ShowInfo(pFilenames[i]);
r = D3DXCreateTextureFromFile(m_pDevice, pFilenames[i], &m_pSkyBoxTexture[i]);
if(FAILED(r))
return E_FAIL;
}
return r;
}
Returns a pointer of pointers for textures...
inline IDirect3DTexture8** CD3DManager::GetSkyBoxTexture()
{
return m_pSkyBoxTexture;
}
In my rendering method...
g_pDevice->SetStreamSource(0,g_pVB, sizeof(MYVERTEX));
g_pDevice->SetTexture(0, pSkyBoxTextures[i]);
g_pDevice->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_pDevice->SetTextureStageState(0,D3DTSS_MINFILTER,D3DTEXF_LINEAR);
g_pDevice->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_MODULATE);
g_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 6, 12);
This draws the whole cube in one go with the first texture applied to all faces, how do I draw a face at a time with a different texture - do I need a seperate vertex
buffer for each face and then set the new texture between calls to DrawPrimitive ?
Kind regards,
sTeVe