Texture Blending Problems

Started by
1 comment, last by liquidjin 19 years, 8 months ago
I am missing something and need help. I've defined 12 vertices and put them in a vertex buffer. This is the FVF format:
#define D3DFVF_PLAYINGCARD_FACE_VERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1)
struct PLAYINGCARD_FACE_VERTEX
{
	D3DXVECTOR3 position;
	D3DXCOLOR color;
	float u, v;
};
These are the 12 vertices. They share a large texture that has 4 rows of 14 different cards which is where the cardTexWidth, cardTexHeight stuff comes in. Top Left Corner(clockwise) - Bottom Left Corner 0,1,2,3: Top Left Corner(clockwise) - Bottom Left Corner 4,5,6,7:

//Playing Card Vertices For Face Of Card
const float cardWidth	= (float)m_width/2.0f;
const float cardHeight	= (float)m_height/2.0f;
const float cardTexWidth	= 1.0f/14.0f;
const float cardTexHeight	= 1.0f/4.0f;
float u					= (float)m_value/14.0f;
float v					= (float)m_suit/4.0f;

PLAYINGCARD_FACE_VERTEX arrCardFaces[] =
{
	//Face #1
	{D3DXVECTOR3(-cardWidth, cardHeight, -2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), u, v},								//Vertex 0
	{D3DXVECTOR3(cardWidth, cardHeight, -2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), u + cardTexWidth, v},				//Vertex 1
	{D3DXVECTOR3(cardWidth, -cardHeight, -2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), u + cardTexWidth, v + cardTexHeight},	//Vertex 2
		
	{D3DXVECTOR3(-cardWidth, cardHeight, -2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), u, v},						//Vertex 0
	{D3DXVECTOR3(cardWidth, -cardHeight, -2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), u + cardTexWidth, v + cardTexHeight},	//Vertex 2
	{D3DXVECTOR3(-cardWidth, -cardHeight, -2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), u, v + cardTexHeight},					//Vertex 3

	//Face #2
	{D3DXVECTOR3(cardWidth, -cardHeight, +2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), cardTexWidth, cardTexHeight},		//Vertex 6
	{D3DXVECTOR3(cardWidth, cardHeight, +2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), cardTexWidth, 0.0f},				//Vertex 5
	{D3DXVECTOR3(-cardWidth, cardHeight, +2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), 0.0f, 0.0f},					//Vertex 4
		
	{D3DXVECTOR3(-cardWidth, -cardHeight, +2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), 0.0f, cardTexHeight},			//Vertex 7
	{D3DXVECTOR3(cardWidth, -cardHeight, +2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), cardTexWidth, cardTexHeight},		//Vertex 6
	{D3DXVECTOR3(-cardWidth, cardHeight, +2.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), 0.0f, 0.0f}					//Vertex 4
};
Whenever I render the faces I don't see the texture. Instead I see a solid color (which is not white). If I choose, as the D3DTSS_COLOROP, D3DTOP_SELECTARG1 then the color is blue and if I choose D3DTOP_SELCTARG2 then the color is red. I have lighting off, z-buffer and target clearing to white, zenable on, and max/min filter to linear. Any help you could give would be most appreciated. Thanks, Edited by Coder: source tags are cool [Edited by - Coder on August 4, 2004 2:34:21 PM]
Advertisement
Try changing your vertex structure to use a DWORD instead of a D3DXCOLOR structure. I believe the D3DXCOLOR structure is 4 floating point values, and the D3DFVF_DIFFUSE flag is looking for one DWORD.

You can set the DWORD color via the D3DCOLOR_RGBA macro.
DOH!!!....

Thank you very much. That did the trick.

This topic is closed to new replies.

Advertisement