CS602-Assignment 2 Solution Spring 2024
CS602-Assignment 2 Solution Spring 2024
Code:
#include <GL/glut.h>
#include <cmath>
#include <ctime>
#include <string>
// Window dimensions
CONTACT ON WHATSAPP
+923074960034
const int WINDOW _HEIGHT = 600;
// User ID
glRasterPos2f(x, y);
void drawClockFace()
CONTACT ON WHATSAPP
+923074960034
// Draw the circle
glBegin(GL_ LIN_LOOP);
glVertex2f(cos(theta), sin(theta));
}
glEnd();
float x1 = cos(theta);
float y1 = sin(theta);
glBegin(GL _LINES);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
glEnd();
}
CONTACT ON WHATSAPP
+923074960034
}
glBegin(GL _LINES);
glVertex2f(0.0, 0.0);
glEnd();
glBegin(GL_ LINES);
glVertex2f(0.0, 0.0);
glEnd();
CONTACT ON WHATSAPP
+923074960034
float hourAngle = degToRad(90 - (hour * 30 + minute * 0.5f));
glBegin(GL _LINES);
glVertex2f(0.0, 0.0);
glEnd();
void display() {
glLoadIdentity();
drawClockFace();
CONTACT ON WHATSAPP
+923074960034
int minute = utcTime->tm _min;
glLoadIdentity();
glColor3f(1.0, 1.0,
1.0);
glutSwapBuffers();
glutPostRedisplay();
void initOpenGL() {
CONTACT ON WHATSAPP
+923074960034
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL _PROJECTION);
glLoadIdentity();
glMatrixMode(GL _ MODELVIEW);
// Main function
glutInit(&argc, argv);
glutCreateWindow("Analog Clock");
initOpenGL();
glutDisplayFunc(display);
glutMainLoop();
return 0;
CONTACT ON WHATSAPP
+923074960034
CONTACT ON WHATSAPP
+923074960034
CONTACT ON WHATSAPP
+923074960034