Original Post
Hey everyone, it's time for another n00b question! Maybe by me asking a million n00b questions, we'll stop other n00bs from reasking the same questions, but probebly not. I'll be the scapegoat. Ok, my problem today is applying textures to 2d polygons. I have created a class that allows for the creation of polygons and today I decided to implement a method for applying textures to that class. When I changed a few different things, I wound up either having all of my polygons disappear (or I suppose they are there, but are black so they arent visible) or all are shown except the ball is black. Here is my method for specifing the texture. This function always returns true, so I don't suspect it is the problem:
bool CPrimitive::SetTexture(const char *TexturePath)
{
//if(FAILED(D3DXCreateTextureFromFile(myD3DDevice, TexturePath, &myTexture))) { return false; }
if(FAILED(D3DXCreateTextureFromFile(myD3DDevice, TexturePath, &myTexture)))
{
return false;
}
return true;
} I changed my FVF from: #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE) to #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) When I use the bottom FVF nothing is shown, everything is black. When I use the top one, everything is shown except the ball (the ball is the only instance of my primitive class who has a texture specified). Also added this to the render method of my class: HRESULT CPrimitive::Render()
{
myD3DDevice->SetStreamSource(0, myVertexBuf, sizeof(CUSTOMVERTEX));
myD3DDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX);
if(myTexture != NULL) {
myD3DDevice->SetTexture(0, myTexture);
myD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
} else {
myD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE);
}
myD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
return S_OK;
} I added the if statements to this method. I'm not sure why I cant see my textures. Is it something to do with SetTextureStageState? Im not quite sure where to look on this one. Any information would be awesome. Also, this might be kind of confusing so if you have any questions or want to see the rest of the code I will paste it in here. Thanks everyone.