opengl: modeling void drawpyramid(){ glbegin(gl_triangles); glvertex3f(0.0, 0.0, 0.0);...
TRANSCRIPT
![Page 1: OpenGL: Modeling void DrawPyramid(){ glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0,](https://reader036.vdocuments.us/reader036/viewer/2022072006/56649f565503460f94c79c03/html5/thumbnails/1.jpg)
OpenGL: Modelingvoid DrawPyramid(){ glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 0.0, 1.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0, 0.1, 0.0); glVertex3f(0.0, 0.0, 0.1); glEnd() ; }
![Page 2: OpenGL: Modeling void DrawPyramid(){ glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0,](https://reader036.vdocuments.us/reader036/viewer/2022072006/56649f565503460f94c79c03/html5/thumbnails/2.jpg)
Modeling: Conevoid DrawCone(int res){ GLfloat d = 2*PI/res ; GLfloat a = 0; glBegin(GL_TRIANGLE_FAN); glVertex3f(0.0, 0.0, 0.0); for (int i = 0 ; i < res ; i++ ){ glVertex3f(cos(a), sin(a), 0.0); a += d ; } glEnd() ; a = 0.0 ; glBegin(GL_TRIANGLE_FAN); glVertex3f(0.0, 0.0, 1.0); for (int i = 0 ; i < res ; i++ ){ glVertex3f(cos(a), sin(a), 0.0); a += d ; } glEnd() ; }
![Page 3: OpenGL: Modeling void DrawPyramid(){ glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0,](https://reader036.vdocuments.us/reader036/viewer/2022072006/56649f565503460f94c79c03/html5/thumbnails/3.jpg)
Modeling: cylindervoid DrawCylinder (int res){ GLfloat a, d = 2*PI/res ; glBegin(GL_TRIANGLE_FAN); glVertex3f(0.0, 0.0, 0.0); for (int i = 0, a = 0 ; i < res ; i++,a += d ) glVertex3f(cos(a), sin(a), 0.0); glEnd() ; glBegin(GL_TRIANGLE_FAN); glVertex3f(0.0, 0.0, 1.0); for ( i = 0, a = 0 ; i < res ; i++, a += d ) glVertex3f(cos(a), sin(a), 1.0); glEnd() ; glBegin(GL_TRIANGLE_STRIP); for ( i = 0 , a = 0 ; i < res; i++ , a += d) { glVertex3f(cos(a), sin(a), 0.0); glVertex3f(cos(a), sin(a), 1.0); } glEnd() ; }
![Page 4: OpenGL: Modeling void DrawPyramid(){ glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0,](https://reader036.vdocuments.us/reader036/viewer/2022072006/56649f565503460f94c79c03/html5/thumbnails/4.jpg)
Scene // Set UpglViewport(0,0,w,h);glMatrixMode(GL_PROJECTION);glLoadIdentity() ;
glOrtho(-100,100,-100,100,-100,100);glMatrixMode(GL_MODELVIEW);glLoadIdentity();
// Draw SceneglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Draw Cylinder glPushMatrix() ;glRotate(90, 1,0,0);glTranslate(0,0,10);glScale(10,10,10)DrawCylinder(50);glPopMatrix() ;
![Page 5: OpenGL: Modeling void DrawPyramid(){ glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0,](https://reader036.vdocuments.us/reader036/viewer/2022072006/56649f565503460f94c79c03/html5/thumbnails/5.jpg)
Scene // Draw CubeglPushMatrix() ;glTranslate(10,0,2);glScale(5,10,5)DrawCube(10);glPopMatrix() ;// Draw ConesglPushMatrix() ;glRotate(90, 0,1,0);glRotate(45, 0,0,1);glPushMatrix();glTranslate(5,0,5);glScale(5,5,5)DrawCone(10);glPopMatrix() ;glTranslate(5,10,5);glScale(10,10,10);DrawCone(10);glPopMatrix() ;