0% found this document useful (0 votes)
75 views6 pages

Assignment: Course Code: 422 Course Title: Computer Graphics Lab

This document is a computer graphics lab assignment submission. It contains code to draw an emoji using OpenGL graphics functions. The code defines a circle drawing function and uses it along with translations and color settings to draw different colored circles representing the features of an emoji face. It initializes an OpenGL window, sets the display callback to the drawing function, and enters the main loop to display the emoji graphics.

Uploaded by

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

Assignment: Course Code: 422 Course Title: Computer Graphics Lab

This document is a computer graphics lab assignment submission. It contains code to draw an emoji using OpenGL graphics functions. The code defines a circle drawing function and uses it along with translations and color settings to draw different colored circles representing the features of an emoji face. It initializes an OpenGL window, sets the display callback to the drawing function, and enters the main loop to display the emoji graphics.

Uploaded by

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

Assignment

Course Code: 422


Course Title: Computer
Graphics Lab

Submitted To:
Name: Mst. Israt Jahan
Lecture
Department of
CSE
Daffodil International University

Submitted By:
Name: Monjur Hasan Milton

ID:171-15-9220
Section: O-7
Emoji Code:
#include <windows.h>
#include <GL/glut.h>
#include <stdlib.h>
#include <math.h>

static float tx = 0.0;


static float ty = 0.0;

void init()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glOrtho(-15,15,-15,15,-15,5);
}
void circle(GLfloat rx,GLfloat ry,GLfloat cx,GLfloat
cy)//radius_x,radius_y,certre_position_x,centre_position_y
{

glBegin(GL_TRIANGLE_FAN);
glVertex2f(cx,cy);

for(int i=0;i<=100;i++)
{
float angle = 2 * 3.1416f * i/100;

float x = rx * cosf(angle);
float y = ry * sinf(angle);

glVertex2f((x+cx),(y+cy));
}
glEnd();
}

void myDisplay()
{
glClear(GL_COLOR_BUFFER_BIT);

glColor3f(1.0f, 1.0f, 0.0f);


glPushMatrix();
glTranslatef(2,8,0);
circle(5,5,0,0);
glPopMatrix();
glColor3f(1.0f, 1.0f, 1.0f);
glPushMatrix();
glTranslatef(0,9,0);
circle(1.8,1.7,0,0);
glPopMatrix();

glColor3f(0.0f, 0.0f, 0.0f);


glPushMatrix();
glTranslatef(0,8.8,0);
circle(1,1,0,0);
glPopMatrix();

glColor3f(1.0f, 1.0f, 1.0f);


glPushMatrix();
glTranslatef(4,9,0);
circle(1.8,1.7,0,0);
glPopMatrix();

glColor3f(0.0f, 0.0f, 0.0f);


glPushMatrix();
glTranslatef(4,8.8,0);
circle(1,1,0,0);
glPopMatrix();
glColor3f(1.0f, 0.0f, 0.0f);
glPushMatrix();
glTranslatef(1.8,5,0);
circle(1,1,0,0);
glPopMatrix();

glFlush();
}
int main()
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(600, 600);
glutInitWindowPosition(200, 200);
glutCreateWindow("Emoji drawing");
init();
glutDisplayFunc(myDisplay);
glutMainLoop();
return 0;
}

You might also like