Skip to main content
gamedev.net
🔒 Locked

question

Started by Directx_Hater 2 replies 300+ views
Original Post
Directx_Hater
Directx_Hater
Hello, i still studying NeHe turorial but is one function i still don''t get. is the drawing glVertex3f() glBegin(GL_QUADS); // Draw A Quad 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(); // Done Drawing The Quad return TRUE; this is draw square right, well how do you know where to put -1.0f etc.. does it go higher then 1.0 ? like 2.4f 5.6f etc.. or is a small tutorial the explain this glVertexef() even more?
Willbo
Willbo
Well, those are only coordinates. Try chaning them and run the application, you probably see what happens. Here's an easy explanation. Go get a piece of papper, I'll wait... Now draw a pretty large + on the papper. on the horizontal line to the right, draw a small 'x'. and on the top of the vertical line, draw a 'y', now draw a small vertical line on the horizontal line to the right in the middle. And on the other side and on the vertical line. Then we plot out our coords on it, I done a REAL crappy illustration of how it should look like, or resemble or something like that. The asterix indicates our vertex points, drawing lines between them completes our polygon!
Check at your glVertex3f function and put the pen on the first asterix, then draw a straight line between that and your second vertex line. then between that and the third. Imagine a diagonal line between the first and the third and you have a triangle! Keep the pen down and draw a line straight to the left to your fourth vertex, and that completes the quad!


      
*(-1,1) --- y *(1,1)
|
-+-
| x
|----|----|----|----|
|
-+-
|
*(-1,-1) --- *(1,-1)


Then, yes it can go higher too! Experiment with your program a little, try changing from GL_QUAD to GL_LINES , GL_POINTS , GL_TRIANGLES and see the diffrence. You're basically just telling OpenGL how to draw it.

(This most have been the most complex and longest explanation to such a simple question! Cheers!

- Patrik Willbo

The Lord says He can get me out of this mess, but He's pretty sure you're fucked.
- Stephen (Braveheart)


[edited by - Willbo on April 26, 2003 7:28:47 PM]
Directx_Hater
Directx_Hater
oh yeah!!, i remember this in math. Thank you for the reminder.
Willbo
Willbo
Then if your still going in school, never miss a math or a physics class!! You''ll have much use of what they teach there!

Happy coding!

- Patrik Willbo

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.