-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRenderer.h
84 lines (65 loc) · 2.4 KB
/
Renderer.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
// Author: [email protected] (Michael DiBernardo)
// Copyright Michael DiBernardo 2006
//
// Encapsulates the view/controller functions that are registered as callbacks
// with GLUT. For simplicity, we don't seperate the view and controller logic.
//
// The default renderer provides stubs for all implemented methods: That is,
// all of them do essentially nothing.
#ifndef __RENDERER_H__
#define __RENDERER_H__
#include "Basics.h"
enum NextAction {
RA_NONE,
RA_REDISPLAY,
RA_TITLE_TO_FADE,
RA_MENU_TO_FADE,
RA_FADE_TO_GAME,
RA_FADE_TO_MENU,
RA_FADE_TO_WINSCREEN,
RA_GAME_WON_TO_FADE,
RA_GAME_LOST_TO_FADE,
RA_WINSCREEN_TO_FADE,
RA_FADE_TO_END,
RA_END_TO_FADE
};
class Renderer {
public:
// Create a new renderer.
Renderer();
// Free resources used by this renderer.
virtual ~Renderer();
// Init your rendering environment (i.e. set/enable gl configuration bits).
virtual void init();
// Render your scene. Before this is called, color and buffer bits will be
// cleared and the matrix mode will be switched to GL_MODELVIEW, with an
// identity matrix loaded.
virtual NextAction render();
// Change projection matrix to deal with new reshaping. Before this is
// called, the viewport is set to the new width and height, the matrix mode
// is switched to GL_PROJECTION, and the identity matrix is loaded. After it
// is called, the matrix mode is switched back to GL_MODELVIEW, and the
// identity matrix is loaded.
virtual void reshape(int newWidth, int newHeight);
// Intercept normal key down events. See 'man glutKeyboardFunc' for details.
virtual void onKeyDown(unsigned char key, int x, int y);
// Intercept normal key up events. See 'man glutKeyboardUpFunc' for details.
virtual void onKeyUp(unsigned char key, int x, int y);
// Intercept special key down events. See 'man glutSpecialFunc' for details.
virtual void onSpecialKeyDown(int key, int x, int y);
// Intercept special key up events. See 'man glutSpecialUpFunc' for details.
virtual void onSpecialKeyUp(int key, int x, int y);
// Should we allow keys to repeat or not?
virtual bool shouldKeysRepeat() const;
// Stop listening to inputs.
void disable();
// Start listening to inputs.
void enable();
// Is this renderer listening to inputs?
bool isEnabled() const;
private:
// Is this renderer listening to inputs?
bool enabled_;
DISALLOW_EVIL_CONSTRUCTORS(Renderer);
};
#endif