lights and colors
Hello,
I have a problem with light and colors in openGl.
I just want to experiment with some material attributes.
So I do not want to define Colors with glColor3f, but I want to use the reflexion of the material and the color of the light for coloring my objects.
my Code looks like this:
first I programm a diffuse/ambient light
glLightf(GL_LIGHT0,GL_AMBIENT,(1.0f , 1.0f , 1.0f , 1.0f ));
glLightf(GL_LIGHT0,GL_DIFFUSE,(0.8f , 0.8f , 0.8f , 1.0f ));
glEnable( GL_LIGHT0);
glEnable( GL_LIGHTING);
then I draw a Quad with material attributes
glBegin(GL_QUADS);
glMaterialf(GL_FRONT,GL_AMBIENT_AND_DIFF USE,(1.0f ,0.0f ,0.0f ));
glNormal3f(0.0f,0.0f,1.0f);
glVertex3f(-4.0f, 4.0f, 1.0f);
glVertex3f(4.0f, 4.0f, 1.0f);
glVertex3f(4.0f, -4.0f, 1.0f);
glVertex3f(-4.0f, -4.0f, 1.0f);
glEnd();
Now OpenGl draws my Quad in white (gray)! I thought the glMaterial command would reflekt red light from the quad so that it looks red in white light.
What am I doing wrong?
I don’t want to use the command glEnable(Color)!
thanks
Schmiid
You can't call glMaterial inside a glBegin/glEnd block; move it to right before glBegin(GL_QUADS).
there is no effect if I use glMaterialf before glBegin or not!
Is this all Code what I need or do I have to enable something more?
Schmiid
Is this all Code what I need or do I have to enable something more?
Schmiid
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement