How to draw a filled envelop like a cone on OpenGL (using GLUT)?

Posted by ashishsony on Stack Overflow See other posts from Stack Overflow or by ashishsony
Published on 2008-10-26T11:32:27Z Indexed on 2010/06/14 13:22 UTC
Read the original article Hit count: 262

Filed under:
|
|
|

Hi,

I am relatively new to OpenGL programming...currently involved in a project that uses freeglut for opengl rendering...

I need to draw an envelop looking like a cone (2D) that has to be filled with some color and some transparency applied.

Is the freeglut toolkit equipped with such an inbuilt functionality to draw filled geometries(or some trick)?? or is there some other api that has an inbuilt support for filled up geometries..

Thanks.

Best Regards.

Edit1: just to clarify the 2D cone thing... the envelop is the graphical interpretation of the coverage area of an aircraft during interception(of an enemy aircraft)...that resembles a sector of a circle..i should have mentioned sector instead..

and glutSolidCone doesnot help me as i want to draw a filled sector of a circle...which i have already done...what remains to do is to fill it with some color... how to fill geometries with color in opengl??

Thanks.

Edit2: Ok thanks for replying...all the answers posted to this questions can work for my problem in a way.. But i would definitely would want to know a way how to fill a geometry with some color. Say if i want to draw an envelop which is a parabola...in that case there would be no default glut function to actually draw a filled parabola(or is there any??).. So to generalise this question...how to draw a custom geometry in some solid color??

Thanks.

Edit3: The answer that mstrobl posted works for GL_TRIANGLES but for such a code:

glBegin(GL_LINE_STRIP);

glColor3f(0.0, 0.0, 1.0);
    glVertex3f(0.0, 0.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
    glVertex3f(200.0, 0.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
    glVertex3f(200.0, 200.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
    glVertex3f(0.0, 200.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
    glVertex3f(0.0, 0.0, 0.0);

glEnd();

which draws a square...only a wired square is drawn...i need to fill it with blue color.

anyway to do it?

if i put some drawing commands for a closed curve..like a pie..and i need to fill it with a color is there a way to make it possible...

i dont know how its possible for GL_TRIANGLES... but how to do it for any closed curve??

Thanks.

© Stack Overflow or respective owner

Related posts about c++

Related posts about opengl