-
Notifications
You must be signed in to change notification settings - Fork 0
/
glCanvas.h
86 lines (70 loc) · 1.96 KB
/
glCanvas.h
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
#ifndef _GL_CANVAS_H_
#define _GL_CANVAS_H_
#include <cstdio>
#include <cstdlib>
#include <string>
// Included files for OpenGL Rendering
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#define GL_GLEXT_PROTOTYPES
#ifdef _WIN32
#define GLUT_DISABLE_ATEXIT_HACK
#include <GL/glew.h>
#endif
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#ifdef _WIN32
#include "GL/wglew.h"
#endif
#endif
#include "vectors.h"
class ArgParser;
class Mesh;
class Camera;
class Hemisphere;
class Forest;
// ====================================================================
// NOTE: All the methods and variables of this class are static
// ====================================================================
class GLCanvas {
public:
// Set up the canvas and enter the rendering loop
// Note that this function will not return but can be
// terminated by calling 'exit(0)'
static void initialize(ArgParser *_args, Mesh* _mesh, Hemisphere* _hemisphere, Forest* _forest);
private:
static void InitLight();
// various static variables
static ArgParser *args;
static Mesh* mesh;
static Camera *camera;
static Hemisphere* hemisphere;
static Forest* forest;
// state of the mouse cursor
static int mouseButton;
static int mouseX;
static int mouseY;
static bool shiftPressed;
static bool controlPressed;
static bool altPressed;
//State of some keys
static bool key_w;
static bool key_a;
static bool key_s;
static bool key_d;
// Callback functions for mouse and keyboard events
static void display(void);
static void reshape(int w, int h);
static void mouse(int button, int state, int x, int y);
static void motion(int x, int y);
static void keyboard(unsigned char key, int x, int y);
static void keyboardUp(unsigned char key, int x, int y);
static void idle();
};
// ====================================================================
int HandleGLError(const std::string &message = "");
#endif