//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.
Texturing Problem
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.
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.
SetTextureStageState(stage, D3DTSS_ADDRESSU,D3DTS_ADDRESS_WRAP) and
SetTextureStageState(stage, D3DTSS_ADDRESSV,D3DTS_ADDRESS_WRAP).
Maybe this can help you.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement