Answer the question
In order to leave comments, you need to log in
Why are objects not being painted?
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);
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();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question