-
-
Save jchain/3022588 to your computer and use it in GitHub Desktop.
xxx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************************************** | |
** Draw a cone ** | |
***************************************************/ | |
void DrawCone() | |
{ | |
float angle; | |
float weight; | |
float red_component; | |
float blue_component; | |
// Draw conical part, including 40+ triangles | |
glBegin( GL_TRIANGLE_FAN ); | |
// The tip of the cone is green | |
glColor3f( 0.0, 1.0, 0.0 ); | |
// The tip of the cone at (0,0,2) | |
glVertex3f( 0.0, 0.0, 2.0 ); | |
for ( int i = 0; i < 40; i++ ) { | |
angle = i*2*PI / 39; | |
if ( i < 21 ) { | |
weight = i / 20.0; | |
} | |
else { | |
weight = 1.0 - ( i - 20 ) / 20.0; | |
} | |
red_component = 1.0 * weight; | |
blue_component = 1.0 * ( 1.0 - weight ); | |
glColor3f( red_component, 0.0, blue_component ); | |
glVertex3f( cos( angle ), sin( angle ), 0.0 ); | |
} | |
glEnd(); | |
// Draw base part, including 40+ triangles | |
glBegin( GL_TRIANGLE_FAN ); | |
// The tip of the cone is green | |
//glColor3f( 0.0, 1.0, 0.0 ); | |
// The tip of the cone at (0,0,0) | |
glVertex3f( 0.0, 0.0, 0.0 ); | |
for ( int i = 0; i < 40; i++ ) { | |
angle = i*2*PI / 39; | |
if ( i < 21 ) { | |
weight = i / 20.0; | |
} | |
else { | |
weight = 1.0 - ( i - 20 ) / 20.0; | |
} | |
red_component = 1.0 * weight; | |
blue_component = 1.0 * ( 1.0 - weight ); | |
glColor3f( red_component, 0.0, blue_component ); | |
glVertex3f( cos( angle ), sin( angle ), 0.0 ); | |
} | |
glEnd(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment