Can SetMaterial() be interleaved with rendering...?

Started by
2 comments, last by Alex Red 18 years, 8 months ago
Hi guys... I am modifing up a DX7 engine I am trying so assign different surfaces 'features' with the D3DMATERIAL7 material and the call SetMaterial()... Well...seems only the 1st SetMaterial() call seems to be accepted, the others seem to be ignored... The calls are done in btw DrawIndexedPrimitiveVB() calls... Then, the doubt, is the SetMaterial() call interleavable with draws...? Should I flush Buffers or check/wait for smthing before calling it again...? tnx for any info [R]ed
Advertisement
Hi there Alex Red,

[The Problem]
can SetMaterial() calls be interleaved?

[The Solution]
You certainly may.
Note a few things. (Sorry if this seems a little condescending, it is not my intention)

Scenario 1 (blue Material will never be applied to the primitives)
[Render Loop]
1) SetMaterial(redMaterial)
2) DrawPrimitive()
3) SetMaterial(blueMaterial)
4) Goto step 1

Scenario 2 (blue Material will only be applied to the second batch of primitives)
[Render Loop]
1) SetMaterial(redMaterial)
2) DrawPrimitive()
3) SetMaterial(blueMaterial)
4) DrawPrimitive()
5) Goto step 1

Check check if you are specifying the SetMaterials in the correct order such as.

[Render Loop]
1) SetMaterial(redMaterial)
2) DrawPrimitive() //render the primitives with a red material
3) SetMaterial(blueMaterial)
4) DrawPrimitive() //render the primitives with a blue material
5) Goto step 1

PS: also make sure you aren't setting the same material twice. It is a common mistake and might cause severe headaches :)

such as
[Render Loop]
1) SetMaterial(redMaterial)
2) DrawPrimitive() //render the primitives with a red material
3) SetMaterial(redMaterial) //Note the RED MATERIAL :)
4) DrawPrimitive() //render the primitives with a blue material
5) Goto step 1


I hope this helps buddy. Take care.
yep...
but... u want to say I can not apply the same D3DMATERIAL7 object twice consecutively...?
There is no such indication on docs... I thought the SetMaterial() just passes an Address Reference from which DX will clonate settings...and so...no matters about same address...
ok...
I will check

Tnx...
OK... solved...

tnx Armadon...

This topic is closed to new replies.

Advertisement