2 // For initializing the random number generator.
14 #include <GL/freeglut.h>
26 static void render() {
31 static void resized(int width
, int height
) {
32 shady
->resized(width
, height
);
35 static void normalKeyPressed(unsigned char key
, int x
, int y
) {
36 shady
->normalKeyPressed(key
, x
, y
);
39 static void specialKeyPressed(int key
, int x
, int y
) {
40 shady
->specialKeyPressed(key
, x
, y
);
43 static void mouseDragged(int x
,int y
) {
44 shady
->mouseDragged(x
, y
);
47 static void mouseClicked(int button
, int state
, int x
, int y
) {
48 shady
->mouseClicked(button
, state
, x
, y
);
52 int main(int argc
, char ** argv
) {
54 OUT(OUT_SHELLCOMMAND(OUT_BRIGHT
) "Shady - OpenGL playground" OUT_SHELLCOMMAND(OUT_RESET
));
56 OUT("usage: shady <postprocess>...");
58 glutInit(&argc
, argv
);
61 for(int i
= 1; i
< argc
; i
++) {
62 pps
.push_back(argv
[i
]);
65 // TODO generalize keybindings
66 OUT("Movement: " OUT_COLORED(OUT_GREEN
, "WASD"));
67 OUT("Height: " OUT_COLORED(OUT_GREEN
, "Q/E"));
68 OUT("Rotation: " OUT_COLORED(OUT_GREEN
, "mouse") " (drag) and " OUT_COLORED(OUT_GREEN
, "arrow keys"));
69 OUT("Radius: " OUT_COLORED(OUT_GREEN
, "+/-"));
70 OUT("Var: " OUT_COLORED(OUT_GREEN
, "*") " and " OUT_COLORED(OUT_GREEN
, "/"));
71 OUT("Reset view: " OUT_COLORED(OUT_GREEN
, "backspace"));
72 OUT("New world: " OUT_COLORED(OUT_GREEN
, "space"));
74 // Initialize the random number generator for unique worlds.
75 srand(time(NULL
) / 2);
77 shady
= new Shady(pps
);
79 glutInitDisplayMode(GLUT_DEPTH
| GLUT_DOUBLE
| GLUT_RGBA
);
80 glutInitWindowSize(1024, 860);
82 glutCreateWindow("Shady");
85 ERROR("initializing shady");
90 // TODO disable key repeating for smoother movement
92 glutDisplayFunc(render
);
94 glutReshapeFunc(resized
);
95 glutKeyboardFunc(normalKeyPressed
);
96 glutSpecialFunc(specialKeyPressed
);
97 glutMouseFunc(mouseClicked
);
98 glutMotionFunc(mouseDragged
);
100 glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE
, GLUT_ACTION_CONTINUE_EXECUTION
);