Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Assignment (Shahid Minar Of BD )

Course Name: Computer Graphics Lab


Course Code: CSE422
Submitted To
Ms.Nazmun Nessa Moon
Associate Professor
Faculty :FSIT
Daffodil International University
Submitted By
Name: Rudra Das
ID:201-15-13831

Department: CSE

Section: C

Daffodil International University

Submission date: 09/05/2022


Input :

#include <GL/gl.h>

#include <GL/glut.h>

#include <iostream>

int a1, b1;

void display(void)

glClear(GL_COLOR_BUFFER_BIT);

a1 = 0;

b1 = 135;

int p = 1 - b1;

while (b1 > a1)

if (p < 0) {

a1++;

p += 2 * a1 + 1;

else {

b1--; a1++;
p += 2 * (a1 - b1) + 1;

glBegin(GL_POLYGON);

glColor3f(1.0, 0.0, 0.0);

glVertex2i(a1, b1);

glVertex2i(-a1, b1);

glVertex2i(a1, -b1);

glVertex2i(-a1, -b1);

glVertex2i(b1, a1);

glVertex2i(-b1, a1);

glVertex2i(b1, -a1);

glVertex2i(-b1, -a1);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(-400, -200);

glVertex2i(-400, -220);

glVertex2i(400, -220);

glVertex2i(400, -200);
glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(-20, 140);

glVertex2i(-20, -200);

glVertex2i(20, -200);

glVertex2i(20, 140);

glVertex2i(-10, 250);

glVertex2i(-50, 250);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(-80, 140);

glVertex2i(-80, -200);

glVertex2i(-50, -200);

glVertex2i(-50, 140);

glVertex2i(-80, 250);

glVertex2i(-110, 250);

glEnd();
glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(50, 140);

glVertex2i(50, -200);

glVertex2i(80, -200);

glVertex2i(80, 140);

glVertex2i(50, 250);

glVertex2i(20, 250);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(-100, 250);

glVertex2i(-100, 230);

glVertex2i(50, 230);

glVertex2i(50, 250);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);


glVertex2i(-220, 90);

glVertex2i(-220, -200);

glVertex2i(-200, -200);

glVertex2i(-200, 90);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(-160, 70);

glVertex2i(-160, -200);

glVertex2i(-140, -200);

glVertex2i(-140, 70);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(-220, 100);

glVertex2i(-220, 80);

glVertex2i(-140, 50);

glVertex2i(-140, 70);

glEnd();
glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(140, 70);

glVertex2i(140, -200);

glVertex2i(160, -200);

glVertex2i(160, 70);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(200, 90);

glVertex2i(200, -200);

glVertex2i(220, -200);

glVertex2i(220, 90);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(140, 70);

glVertex2i(140, 50);
glVertex2i(220, 80);

glVertex2i(220, 100);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(-350, -10);

glVertex2i(-350, -200);

glVertex2i(-330, -200);

glVertex2i(-330, -10);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(-290, -20);

glVertex2i(-290, -200);

glVertex2i(-270, -200);

glVertex2i(-270, -20);

glEnd();

glBegin(GL_POLYGON);
glColor3ub(128, 128, 128);

glVertex2i(-350, 0);

glVertex2i(-350, -20);

glVertex2i(-270, -40);

glVertex2i(-270, -20);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(270, -30);

glVertex2i(270, -200);

glVertex2i(290, -200);

glVertex2i(290, -30);

glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(330, -20);

glVertex2i(330, -200);

glVertex2i(350, -200);

glVertex2i(350, -20);
glEnd();

glBegin(GL_POLYGON);

glColor3ub(128, 128, 128);

glVertex2i(270, -20);

glVertex2i(270, -40);

glVertex2i(350, -20);

glVertex2i(350, 0);

glEnd();

glFlush();

void init(void)

glClearColor(1.0, 1.0, 1.0, 0.0);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(-500, 500, -500, 500);

}
int main(int argc, char** argv)

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

glutInitWindowSize(500, 500);

glutInitWindowPosition(100, 100);

glutCreateWindow("201-15-13831");

init();

glutDisplayFunc(display);

glutMainLoop();

return 0;

OutPut :

You might also like