Jump to content
  • Advertisement
Sign in to follow this  
cppcdr

Both my triangles render red when i use effects!

This topic is 4623 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

For some reason, when I try to render with effects my triangles all come out the same color. Does anyone know why? Here is the source:
pEffect->SetTechnique ("Technique0");

pEffect->Begin (&nPasses);
pEffect->BeginPass (0);

for (UINT i = 0; i < m_NumMaterials; i++)
{	
	if (m_pTempNumFaces  > 0)
	{
		pEffect->SetValue ("material_diffuse_color", &m_pMaterials .cDiffuse, sizeof (COLOR));
		pGraphics->RenderPolys (VERTEX_FVF, m_VB, m_pIB , m_NumVerts, sizeof (VERTEX), m_NumFaces, NULL);
	}
}

pEffect->EndPass ();
pEffect->End ();

m_NumMaterials = 2. TempNumFaces contains the number of faces for each material (in this case 1 each). The index buffers (i have 2) contain each one triangle. All of the 4 vertices are in the single vertex buffer. Material [0].diffuse = grey and Material [1].diffuse = red. When I try to render the triangles, both come out red. Anyone know why? (The effect file contains a vertex and pixel shader that output triangles that are the color specified by "material_diffuse_color". It has been tested and works fine)

Share this post


Link to post
Share on other sites
Advertisement
You need to call ID3DXEffect::CommitChanges() after SetValue() in order for it to update itself mid-pass [smile]

Quote:
If the application changes any effect state using any of the ID3DXEffect::Setx methods inside of an BeginPass/EndPass matching pair, the application must call CommitChanges before any DrawxPrimitive call to propagate state changes to the device before rendering. If no state changes occur within a BeginPass and EndPass matching pair, it is not necessary to call CommitChanges.


hth
Jack

Share this post


Link to post
Share on other sites
It works! I have been fighting to get this program to work for the last 6 days and I can now continue!
Thank you VERY much!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!