Skip to main content
GameDev.net gamedev.net
🔒 Locked

Texturing Problem

Started by McSteel Aug 11, 2002 at 7:37 AM 1 replies 250+ views
Original Post
McSteel
McSteel
Hello! I am making a simple 2d particle effect in D3D. I have a vertex Buffer which I put the particle vertex into. Then I have an index buffer which I use to index the vertex to make a square. Then I draw it. It draws the triangles correctly and make the square but the texture is not drawn onto it propperly. It textures the whole square with just the top left pixel of the texture. So I know that the texture is loaded propperly but not being put onto the square correctly. I have tried to work out what is wrong with it and can''t seem to see what is broken. Here is the code I use to build my triangles.
//Add the 4 Vertex that make the quad to the Vertex Buffer
			
	//(0,0)
	pVertices->Color = Particles[Count].StartColor;
	pVertices->Position = D3DXVECTOR3(Particles[Count].Position.x - (Particles[Count].Size/2.0f), Particles[Count].Position.y - (Particles[Count].Size/2.0f), 0.0);
	pVertices->rhw = 0.0f;
	pVertices->tu = 0.0f;
	pVertices->tv = 0.0f;
	pVertices++;

	//(1,0) 
	pVertices->Color = Particles[Count].StartColor;
	pVertices->Position = D3DXVECTOR3(Particles[Count].Position.x + (Particles[Count].Size/2.0f), Particles[Count].Position.y - (Particles[Count].Size/2.0f), 0.0);
	pVertices->rhw = 0.0f;
	pVertices->tu = 1.0f;
	pVertices->tv = 0.0f;
	pVertices++;

	//(0,1)
	pVertices->Color = Particles[Count].StartColor;
	pVertices->Position = D3DXVECTOR3(Particles[Count].Position.x - (Particles[Count].Size/2.0f), Particles[Count].Position.y + (Particles[Count].Size/2.0f), 0.0);
	pVertices->rhw = 0.0f;
	pVertices->tu = 0.0f;
	pVertices->tv = 1.0f;
	pVertices++;

	//(1,1)
	pVertices->Color = Particles[Count].StartColor;
	pVertices->Position = D3DXVECTOR3(Particles[Count].Position.x + (Particles[Count].Size/2.0f), Particles[Count].Position.y + (Particles[Count].Size/2.0f), 0.0);
	pVertices->rhw = 0.0f;
	pVertices->tu = 1.0f;
	pVertices->tv = 1.0f;
	pVertices++;

//Add to Index Buffer to make the 2 triangles
			
	*(pIndices) = 2+(ParticlesCached*4);
	*(pIndices)++;

	*(pIndices) = (ParticlesCached*4);
	*(pIndices)++;

	*(pIndices) = 3+(ParticlesCached*4);
	*(pIndices)++;

	*(pIndices) = 3+(ParticlesCached*4);
	*(pIndices)++;

	*(pIndices) = (ParticlesCached*4);
	*(pIndices)++;

	*(pIndices) = 1+(ParticlesCached*4);
	*(pIndices)++;
 
Thank you for any help.
paccabal
paccabal
If your quad is drawn as a real quad maybe your texture addressing mode is wrong. Look if you have something like that in your code:
SetTextureStageState(stage, D3DTSS_ADDRESSU,D3DTS_ADDRESS_WRAP) and
SetTextureStageState(stage, D3DTSS_ADDRESSV,D3DTS_ADDRESS_WRAP).

Maybe this can help you.
McSteel
McSteel
I have not changed them at all and the sdk says they are default settings so it should not be that?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.