The code is as follows:
#include <windows.h>//#include <GLUT/glut.h>#include <GL/glut.h>#include<math.h>#include<iostream>using namespacestd;#defineGl_pi 3.1415fvoidRenderscene () {glfloat x,y,angle; intIpivot =1; Glclear (Gl_color_buffer_bit|gl_depth_buffer_bit); Glboolean Bcull=true; Glboolean bdepth=true; Glboolean Boutline=true; if(bcull) glenable (gl_cull_face); Elsegldisable (gl_cull_face); if(bdepth) glenable (gl_depth_test); Elsegldisable (gl_depth_test); if(Boutline) Glpolygonmode (gl_back,gl_line); ElseGlpolygonmode (Gl_back,gl_fill); Glpushmatrix (); Glrotatef (45.0f,1.0f,0.0f,0.0f); Glrotatef (45.0f,0.0f,1.0f,0.0f); Glbegin (Gl_triangle_fan); glvertex3f (0.0f,0.0f,75.0f); for(angle =0.0f; Angle < (2.0*GL_PI) Angle + = (GL_PI)/8.0) {x=50.0f*sin (angle); Y=50.0f*cos (angle); if((Ipivot%2)==0) glcolor3f (0.0f,0.0f,1.0f); Elseglcolor3f (1.0f,0.0f,0.0f); Ipivot++; glvertex2f (x, y); } glend (); Glbegin (Gl_triangle_fan); GLVERTEX2F (0.0f,0.0f); for(angle =0.0f; Angle < (2.0f*GL_PI); angle + = (gl_pi/8.0f) ) {x=50.0f*sin (angle); Y=50.0f*cos (angle); if((Ipivot%2)==0) glcolor3f (0.0f,0.0f,1.0f); Elseglcolor3f (1.0f,0.0f,0.0f); Ipivot++; glvertex2f (x, y); } glend (); Glpopmatrix (); Glutswapbuffers ();}voidchangesize (Glsizei w,glsizei h) {if(h==0) H=1; Glfloat Aspectratio= (glfloat) w/(glfloat) H; Glviewport (0,0, w,h); Glmatrixmode (gl_projection); Glloadidentity (); if(w<=h) Glortho (- -, -,- -/aspectratio, -/aspectratio,100.0,-100.0); ElseGlortho (- -*aspectratio, -*aspectratio,- -, -,100.0,-100.0); Glmatrixmode (Gl_modelview); Glloadidentity ();}voidSETUPRC () {Glclearcolor (0.0f,0.0f,0.0f,1.0f); glcolor3f (1.0f,0.0f,0.0f); Glshademodel (Gl_flat); Glfrontface (GL_CW);}intMainintargcChar*argv[]) {Glutinit (&argc,argv); Glutinitdisplaymode (glut_double| glut_rgb|glut_depth); Glutinitwindowsize ( -, -); Glutcreatewindow (" Simple"); Glutdisplayfunc (Renderscene); Glutreshapefunc (changesize); SETUPRC (); Glutmainloop (); return 0;}
Solid object creation