Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] Vertex Buffer Colour

Started by Barguast Nov 4, 2004 at 11:26 AM 1 replies 350+ views
Original Post
Barguast
Barguast
I have a vertex buffer which defines a wireframe cube. This vertex buffer uses the PositionOnly vertex type. Is it possible to tell Direct3D what colour to draw this cube without having to use (for example) the PositionColored vertex type? I want to make the colour of the cube changable and I can't think of any way to do this other than recreate the vertex buffer each time the colour is changed... With OpenGL (in C++) I could use the glColor3f function to achieve this effect. Is there anything similar in Direct3D for C#? Thanks
Using Visual C++ 7.0
turnpast
turnpast
Before you draw your cube you can set up lighting and material on the device:
//materialMaterial m = new Material();m.DiffuseColor = new ColorValue(1.0f,0.0f,0.0f); //REDdevice.Material = m;//lightingdevice.Lights[0].Type = LightType.Directional;device.Lights[0].DiffuseColor = new ColorValue(0.0f,1.0f,0.0f); //GREENdevice.Lights[0].Direction = new Vector3(1.0f,0.0f,0.0f);//in the x directiondevice.Lights[0].Enabled = true;//now draw your cube:device.DrawPrimitive(...);//should be red and lit from the left with a green light.

hope this helps.

Even if you are using a wireframe the materail should take effect.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.