#### Archived

This topic is now archived and is closed to further replies.

# beginner - rendering confusion.

This topic is 5295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i thought i understood the concept of glPushMatrix(), but im not so sure anymore. I am following NeHe''s tutorials.
glTranslatef(0.0f,0.0f,-9.0f);

glPushMatrix();
glColor3f(1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 0.0f);				// Top Left

glVertex3f( 1.0f, 1.0f, 0.0f);				// Top Right

glVertex3f( 1.0f,-1.0f, 0.0f);				// Bottom Right

glVertex3f(-1.0f,-1.0f, 0.0f);				// Bottom Left

glEnd();
glPopMatrix();

glPushMatrix();
glTranslatef(-1.0f, 0.0f, 1.0f);
glColor3f(1.0f, 0.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 0.0f);				// Top Left

glVertex3f( 1.0f, 1.0f, 0.0f);				// Top Right

glVertex3f( 1.0f,-1.0f, 0.0f);				// Bottom Right

glVertex3f(-1.0f,-1.0f, 0.0f);				// Bottom Left

glEnd();
glPopMatrix();

that code should draw two square, one white and the other purple or something. but the colors appear to be off, for example, the first square is not white. more importantly, commenting out the glPushMatrix and glPopMatrix yields very different results. how does openGL work?

##### Share on other sites
glPushMatrix(); has nothing to do with the colors.
glColor3f(1.0f, 1.0f, 1.0f); and glColor3f(1.0f, 0.0f, 1.0f); changes the color.

##### Share on other sites
I think what you need is to read a little about matrixes if you don''t know how they work. There are A LOT of matrix questions, so maybe you should consider reading them. It will help you when your objects are going to twist and move and so on.

##### Share on other sites
my number one point of confusion is the color3f.

isn''t (1.0f, 1.0f, 1.0f) the color white?

well, my opengl app fills the shape as a shade of light yellow-tanish color. very subtle. it should be pure, bright white...no?

##### Share on other sites
Are you using a light source at all? The colour of the light will effect the colour of your poly.

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633409
• Total Posts
3011702
• ### Who's Online (See full list)

There are no registered users currently online

×