0% found this document useful (0 votes)
5 views5 pages

Task 1

The document contains a C++ program using OpenGL and GLUT to create a graphical window displaying several colored polygons and outlines. The program initializes the OpenGL environment, sets up the projection, and defines the display function to render shapes. It creates a window titled 'Munif Mubtashim 22-48529-3' with specific dimensions and executes the rendering loop.

Uploaded by

codex0224
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Task 1

The document contains a C++ program using OpenGL and GLUT to create a graphical window displaying several colored polygons and outlines. The program initializes the OpenGL environment, sets up the projection, and defines the display function to render shapes. It creates a window titled 'Munif Mubtashim 22-48529-3' with specific dimensions and executes the rendering loop.

Uploaded by

codex0224
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Task-1:

CODE HERE:

#include <GL/glut.h>

void display() {
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glColor3f(1.0, 1.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(-0.7, 0.3);
glVertex2f(-0.3, 0.3);
glVertex2f(-0.3, 0.7);
glVertex2f(-0.7, 0.7);
glEnd();
glColor3f(1.0, 1.0, 0.0);
glBegin(GL_LINE_LOOP);
glVertex2f(-0.7, 0.3);
glVertex2f(-0.3, 0.3);
glVertex2f(-0.3, 0.7);
glVertex2f(-0.7, 0.7);
glEnd();
glColor3f(1.0, 0.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.2);
glVertex2f(-0.1, -0.2);
glVertex2f(-0.1, 0.2);
glVertex2f(-0.5, 0.2);
glEnd();
glColor3f(1.0, 0.0, 1.0);
glBegin(GL_LINE_LOOP);
glVertex2f(-0.5, -0.2);
glVertex2f(-0.1, -0.2);
glVertex2f(-0.1, 0.2);
glVertex2f(-0.5, 0.2);
glEnd();
glColor3f(1.0, 1.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(0.3, 0.1);
glVertex2f(0.7, 0.1);
glVertex2f(0.5, 0.4);
glEnd();
glColor3f(1.0, 1.0, 0.0);
glBegin(GL_LINE_LOOP);
glVertex2f(0.3, 0.1);
glVertex2f(0.7, 0.1);
glVertex2f(0.5, 0.4);
glEnd();
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(0.3, 0.1);
glVertex2f(0.7, 0.1);
glVertex2f(0.5, -0.2);
glEnd();
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINE_LOOP);
glVertex2f(0.3, 0.1);
glVertex2f(0.7, 0.1);
glVertex2f(0.5, -0.2);
glEnd();

glFlush();
}
void init() {
glClearColor(1.0, 0.0, 0.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-1, 1, -1, 1);
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500, 500);
glutCreateWindow("Munif Mubtashim 22-48529-3");

init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
OUTPUT SCREENSHOT:

You might also like