   Problem with Direct3D and using D3DMaterial to set material
  Hello.My name is TJ and I just registered a few days ago. I have recently started learning DirectX by buying _Programming_Role_Playing_Games_with_DirectX_ and have gone through the DirectX Graphics section (Chapter 6). I''ve made reasonable progress, but now I''m stuck at setting a material for a polygon face.Which brings me to my question: How the heck do I set the material for a polygon that I want to draw? I thought it was accomplished doing the following code:During initialization:  // Set the rendering states  g_D3DD8->SetRenderState(D3DRS_LIGHTING, FALSE);  g_D3DD8->SetRenderState(D3DRS_ZENABLE, TRUE);  g_D3DD8->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);  g_D3DD8->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);  g_D3DD8->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);Setting the material:  D3DMATERIAL8 d3dm;  // clear device backbuffer  g_D3DD8->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 255), 1.0f, 0);  ... //None of the code here touches d3dm;  ZeroMemory(&d3dm, sizeof(D3DMATERIAL8));  // Fill Diffuse and Ambient to purple 100% opaque color  d3dm.Diffuse.r = d3dm.Ambient.r = 1.0f;  d3dm.Diffuse.g = d3dm.Ambient.g = 0.0f;  d3dm.Diffuse.b = d3dm.Ambient.b = 1.0f;  d3dm.Diffuse.a = d3dm.Ambient.a = 1.0f;  g_D3DD8->SetMaterial(&d3dm);After I do g_D3DD8->SetMaterial(&d3dm) I begin my scene, draw my primitives, then end the scene and present it. The program compiles fine, but when I run it on my computer it still uses the coloring information attatched to the vertices.I searched the DirectX and Beginner boards for other people with problems on d3dmaterial8 but have only found one other person who posted last year having this same problem as I do. I''m using the DirectX 8.1 SDK. Any help is appreciated.Thank you very much,-TJ 
  I seen you had:g_D3DD8->SetRenderState(D3DRS_LIGHTING, FALSE);Materials define what light the object will absorb or reflect. So you have:d3dm.Diffuse.r = d3dm.Ambient.r = 1.0f;d3dm.Diffuse.g = d3dm.Ambient.g = 0.0f;d3dm.Diffuse.b = d3dm.Ambient.b = 1.0f;d3dm.Diffuse.a = d3dm.Ambient.a = 1.0f;Which means it will reflect the red and blue lighting color, but absorb the any green light (Won''t show any green lighting).If your object has normals, just add a light and the material will work the way you want it to.   -UltimaX-"You wished for a white christmas... Now go shovel your wishes!" ;  Even with lightning off though he should beable to see the diffuse color though. ~Wave   [edited by - Wavewash on August 2, 2003 11:58:15 AM];  The calculations involving ''lights'' and ''materials'' are turned off and on via D3DRS_LIGHTING state.Diffuse lighting is part of these calculations.However, if vertex format contains color value, then that should be visible as D3DRS_LIGHTING is disabled. ;  And, the driver might assume, based on the existence of per-vertex color, that you do not want to use d3d lighting engine.Not sure if it''s up to driver or d3d to decide this... ;  Thanks for the replies everyone!I read in this book that, at least in DX8, if I specified a D3DMaterial8 variable and used SetMaterial with it, the drivers would ignore the vertex colors. However, it makes sense that I''d have to turn the lighting on in order for this to work. Thanks for the help!-TJ 