-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwheels.cpp
More file actions
90 lines (68 loc) · 2.06 KB
/
wheels.cpp
File metadata and controls
90 lines (68 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <cstdlib>
#include <iostream>
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/freeglut.h>
using namespace std;
// ----------------------------------------------------------------------
// CS 218 -> Assignment #10
// Wheels Program.
// Provided main...
// Uses openGL (which must be installed).
// openGL installation:
// sudo apt-get update
// sudo apt-get upgrade
// sudo apt-get install freeglut3-dev
// Compilation:
// g++ -Wall -pedantic -g -c wheels.cpp -lglut -lGLU -lGL -lm
// ----------------------------------------------------------------------
// External functions (in seperate file).
extern "C" void drawWheels();
extern "C" int getParams(int, char* [], int *, int *, int *);
// ----------------------------------------------------------------------
// Global variables
// Must be GLOABBBLY accessible for THE openGL
// display routine, drawWheels().
int color = 0; // draw color
int size = 0; // screen size
int speed = 0; // draw speed
// ----------------------------------------------------------------------
// Key handler function.
// Terminates for 'x', 'q', or ESC key.
// Ignores all other characters.
void keyHandler(unsigned char key, int x, int y)
{
if (key == 'x' || key == 'q' || key == 27) {
glutLeaveMainLoop();
exit(0);
}
}
// ----------------------------------------------------------------------
// Main routine.
int main(int argc, char* argv[])
{
int height = 0;
int width = 0;
bool stat;
stat = getParams(argc, argv, &speed, &color, &size);
height = size;
width = size;
// Debug call for display function
// drawWheels();
if (stat) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowSize(width, height);
glutInitWindowPosition(200, 100);
glutCreateWindow("CS 218 Assignment #10 - Wheels Program");
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.5, 1.5, -1.5, 1.5, 0.0, 1.0);
glutKeyboardFunc(keyHandler);
glutDisplayFunc(drawWheels);
glutMainLoop();
}
return 0;
}