Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

McSteel

Texturing Problem

This topic is 5889 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!