|
Post by confused on Jul 11, 2004 22:33:36 GMT -5
can someone guide me through basic4gl...i really dont understand the tutorial... like how to make polygons and things....please someone help me..
|
|
|
Post by Ranger1800 on Jul 12, 2004 14:19:01 GMT -5
Making Squares, Polygons, and Triangles are easy it only takes a few lines to make a 2 dimensional polygon i would start here and keep practicing this method before you go on to 3d polygons heres a small code example:
glTranslatef(0, 0, -4) glBegin(Gl_Triangles) glColor3f(1, 0, 0): glVertex2f( 0, 1) glColor3f(0, 1, 0): glVertex2f(-1,-1) glColor3f(0, 0, 1): glVertex2f( 1,-1) glEnd() SwapBuffers()
Let me go over these one by one first off the line glTranslatef Initialises the viewport it basically draws the screen your going to use now on to the next one glBegin sets up Opengl it basically allows you to use Opengl commands and inside the () is where you specify what shape you want to draw onto the screen and the glColor#f allows you to specify what color you want to paint in a certain area of the object your making (where the # is, this is where you specify how many colors you will be using for this object) for instance glColor4f(#, #, #, #) this allows you to use four colors these are used inside the brackets. Now glVertex is where you specify where you draw your points for the object, inside the brackets this is where you plot points to draw the object. On to glEnd() this exits you out of the Opengl program. Now SwapBuffers() is the most important part of any Opengl program what this does is renders everything to the screen basically draws everything you made in the GlColor and GlVertex commands without the SwapBuffers command you won't be able to see anything. I hope this helped
-Branden
|
|