Hi,
I have this code (in OpenGL):
[...]
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(4, GL_FLOAT, 0, color_p);
glNormalPointer(GL_FLOAT, 0, normal_p);
glVertexPointer(3, GL_FLOAT, 0, vertex_p);
glDrawArrays(GL_TRIANGLES, 0, 3 * c);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
[...]
With GL_COLOR_MATERIAL/glColorMaterial enabled.
( http://www.opengl.org/documentation/spe ... erial.html )
In this way, I can change material's color for each vertex.
But... I don't understand how I can implement it with Irrlicht... =((
OpenGL conversion (glColorMaterial)
-
Baal Cadar
- Posts: 377
- Joined: Fri Oct 28, 2005 10:28 am
- Contact:
With glColorMaterial, I can change the material's color for each vertex and not only the vertex's color.
For example, if I enable lighting (and add some lights) in CustomSceneNode tutorial, the object appears "white and black":

If I add glEnable(GL_COLOR_MATERIAL); in COpenGLDriver::drawIndexedTriangleList, the material's color changes at each vertex:

But I don't know how I can implement it with Direct3D or Irrlicht methods =(
Thanx =)
For example, if I enable lighting (and add some lights) in CustomSceneNode tutorial, the object appears "white and black":

If I add glEnable(GL_COLOR_MATERIAL); in COpenGLDriver::drawIndexedTriangleList, the material's color changes at each vertex:

But I don't know how I can implement it with Direct3D or Irrlicht methods =(
Thanx =)
Well, I found how to implement it in D3D =)
I must add in CD3D9Driver::drawIndexedTriangleList these lines:
pID3DDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
pID3DDevice->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_COLOR1);
pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_COLOR1);
pID3DDevice->SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1);
But I still don't understand how to implement it without changing the Irrlicht code... =)
I must add in CD3D9Driver::drawIndexedTriangleList these lines:
pID3DDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
pID3DDevice->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_COLOR1);
pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_COLOR1);
pID3DDevice->SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1);
But I still don't understand how to implement it without changing the Irrlicht code... =)