-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhints.hpp
139 lines (126 loc) · 4.57 KB
/
hints.hpp
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#ifndef SRE_HINTS_HPP
#define SRE_HINTS_HPP
#include <GLFW/glfw3.h>
#include <map>
#include <iostream>
namespace sre
{
class WindowAttribs
{
protected:
// special values
enum API
{
OPENGL_API,
OPENGL_ES_API,
};
enum Robustness
{
NO_ROBUSTNESS,
NO_RESET_NOTIFICATION,
LOSE_CONTEXT_ON_RESET,
};
enum Profile
{
ANY,
OPENGL_COMPAT,
OPENGL_CORE,
};
public:
enum KEY
{
RESIZABLE,
VISIBLE,
DECORATED,
RED_BITS,
GREEN_BITS,
BLUE_BITS,
ALPHA_BITS,
DEPTH_BITS,
STENCIL_BITS,
ACCUM_RED_BITS,
ACCUM_GREEN_BITS,
ACCUM_BLUE_BITS,
ACCUM_ALPHA_BITS,
AUX_BUFFERS,
SAMPLES,
REFRESH_RATE,
STEREO,
SRGB_CAPABLE,
CLIENT_API,
VERSION_MAJOR,
VERSION_MINOR,
CONTEXT_ROBUSTNESS,
OPENGL_FORWARD_COMPAT,
OPENGL_DEBUG,
OPENGL_PROFILE,
};
//// static methods ////
static void getGLFWattrib ( const WindowAttribs::KEY & attrib,
const int& val,
int & attribGLFW,
int & valGLFW );
};
class Hints : public WindowAttribs
{
public:
virtual void apply() const =0;
};
class HintsMap : public Hints, public std::map<Hints::KEY, int>
{
static void applyHint (const Hints::KEY & key, const int & val );
public:
void apply() const;
};
class DefaultHints : public Hints
{
public:
void apply() const;
};
class WindowHints : public HintsMap
{
public:
WindowHints();
void resizable ( bool tf ) { (*this)[RESIZABLE] = tf; }
void visible ( bool tf ) { (*this)[VISIBLE] = tf; }
void decorated ( bool tf ) { (*this)[DECORATED] = tf; }
};
class FramebufferHints: public HintsMap
{
public:
FramebufferHints();
void redBits ( int bits ) { (*this)[RED_BITS] = bits; }
void greenBits ( int bits ) { (*this)[GREEN_BITS] = bits; }
void blueBits ( int bits ) { (*this)[BLUE_BITS] = bits; }
void alphaBits ( int bits ) { (*this)[ALPHA_BITS] = bits; }
void depthBits ( int bits ) { (*this)[DEPTH_BITS] = bits; }
void stencilBits ( int bits ) { (*this)[STENCIL_BITS] = bits; }
void accumRedBits ( int bits ) { (*this)[ACCUM_RED_BITS] = bits; }
void accumGreenBits ( int bits ) { (*this)[ACCUM_GREEN_BITS] = bits; }
void accumBlueBits ( int bits ) { (*this)[ACCUM_BLUE_BITS] = bits; }
void accumAlphaBits ( int bits ) { (*this)[ACCUM_ALPHA_BITS] = bits; }
void auxBuffers ( int buffers ) { (*this)[AUX_BUFFERS] = buffers; }
void samples ( int samples ) { (*this)[SAMPLES] = samples; }
void refreshRate ( int frameHz ) { (*this)[REFRESH_RATE] = frameHz; }
void stereo ( bool tf ) { (*this)[STEREO] = tf; }
void sRGBCapable ( bool tf ) { (*this)[SRGB_CAPABLE] = tf; }
};
class ContextHints : public HintsMap
{
public:
ContextHints();
void setAPIES () { (*this)[CLIENT_API] = OPENGL_ES_API; }
void setAPIGL () { (*this)[CLIENT_API] = OPENGL_API; }
void versionMajor ( int versionNum ) { (*this)[VERSION_MAJOR] = versionNum; }
void versionMinor ( int versionNum ) { (*this)[VERSION_MINOR] = versionNum; }
void setNoRobustness () { (*this)[CONTEXT_ROBUSTNESS] = NO_ROBUSTNESS; }
void setNoResetNotification () { (*this)[CONTEXT_ROBUSTNESS] = NO_RESET_NOTIFICATION; }
void setLoseContextOnReset () { (*this)[CONTEXT_ROBUSTNESS] = LOSE_CONTEXT_ON_RESET; }
void forwardCompat ( bool tf ) { (*this)[OPENGL_FORWARD_COMPAT] = tf; }
void debug ( bool tf ) { (*this)[OPENGL_DEBUG] = tf; }
void setProfileAny () { (*this)[OPENGL_PROFILE] = ANY; }
void setProfileCompat () { (*this)[OPENGL_PROFILE] = OPENGL_COMPAT; }
void setProfileCore () { (*this)[OPENGL_PROFILE] = OPENGL_CORE; }
};
} // namespace sre
#endif // HINTS_HPP