-
Demon Textureing
These couple of functions are giving me h*ll. It is designed to load a texture up (another class that i know actually works), and display it at blah blah position, being blah blah tall and wide. Its (going to be) my D3D equivelent of a PictureBox. The problem is this. When I render normally, with the texture enabled, nothing shows up. When i switch to wire frame, i get a box that is just black, no texturing. This is odd in itself because i set the vertex colors to white before creating them. When i dont set the texture, i get a box where one side is red, and fades across to black. If someone can figure this out, i would be grateful. Its all in D3D8...
Code:
VOID UIPicBox::Render(SYSD3D* Device)
{
if(draw)
{
Reset();
Device->Device->SetVertexShader(TLTVERTFVF);
Device->Device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
//Device->Device->SetTexture(0, myText->GetTexture());
myText->SetTexture(Device);
//Reset();
Device->Device->SetStreamSource(0, myVB, sizeof(TLTVERTEX));
Device->Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
Device->Device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
Device->Device->SetTexture(0, NULL);
//Device->Device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
return;
}
VOID UIPicBox::Create(SYSD3D* Device, INT SizeX, INT SizeY)
{
//backColor = 0xffffffff;
TLTVERTEX* pts;
Device->Device->CreateVertexBuffer(4*sizeof(TLTVERTEX), NULL, TLTVERTFVF, D3DPOOL_DEFAULT, &myVB);
myVB->Lock(0, 0, (BYTE**)&pts, 0);
pts[2] = TLTVertex(myPos.x + SizeX, myPos.y, 0.0f, 1.0f, backColor, 1.0f, 0.0f);
pts[3] = TLTVertex(myPos.x + SizeX, myPos.y + SizeY, 0.0f, 1.0f, backColor, 1.0f, 1.0f);
pts[0] = TLTVertex(myPos.x, myPos.y, 0.0f, 1.0f, backColor, 0.0f, 0.0f);
pts[1] = TLTVertex(myPos.x, myPos.y + SizeY, 0.0f, 1.0f, backColor, 0.0f, 1.0f);
myVB->Unlock();
mySize.cx = SizeX;
mySize.cy = SizeY;
return;
}
VOID UIPicBox::Reset()
{
//backColor = 0xffffffff;
TLTVERTEX* pts;
myVB->Lock(0, 0, (BYTE**)&pts, 0);
pts[2] = TLTVertex(myPos.x + mySize.cx, myPos.y, 0.0f, 1.0f, backColor, 1.0f, 0.0f);
pts[3] = TLTVertex(myPos.x + mySize.cx, myPos.y + mySize.cy, 0.0f, 1.0f, backColor, 1.0f, 1.0f);
pts[0] = TLTVertex(myPos.x, myPos.y, 0.0f, 1.0f, backColor, 0.0f, 0.0f);
pts[1] = TLTVertex(myPos.x, myPos.y + mySize.cy, 0.0f, 1.0f, backColor, 0.0f, 1.0f);
myVB->Unlock();
//mySize.cx = SizeX;
//mySize.cy = SizeY;
return;
}
"draw" is a boolean, defined in the class. TLTVertex(...) is a function that spits out a transformed, lit, and textured vertex. MyText->GetTexture() returns a pointer to a loaded texture. This function/class work, because if i comment the SetTexture(0, NULL) line out, it textures my models =). Again, any help would be much appreciated. Thanks in advance.
Z.