CS602 2 Assignment Solution
CS602 2 Assignment Solution
CS602 2 Assignment Solution
Assignment # 02 Deadline
th
29 of August, 2022
Spring 2022
Please carefully read the following instructions before attempting the assignment.
You are required to submit your solution through LMS in zip format containing
following files.
Your Project in zipped form containing both .cpp and .exe file.
The word document (.doc/docx) or any other file format containing code will
not be considered. And rewarded by zero marks.
If the code file or exe file is missing in zip folder, your assignment will be
awarded as zero.
OBJECTIVE
The objective of this assignment is to:
Learn and practice basic concepts of 2D transformation with drawing shapes using OpenGL
libraries.
Learn to draw shapes and patterns by using OpenGL libraries functions and transform them.
Instructions:
You have to do the following steps first in order to perform the task.
Install Dev-C++ from your LMS.
Read out the file “How to instal and Program with Glut (OpenGL Utility) Libraires” thoroughly
and follow the instructions in the file properly provided to you on your LMS.
NOTE
No assignment will be accepted after the due date via email in any case (whether it is the case of load
shedding or internet malfunctioning etc.). Hence refrain from uploading assignments in the last hour
of the deadline. It is recommended to upload the solution file at least two days before its closing date.
If you people find any mistake or confusion in the assignment (Question statement), please consult
with your instructor before the deadline. After the deadline, no queries will be entertained in this
regard.
For any query, feel free to email at:
Cs602@vu.edu.pk
Below images are the different shapes of Mechanical arm and its movements.
Code:
#ifdef _APPLE_CC
#include<GLUT/glut.h>
#else
#include<GL/glut.h>
#include<stdlib.h>
#endif
static int shoulderAngle = 0, elbowAngle = 0;
void special(int key, int, int) {
switch (key) {
default: return;
}
glutPostRedisplay();
}
glPushMatrix();
glPopMatrix();
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(2.2, 0.9, 0.5);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
drawString(0.2, 2.5, 0.0,"bc210209446");
glPopMatrix();
glFlush();
}
void reshape(GLint w, GLint h) {
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(65.0, GLfloat(w)/GLfloat(h), 1.0, 20.0);
void init(){
glShadeModel(GL_FLAT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(1,2,8,0,0,0,0,1,0);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(80, 80);
glutInitWindowSize(800, 600);
glutCreateWindow("BC190409022");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutSpecialFunc(special);
init();
glutMainLoop();
Output: