Skip to main content
GameDev.net gamedev.net
🔒 Locked

Flat Donut

Started by LarrxX Mar 31, 2004 at 3:04 AM 2 replies 400+ views
Original Post
LarrxX
LarrxX
I''m looking to draw a band between 2 concentric circles (like a flat donut) using only triangles with openGL. Can anyone help? (I know there''s the gluPartialDisk() method, but it doesn''t use separate triangles). Thanx.
szinkopa
szinkopa
Use trianglestrip like this

int N;//Number Of Triangles

double pi=4*atan(1);
double twopi=2*pi;

double r,R;//the inner and outer radius

glBegin(GL_TRIANGLE_STRIP);
for(i=0;i {
sn=sin(i/N * twopi);
cs=cos(i/N * twopi);
if(i&1) //i odd
{
glVertex(r*cs,r*sn,0);
}
else//i even
{
glVertex(R*cs,R*sn,0);
}
}
glEnd();


It may not work properly, I did not try it, but I would make it this way, with some optimizations.

Topic Locked

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

Sign in to reply to this topic.