I draw objects in OpenGL. You need to color them with glMaterialfv() . So, I set different properties of the material, but they are painted only in some places, and the main part remains white.

It seems that everything you need is connected:

 glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glEnable(GL_DEPTH_TEST); //glDepthFunc(GL_LESS); glEnable(GL_LIGHT0); glEnable(GL_NORMALIZE); glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); 

And material properties:

 GLfloat ambcon [] = {1,0,0,1}; GLfloat diffcon [] = {1,0,0,1}; GLfloat speccon [] = {1,0,0,1}; GLfloat shincon = 0; GLfloat ambsph [] = {1,1,0,1}; GLfloat diffsph [] = {1,1,0,1}; GLfloat specsph [] = {1,1,0,1}; GLfloat shinsph = 0; GLfloat ambcyl [] = {0,0,1,1}; GLfloat diffcyl [] = {0,0,1,1}; GLfloat speccyl [] = {0,0,1,1}; GLfloat shincyl = 0; glMaterialfv(GL_FRONT, GL_AMBIENT, ambcon); glMaterialfv(GL_FRONT, GL_DIFFUSE, diffcon); glMaterialfv(GL_FRONT, GL_SPECULAR, speccon); glPushMatrix(); glTranslated(-0.2,-0.3,0); glRotated(-60,1,0,0); glutSolidCone(0.3,1, slices,stacks); glPopMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, ambsph); glMaterialfv(GL_FRONT, GL_DIFFUSE, diffsph); glMaterialfv(GL_FRONT, GL_SPECULAR, specsph); glPushMatrix(); glTranslated(0.4,0,-1.1); glRotated(-60,1,0,0); glutSolidSphere(0.3, slices, stacks); glPopMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, ambcyl); glMaterialfv(GL_FRONT, GL_DIFFUSE, diffcyl); glMaterialfv(GL_FRONT, GL_SPECULAR, speccyl); glPushMatrix(); glTranslated(0.7,-0.38,0); glRotated(160,1,0,-1); GLUquadricObj *quadric = gluNewQuadric(); GLUquadricObj *bottom = gluNewQuadric(); GLUquadricObj *top = gluNewQuadric(); //gluQuadricDrawStyle(quadric, GLU_FILL); gluCylinder(quadric, 0.1, 0.1, 1.2, slices, stacks); gluDisk (bottom, 0, 0.1, slices, stacks); glTranslated(0,0,1.2); gluDisk(top, 0, 0.1, slices, stacks); glPopMatrix(); 

But the objects still remain white! Objects

What to do with it?

  • Do you ask somehow glColor4fv? Try to make it black. - Unick
  • @Unick, is it necessary? - Byulent
  • Honestly, you use the render pipeline by default. This method has long been outdated and it is necessary to use shaders. You can read more in the documentation that he uses. But according to your screenshot, it looks like white is involved somewhere. And since in the materials you do not have it, glColor4fv remains. - Unick
  • @Unick, the fact is that I don’t ask glColor4fv in any way, and all manuals on the Internet say that you can do without glColor 's. - Byulent

0