Materials have no effect...???

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Morten Aune Lyrstad (too_at_much.spam)
Date: 07/21/04


Date: Wed, 21 Jul 2004 18:35:26 +0200

Hi there!

Anyone experienced that the material definitions have no effect on the
color?
Here's my code: (Very unoptimized, I know... ;-)

----------------------------------------------------------------------------
------------------------------------------------------------------------
INT i;
DWORD lightState;
D3DMATERIAL9 sketchMat;

// Set render states for this canvas
global.device->GetRenderState(D3DRS_LIGHTING, &lightState);
if (lightState)
        global.device->SetRenderState(D3DRS_LIGHTING, FALSE);
global.device->SetRenderState(D3DRS_COLORVERTEX, FALSE);
global.device->SetTexture(0, NULL);
global.device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
global.device->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

sketchMat.Emissive = D3DXCOLOR(0x00000000UL);
sketchMat.Specular = sketchMat.Emissive;
sketchMat.Power = 0;

sketchMat.Ambient =
D3DXCOLOR(global.constructor->GetColorSet()->GetSketchFaceColor());
// (Would return 0xFFB0B0B0)

sketchMat.Diffuse = sketchMat.Ambient;
global.device->SetMaterial(&sketchMat);

// Renders various scene elements, usually a collection of D3DXMeshes. The
flag indicates that no materials should be uploaded to the device.
for (i = 0; i < prv->sceneItems->size(); i++)
    prv->sceneItems->at(i)->Render(RENDER_OVERRIDE);

// Restore render states
global.device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
global.device->SetRenderState(D3DRS_COLORVERTEX, TRUE);
if (lightState)
    global.device->SetRenderState(D3DRS_LIGHTING, TRUE);

----------------------------------------------------------------------------
------------------------------------------------------------------------

Everything comes out white.

DirectX9 MSDEV60

Yours,
Morten Aune Lyrstad