Sign in to follow this  
liquidjin

Texture Blending Problems

Recommended Posts

liquidjin    122
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]

Share this post


Link to post
Share on other sites
FugueInCPP    184
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this