OpenGL

Jun 15, 2011 at 10:27pm
Hi there!!

I've been doing a bit of OpenGL lately, and I manage to get a spinning cube on the screen, but I don't understand the following, can anyone please explain?
1
2
3
4
5
6
7
8
glBegin(GL_QUADS);

glVertex3f(-50.f, -50.f, -50.f);
glVertex3f(-50.f, -50.f, 50.f);
glVertex3f(50.f, 50.f, 50.f);
glVertex3f(50.f, 50.f, -50.f);
...
glEnd();



That is just for one side of the cube, but I would like to fully understand vertexes.

Regards
FR3DDIE
Jun 16, 2011 at 4:39am
Imagine a rectangle. The upper-left vertex will be A; the upper-right, B; the lower-right, C; and the lower-left, D.
Quads are typically given in ABCD (or clockwise) order. I'm not sure what happens if you give it in ADCB (or counter-clockwise) order; I presume the normal will point in the opposite direction, but I don't know that for a fact.

Did that answer your question?
Jun 16, 2011 at 7:33am
Yes, in a way... I don't understand the values, for example how do I know when it should be -50.f or just 50.f?
Jun 16, 2011 at 8:14am
@helios

Yes, the normal will point the other way, forward faces are anticlockwise. You can change this with an option, but I forget the name of the call.

@FR3DDIE

You will have at some point done something to the projection matrix. This is used to set up your coordinate system, so whether the screen is 3 units or 3000 wide. Also, objects normally have their center at (0,0,0) this allows you to rotate them easily. So because the center is at (0,0,0) some vertices will be negative, and others positive.
Last edited on Jun 16, 2011 at 8:15am
Jun 16, 2011 at 8:21am
Now I get it.

Thanks
FR3DDIE
Topic archived. No new replies allowed.