glVertex3f??!

Started by
20 comments, last by Noxir 18 years, 6 months ago
Without using any transforms, i.e. glRotate, glTranslate, glScale, etc, the camera it as the origin pointing down the negative z axis, the positive x axis is to the right and the positive y axis is up. Whether you actually see a point depends upon whether it is on the correct side of six planes. You have to be to the left of the right plane, right of the left, below the top, above the bottom, closer than far and further than near.

Getting started I would suggest using gluOrtho2D to setup the projection matrix. You specify left, right, top and bottom with near and far set to -1 and 1 for you. Then glVertex2f(x,y) will appear on the screen assuming the color is set appropriately and x is between left and right and y is between top and bottom. You won't see the effect of z other than it has to be between -1 and 1 for the point to be visible.
Keys to success: Ability, ambition and opportunity.
Advertisement
Quote:Original post by WarAmp
glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
// isnt this 1 unit left and 1 unit up? doesnt this mean that opengl is going to write a "\" ???
glVertex3f( 1.0f, 1.0f, 0.0f); // isn't this 1 unit right and 1 unit up? doesnt this mean that opengl is going to write a "/" ???
glVertex3f( 1.0f,-1.0f, 0.0f); // isn't this 1 unit right and 1 unit down? doesnt this mean that opengl is going to write a "\" ???
glVertex3f(-1.0f,-1.0f, 0.0f); // isn't this 1 unit left and 1 unit down? doesnt this mean that opengl is going to write a "/" ???
glEnd();


No, what glVertex3f does is simply set points, then the GL_QUADS tells Opengl that the points you are giving it are corners of Quads. So it simply 'connects the dots' to create a quad out of every 4 points you give it.

That code should create a single Quad, centered on the origin (0,0,0) that is 2 units on each side. (-1 to 1, -1 to 1, 0).


thanks man i finally figured out how it works

This topic is closed to new replies.

Advertisement