Hello,
I am doing my project now...wat i need 2 do now is wanna drawing a simple circle.....who can tell me how should i draw a circle with a GL_LINE_LOOP or GL_POLYGON...??
Thank you.
Hello,
I am doing my project now...wat i need 2 do now is wanna drawing a simple circle.....who can tell me how should i draw a circle with a GL_LINE_LOOP or GL_POLYGON...??
Thank you.
Hi !
With GL_LINE_LOOP you will get a circle, with GL_POLYGON you break down the "circle" into triangles, so if you just want a circle, use GL_LINE_LOOP if you intend to fill it with color or texture then use GL_POLYGON (a disk).
Mikael
play with this:
Code :GLfloat r = 1.; glBegin(GL_LINE_LOOP); for(float phi = 0; phi <= 2*M_PI; phi += M_PI/10.) glVertex3f(r*cos(phi), r*sin(phi), 0.); glEnd();
hello,I am also a beginner,I am thinking if do like that,would i gain a circle not filled?Originally posted by GreetingsFromMunich:
play with this:
Code :GLfloat r = 1.; glBegin(GL_LINE_LOOP); for(float phi = 0; phi <= 2*M_PI; phi += M_PI/10.) glVertex3f(r*cos(phi), r*sin(phi), 0.); glEnd();
3Q
I am only a VC beginner
Yes, you will get lines, that's the idea with GL_LINE_LOOP, if you replace GL_LINE_LOOP with GL_POLYGON you will get a filled circle instead (if you have setup the correct polygon mode).
Mikael
for a filled circle i'd rather use a triangle fan than a polygon:
the first vertex defines the center, the vertices in the for-loop lie on the perimeterCode :GLfloat r = 1.; glBegin(GL_TRIANGLE_FAN); glVertex3f(0., 0., 0.); for(float phi = 0; phi <= 2*M_PI; phi += M_PI/10.) glVertex3f(r*cos(phi), r*sin(phi), 0.); glEnd();
Thank you very muchOriginally posted by mikael_aronsson:
Yes, you will get lines, that's the idea with GL_LINE_LOOP, if you replace GL_LINE_LOOP with GL_POLYGON you will get a filled circle instead (if you have setup the correct polygon mode).
Mikael
I am only a VC beginner