Browse Source

No longer including gl.h globally, renamed own assert.

Thomas Buck 9 years ago
parent
commit
9121091e5e

+ 27
- 22
ChangeLog.md View File

2
 
2
 
3
 ## OpenRaider (0.1.4) xythobuz <xythobuz@xythobuz.de>
3
 ## OpenRaider (0.1.4) xythobuz <xythobuz@xythobuz.de>
4
 
4
 
5
-    [ 20140318 ]
5
+    [ 20150326 ]
6
+    * No longer including gl.h globally, now only using gl33.h where needed.
7
+    * No longer including all of glm globally, only the vec2/3/4 and mat4x4.
8
+    * No longer re-defining our own assert(), now called orAssert().
9
+
10
+    [ 20150318 ]
6
     * Updated imgui to version 1.36
11
     * Updated imgui to version 1.36
7
     * Can now display all compiled/linked library versions
12
     * Can now display all compiled/linked library versions
8
     * GLFW windowing interface now supports proper text input
13
     * GLFW windowing interface now supports proper text input
9
 
14
 
10
-    [ 20140313 ]
15
+    [ 20150313 ]
11
     * Renderer now limits room list size
16
     * Renderer now limits room list size
12
     * Updated Doxyfile template to current Doxygen version
17
     * Updated Doxyfile template to current Doxygen version
13
     * Improved documentation
18
     * Improved documentation
14
 
19
 
15
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
20
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
16
 
21
 
17
-    [ 20140312 ]
22
+    [ 20150312 ]
18
     * Now including imguifilesystem dependency
23
     * Now including imguifilesystem dependency
19
     * Completely re-wrote Main menu, now reading TOMBPC.DAT scripts
24
     * Completely re-wrote Main menu, now reading TOMBPC.DAT scripts
20
     * Main menu is now just a full-screen ImGui window
25
     * Main menu is now just a full-screen ImGui window
21
 
26
 
22
-    [ 20140310 ]
27
+    [ 20150310 ]
23
     * Tried to fix moveable loading. Fixed TR1 angle parser, but still not working better.
28
     * Tried to fix moveable loading. Fixed TR1 angle parser, but still not working better.
24
 
29
 
25
-    [ 20140309 ]
30
+    [ 20150309 ]
26
     * Removed (unused) SSE support script
31
     * Removed (unused) SSE support script
27
     * Added level loading notification in main menu
32
     * Added level loading notification in main menu
28
     * Can now start/stop individual SoundSources
33
     * Can now start/stop individual SoundSources
29
     * Added SoundDetail debug UI, improved SoundSources debug UI
34
     * Added SoundDetail debug UI, improved SoundSources debug UI
30
     * Updated imgui to version 1.35
35
     * Updated imgui to version 1.35
31
 
36
 
32
-    [ 20140307 ]
37
+    [ 20150307 ]
33
     * Can now load all TR3 levels without crashing
38
     * Can now load all TR3 levels without crashing
34
     * Sound Sources now working, with (more or less) proper 3D Sound
39
     * Sound Sources now working, with (more or less) proper 3D Sound
35
     * Fixed bug that caused entities to display the wrong object
40
     * Fixed bug that caused entities to display the wrong object
36
     * Improved Debug UI
41
     * Improved Debug UI
37
     * Updated imgui
42
     * Updated imgui
38
 
43
 
39
-    [ 20140306 ]
44
+    [ 20150306 ]
40
     * Fixed LoaderTR1, can now also open the Unfinished Business levels
45
     * Fixed LoaderTR1, can now also open the Unfinished Business levels
41
     * Walk key can now be used to increase free-camera movement speed
46
     * Walk key can now be used to increase free-camera movement speed
42
     * Removed color definitions in global.h
47
     * Removed color definitions in global.h
44
     * Hard-coded controller mapping now supports all available ActionEvents
49
     * Hard-coded controller mapping now supports all available ActionEvents
45
     * Fixed TR3 level loading. Only some levels with invalid SoundSources still crash.
50
     * Fixed TR3 level loading. Only some levels with invalid SoundSources still crash.
46
 
51
 
47
-    [ 20140305 ]
52
+    [ 20150305 ]
48
     * SoundAL now has more useful error message output.
53
     * SoundAL now has more useful error message output.
49
     * Fixed TR1 color map parsing, now textures have the proper color values.
54
     * Fixed TR1 color map parsing, now textures have the proper color values.
50
     * Fixed TR1 sound sample parsing. Can now load all TR1 levels without crashing.
55
     * Fixed TR1 sound sample parsing. Can now load all TR1 levels without crashing.
51
     * Improved parsing and summaries in binspector level reading script.
56
     * Improved parsing and summaries in binspector level reading script.
52
 
57
 
53
-    [ 20140304 ]
58
+    [ 20150304 ]
54
     * Added (more or less working) support for loading TR1 levels
59
     * Added (more or less working) support for loading TR1 levels
55
     * Updated imgui
60
     * Updated imgui
56
 
61
 
57
-    [ 20140222 ]
62
+    [ 20150222 ]
58
     * Updated imgui to version 1.33
63
     * Updated imgui to version 1.33
59
 
64
 
60
-    [ 20140219 ]
65
+    [ 20150219 ]
61
     * Started implementing ability to render into textures (mainly for debugging)
66
     * Started implementing ability to render into textures (mainly for debugging)
62
     * Started implementing camera movement room tracking
67
     * Started implementing camera movement room tracking
63
     * Started implementing camera look-at target overlay UI
68
     * Started implementing camera look-at target overlay UI
64
 
69
 
65
-    [ 20140213 ]
70
+    [ 20150213 ]
66
     * The menu can be navigated using a controller
71
     * The menu can be navigated using a controller
67
     * Vertical camera rotation is now also clamped when using a controller
72
     * Vertical camera rotation is now also clamped when using a controller
68
     * Worked on rendering SkeletalModels, not yet working correctly
73
     * Worked on rendering SkeletalModels, not yet working correctly
69
     * Implemented level loader for TR3, but tries to access invalid textiles
74
     * Implemented level loader for TR3, but tries to access invalid textiles
70
 
75
 
71
-    [ 20140211 ]
76
+    [ 20150211 ]
72
     * Updated imgui to version 1.32
77
     * Updated imgui to version 1.32
73
     * Included some SDL game controller configurations
78
     * Included some SDL game controller configurations
74
     * Camera movement speed is now clamped when moving in multiple directions
79
     * Camera movement speed is now clamped when moving in multiple directions
75
     * Slightly increased controller dead-zone, now 0.2
80
     * Slightly increased controller dead-zone, now 0.2
76
 
81
 
77
-    [ 20140204 ]
82
+    [ 20150204 ]
78
     * Return of textile, animated textile and sprite viewer, in TextureManager
83
     * Return of textile, animated textile and sprite viewer, in TextureManager
79
 
84
 
80
-    [ 20140203 ]
85
+    [ 20150203 ]
81
     * Updated imgui to newest version, supporting Images
86
     * Updated imgui to newest version, supporting Images
82
     * Texture viewer is back, using imgui Images
87
     * Texture viewer is back, using imgui Images
83
 
88
 
84
-    [ 20140124 ]
89
+    [ 20150124 ]
85
     * Started working on Entity system.
90
     * Started working on Entity system.
86
 
91
 
87
-    [ 20140118 ]
92
+    [ 20150118 ]
88
     * Added ability to visualize font _outline_.
93
     * Added ability to visualize font _outline_.
89
     * Updated imgui to newest version, now with its own TTF support.
94
     * Updated imgui to newest version, now with its own TTF support.
90
     * Fixed drawing of camera view frustum.
95
     * Fixed drawing of camera view frustum.
91
     * Added support for imgui/SDLs IME text input rectangle.
96
     * Added support for imgui/SDLs IME text input rectangle.
92
 
97
 
93
-    [ 20140117 ]
98
+    [ 20150117 ]
94
     * Updated imgui, fix for Logging to Clipboard included.
99
     * Updated imgui, fix for Logging to Clipboard included.
95
     * Sprites and SpriteSequences are now stored independently in World.
100
     * Sprites and SpriteSequences are now stored independently in World.
96
     * Added support for Room Sprites displaying.
101
     * Added support for Room Sprites displaying.
98
     * Room list is now displayed in reverse. This _fixes_ some transparency issues.
103
     * Room list is now displayed in reverse. This _fixes_ some transparency issues.
99
     * Fixed a bug that sometimes caused distorted Screenshots.
104
     * Fixed a bug that sometimes caused distorted Screenshots.
100
 
105
 
101
-    [ 20140111 ]
106
+    [ 20150111 ]
102
     * Enabled back face culling --> triangles now oriented correctly
107
     * Enabled back face culling --> triangles now oriented correctly
103
     * Game is now completely static
108
     * Game is now completely static
104
     * Shaders drawGL methods can now be given a specific Shader instance.
109
     * Shaders drawGL methods can now be given a specific Shader instance.
106
     * Console can now log to the TTY, the clipboard or a file.
111
     * Console can now log to the TTY, the clipboard or a file.
107
     * Added system clipboard support for imgui in both WindowSDL and WindowGLFW.
112
     * Added system clipboard support for imgui in both WindowSDL and WindowGLFW.
108
 
113
 
109
-    [ 20140109 ]
114
+    [ 20150109 ]
110
     * Display of Bounding Boxes can be individually toggled for Rooms/StaticMeshes
115
     * Display of Bounding Boxes can be individually toggled for Rooms/StaticMeshes
111
     * Tightened imgui Style and changed colors to match the _OpenRaider-blue_
116
     * Tightened imgui Style and changed colors to match the _OpenRaider-blue_
112
 
117
 
113
-    [ 20140108 ]
118
+    [ 20150108 ]
114
     * FPS and Camera position now displayed in imgui Overlay
119
     * FPS and Camera position now displayed in imgui Overlay
115
     * Removed many unnecessary includes
120
     * Removed many unnecessary includes
116
     * Camera now using combination of quaternion and X/Y angle.
121
     * Camera now using combination of quaternion and X/Y angle.
117
         * Fixes strange bug that sometimes rotated Camera on Z Axis.
122
         * Fixes strange bug that sometimes rotated Camera on Z Axis.
118
 
123
 
119
-    [ 20140107 ]
124
+    [ 20150107 ]
120
     * Fixed problems with FontTTFs Glyph Baseline
125
     * Fixed problems with FontTTFs Glyph Baseline
121
     * No longer using wrong assert() when glm is included
126
     * No longer using wrong assert() when glm is included
122
     * Updated imgui, now Version 1.20
127
     * Updated imgui, now Version 1.20

+ 1
- 4
cmake/travis_script_linux.sh View File

11
 #curl -L https://github.com/hpicgs/glbinding/archive/${GLBVER}.tar.gz | tar xzf -
11
 #curl -L https://github.com/hpicgs/glbinding/archive/${GLBVER}.tar.gz | tar xzf -
12
 #cd glbinding-${GLBVER#v}
12
 #cd glbinding-${GLBVER#v}
13
 
13
 
14
-# Hacky fix to allow building glbinding with clang on Linux
15
-#sed -i 's/  -Werror/  /g' cmake/PlatformLinuxGCC.cmake
16
-
17
-# Try fix in glbinding master
14
+# Need to use master until a fixed version is released
18
 git clone https://github.com/hpicgs/glbinding.git
15
 git clone https://github.com/hpicgs/glbinding.git
19
 cd glbinding
16
 cd glbinding
20
 
17
 

+ 4
- 4
include/RoomData.h View File

35
     }
35
     }
36
 
36
 
37
     glm::vec3 getCorner(int i) {
37
     glm::vec3 getCorner(int i) {
38
-        assertGreaterThanEqual(i, 0);
39
-        assertLessThan(i, 8);
38
+        orAssertGreaterThanEqual(i, 0);
39
+        orAssertLessThan(i, 8);
40
         return corner[i];
40
         return corner[i];
41
     }
41
     }
42
 
42
 
84
     glm::vec3 getNormal() { return normal; }
84
     glm::vec3 getNormal() { return normal; }
85
 
85
 
86
     glm::vec3 getVertex(int i) {
86
     glm::vec3 getVertex(int i) {
87
-        assertGreaterThanEqual(i, 0);
88
-        assertLessThan(i, 4);
87
+        orAssertGreaterThanEqual(i, 0);
88
+        orAssertLessThan(i, 4);
89
         return vert[i];
89
         return vert[i];
90
     }
90
     }
91
 
91
 

+ 35
- 46
include/global.h View File

66
     unknownKey // Should always be at the end
66
     unknownKey // Should always be at the end
67
 } KeyboardButton;
67
 } KeyboardButton;
68
 
68
 
69
-// Globally include OpenGL header
70
-#include <glbinding/gl/gl.h>
71
-#include <glbinding/Binding.h>
72
-using namespace gl;
73
-
74
-/*! \fixme Is there a better way to handle this?
75
- * We wan't to use our own assert(). Unfortunately, glm includes
76
- * cassert in its headers. So we need to define NDEBUG here.
77
- * To avoid a conflict, our flag is now called NODEBUG instead.
78
- */
79
-#define NDEBUG
80
-#include <glm/glm.hpp>
69
+#include <glm/vec2.hpp>
70
+#include <glm/vec3.hpp>
71
+#include <glm/vec4.hpp>
72
+#include <glm/mat4x4.hpp>
81
 
73
 
82
 // If available, use our own assert that prints the call stack
74
 // If available, use our own assert that prints the call stack
83
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
75
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
84
 
76
 
85
-#ifndef NODEBUG
77
+#ifndef NDEBUG
86
 
78
 
87
 #include <iostream>
79
 #include <iostream>
88
 #include <execinfo.h>
80
 #include <execinfo.h>
89
 
81
 
90
 template<typename T, typename U>
82
 template<typename T, typename U>
91
-[[noreturn]] void assertEqualImplementation(const char* exp, T a, U b, const char* file, int line,
83
+[[noreturn]] void orAssertImplementation(const char* exp, T a, U b, const char* file, int line,
92
         const char* str = nullptr) {
84
         const char* str = nullptr) {
93
     const unsigned int maxSize = 128;
85
     const unsigned int maxSize = 128;
94
     void* callstack[maxSize];
86
     void* callstack[maxSize];
108
     abort();
100
     abort();
109
 }
101
 }
110
 
102
 
111
-// Evaluating x or y could have side-effects
112
-// So we only do it once!
113
-
114
-#define assert(x) { \
103
+#define orAssert(x) { \
115
     auto assertEvalTemp = x; \
104
     auto assertEvalTemp = x; \
116
     if (!assertEvalTemp) \
105
     if (!assertEvalTemp) \
117
-        assertEqualImplementation(#x, assertEvalTemp, true, __FILE__, __LINE__); \
106
+        orAssertImplementation(#x, assertEvalTemp, true, __FILE__, __LINE__); \
118
 }
107
 }
119
 
108
 
120
-#define assertEqual(x, y) { \
109
+#define orAssertEqual(x, y) { \
121
     auto assertEvalTemp = x; \
110
     auto assertEvalTemp = x; \
122
     auto assertEvalTemp2 = y; \
111
     auto assertEvalTemp2 = y; \
123
     if (assertEvalTemp != assertEvalTemp2) \
112
     if (assertEvalTemp != assertEvalTemp2) \
124
-        assertEqualImplementation(#x " == " #y, assertEvalTemp, assertEvalTemp2, \
113
+        orAssertImplementation(#x " == " #y, assertEvalTemp, assertEvalTemp2, \
125
                                   __FILE__, __LINE__, "!="); \
114
                                   __FILE__, __LINE__, "!="); \
126
 }
115
 }
127
 
116
 
128
-#define assertNotEqual(x, y) { \
117
+#define orAssertNotEqual(x, y) { \
129
     auto assertEvalTemp = x; \
118
     auto assertEvalTemp = x; \
130
     auto assertEvalTemp2 = y; \
119
     auto assertEvalTemp2 = y; \
131
     if (assertEvalTemp == assertEvalTemp2) \
120
     if (assertEvalTemp == assertEvalTemp2) \
132
-        assertEqualImplementation(#x " != " #y, assertEvalTemp, assertEvalTemp2, \
121
+        orAssertImplementation(#x " != " #y, assertEvalTemp, assertEvalTemp2, \
133
                                   __FILE__, __LINE__, "=="); \
122
                                   __FILE__, __LINE__, "=="); \
134
 }
123
 }
135
 
124
 
136
-#define assertLessThan(x, y) { \
125
+#define orAssertLessThan(x, y) { \
137
     auto assertEvalTemp = x; \
126
     auto assertEvalTemp = x; \
138
     auto assertEvalTemp2 = y; \
127
     auto assertEvalTemp2 = y; \
139
     if (assertEvalTemp >= assertEvalTemp2) \
128
     if (assertEvalTemp >= assertEvalTemp2) \
140
-        assertEqualImplementation(#x " < " #y, assertEvalTemp, assertEvalTemp2, \
129
+        orAssertImplementation(#x " < " #y, assertEvalTemp, assertEvalTemp2, \
141
                                   __FILE__, __LINE__, ">="); \
130
                                   __FILE__, __LINE__, ">="); \
142
 }
131
 }
143
 
132
 
144
-#define assertLessThanEqual(x, y) { \
133
+#define orAssertLessThanEqual(x, y) { \
145
     auto assertEvalTemp = x; \
134
     auto assertEvalTemp = x; \
146
     auto assertEvalTemp2 = y; \
135
     auto assertEvalTemp2 = y; \
147
     if (assertEvalTemp > assertEvalTemp2) \
136
     if (assertEvalTemp > assertEvalTemp2) \
148
-        assertEqualImplementation(#x " <= " #y, assertEvalTemp, assertEvalTemp2, \
137
+        orAssertImplementation(#x " <= " #y, assertEvalTemp, assertEvalTemp2, \
149
                                   __FILE__, __LINE__, ">"); \
138
                                   __FILE__, __LINE__, ">"); \
150
 }
139
 }
151
 
140
 
152
-#define assertGreaterThan(x, y) { \
141
+#define orAssertGreaterThan(x, y) { \
153
     auto assertEvalTemp = x; \
142
     auto assertEvalTemp = x; \
154
     auto assertEvalTemp2 = y; \
143
     auto assertEvalTemp2 = y; \
155
     if (assertEvalTemp <= assertEvalTemp2) \
144
     if (assertEvalTemp <= assertEvalTemp2) \
156
-        assertEqualImplementation(#x " > " #y, assertEvalTemp, assertEvalTemp2, \
145
+        orAssertImplementation(#x " > " #y, assertEvalTemp, assertEvalTemp2, \
157
                                   __FILE__, __LINE__, "<="); \
146
                                   __FILE__, __LINE__, "<="); \
158
 }
147
 }
159
 
148
 
160
-#define assertGreaterThanEqual(x, y) { \
149
+#define orAssertGreaterThanEqual(x, y) { \
161
     auto assertEvalTemp = x; \
150
     auto assertEvalTemp = x; \
162
     auto assertEvalTemp2 = y; \
151
     auto assertEvalTemp2 = y; \
163
     if (assertEvalTemp < assertEvalTemp2) \
152
     if (assertEvalTemp < assertEvalTemp2) \
164
-        assertEqualImplementation(#x " >= " #y, assertEvalTemp, assertEvalTemp2, \
153
+        orAssertImplementation(#x " >= " #y, assertEvalTemp, assertEvalTemp2, \
165
                                   __FILE__, __LINE__, "<"); \
154
                                   __FILE__, __LINE__, "<"); \
166
 }
155
 }
167
 
156
 
168
-#else // NODEBUG
157
+#else // NDEBUG
169
 
158
 
170
-#define assert(x)
171
-#define assertEqual(x, y)
172
-#define assertNotEqual(x, y)
173
-#define assertLessThan(x, y)
174
-#define assertLessThanEqual(x, y)
175
-#define assertGreaterThan(x, y)
176
-#define assertGreaterThanEqual(x, y)
159
+#define orAssert(x)
160
+#define orAssertEqual(x, y)
161
+#define orAssertNotEqual(x, y)
162
+#define orAssertLessThan(x, y)
163
+#define orAssertLessThanEqual(x, y)
164
+#define orAssertGreaterThan(x, y)
165
+#define orAssertGreaterThanEqual(x, y)
177
 
166
 
178
-#endif // NODEBUG
167
+#endif // NDEBUG
179
 
168
 
180
 #else // EXECINFO
169
 #else // EXECINFO
181
 
170
 
182
 // Fall back to the default C assert
171
 // Fall back to the default C assert
183
 #include <cassert>
172
 #include <cassert>
184
-#define assertEqual(x, y) assert((x) == (y))
185
-#define assertNotEqual(x, y) assert((x) != (y))
186
-#define assertLessThan(x, y) assert((x) < (y))
187
-#define assertLessThanEqual(x, y) assert((x) <= (y))
188
-#define assertGreaterThan(x, y) assert((x) > (y))
189
-#define assertGreaterThanEqual(x, y) assert((x) >= (y))
173
+#define orAssertEqual(x, y) assert((x) == (y))
174
+#define orAssertNotEqual(x, y) assert((x) != (y))
175
+#define orAssertLessThan(x, y) assert((x) < (y))
176
+#define orAssertLessThanEqual(x, y) assert((x) <= (y))
177
+#define orAssertGreaterThan(x, y) assert((x) > (y))
178
+#define orAssertGreaterThanEqual(x, y) assert((x) >= (y))
190
 
179
 
191
 #endif // EXECINFO
180
 #endif // EXECINFO
192
 
181
 

+ 1
- 0
include/loader/Loader.h View File

28
     static LoaderVersion checkFile(std::string f);
28
     static LoaderVersion checkFile(std::string f);
29
     static std::unique_ptr<Loader> createLoader(std::string f);
29
     static std::unique_ptr<Loader> createLoader(std::string f);
30
 
30
 
31
+    virtual ~Loader();
31
     virtual int load(std::string f) = 0;
32
     virtual int load(std::string f) = 0;
32
 
33
 
33
   protected:
34
   protected:

+ 6
- 4
include/system/Shader.h View File

13
 
13
 
14
 #include "TextureManager.h"
14
 #include "TextureManager.h"
15
 
15
 
16
+#include <glbinding/gl/gl33.h>
17
+
16
 class ShaderBuffer {
18
 class ShaderBuffer {
17
   public:
19
   public:
18
     ShaderBuffer() : created(false), buffer(0), boundSize(0) { }
20
     ShaderBuffer() : created(false), buffer(0), boundSize(0) { }
28
     void bindBuffer(int location, int size);
30
     void bindBuffer(int location, int size);
29
     void unbind(int location);
31
     void unbind(int location);
30
 
32
 
31
-    unsigned int getBuffer() { assert(created); return buffer; }
33
+    unsigned int getBuffer() { orAssert(created); return buffer; }
32
     int getSize() { return boundSize; }
34
     int getSize() { return boundSize; }
33
 
35
 
34
   private:
36
   private:
74
     static void set2DState(bool on, bool depth = true);
76
     static void set2DState(bool on, bool depth = true);
75
 
77
 
76
     static void drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, glm::vec4 color, unsigned int texture,
78
     static void drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, glm::vec4 color, unsigned int texture,
77
-                       TextureStorage store = TextureStorage::SYSTEM, GLenum = GL_TRIANGLES,
79
+                       TextureStorage store = TextureStorage::SYSTEM, gl::GLenum = gl::GL_TRIANGLES,
78
                        ShaderTexture* target = nullptr, Shader& shader = textShader);
80
                        ShaderTexture* target = nullptr, Shader& shader = textShader);
79
 
81
 
80
     static void drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, unsigned int texture, glm::mat4 MVP,
82
     static void drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, unsigned int texture, glm::mat4 MVP,
86
                        Shader& shader = textureShader);
88
                        Shader& shader = textureShader);
87
 
89
 
88
     static void drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, glm::mat4 MVP,
90
     static void drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, glm::mat4 MVP,
89
-                       GLenum mode = GL_TRIANGLES, ShaderTexture* target = nullptr,
91
+                       gl::GLenum mode = gl::GL_TRIANGLES, ShaderTexture* target = nullptr,
90
                        Shader& shader = colorShader);
92
                        Shader& shader = colorShader);
91
     static void drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, ShaderBuffer& indices,
93
     static void drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, ShaderBuffer& indices,
92
-                       glm::mat4 MVP, GLenum mode = GL_TRIANGLES, ShaderTexture* target = nullptr,
94
+                       glm::mat4 MVP, gl::GLenum mode = gl::GL_TRIANGLES, ShaderTexture* target = nullptr,
93
                        Shader& shader = colorShader);
95
                        Shader& shader = colorShader);
94
 
96
 
95
     static std::string getVersion(bool linked);
97
     static std::string getVersion(bool linked);

+ 1
- 1
include/system/SoundAL.h View File

21
     static int loadBuffer(unsigned char* buffer, unsigned int length);
21
     static int loadBuffer(unsigned char* buffer, unsigned int length);
22
 
22
 
23
     static int numSources(bool atListener);
23
     static int numSources(bool atListener);
24
-    static int addSource(int buffer, float volume, bool atListener, bool loop);
24
+    static int addSource(int buffer, float vol, bool atListener, bool loop);
25
 
25
 
26
     static int sourceAt(int source, glm::vec3 pos);
26
     static int sourceAt(int source, glm::vec3 pos);
27
     static void listenAt(glm::vec3 pos, glm::vec3 at, glm::vec3 up);
27
     static void listenAt(glm::vec3 pos, glm::vec3 at, glm::vec3 up);

+ 1
- 1
include/system/WindowGLFW.h View File

11
 #include <string>
11
 #include <string>
12
 #include <glm/gtc/type_precision.hpp>
12
 #include <glm/gtc/type_precision.hpp>
13
 
13
 
14
-class GLFWwindow;
14
+struct GLFWwindow;
15
 
15
 
16
 class WindowGLFW {
16
 class WindowGLFW {
17
   public:
17
   public:

+ 2
- 1
src/Camera.cpp View File

17
 #include "system/Window.h"
17
 #include "system/Window.h"
18
 #include "Camera.h"
18
 #include "Camera.h"
19
 
19
 
20
+#include <glbinding/gl/gl33.h>
20
 #include <glm/gtc/epsilon.hpp>
21
 #include <glm/gtc/epsilon.hpp>
21
 #include <glm/gtc/matrix_transform.hpp>
22
 #include <glm/gtc/matrix_transform.hpp>
22
 #include <glm/gtc/quaternion.hpp>
23
 #include <glm/gtc/quaternion.hpp>
396
 void Camera::displayFrustum(glm::mat4 MVP) {
397
 void Camera::displayFrustum(glm::mat4 MVP) {
397
     Shader::set2DState(true, false);
398
     Shader::set2DState(true, false);
398
     Shader::drawGL(vertexBuffer, colorBuffer, indexBuffer, MVP);
399
     Shader::drawGL(vertexBuffer, colorBuffer, indexBuffer, MVP);
399
-    Shader::drawGL(vertexPointBuffer, colorPointBuffer, MVP, GL_POINTS);
400
+    Shader::drawGL(vertexPointBuffer, colorPointBuffer, MVP, gl::GL_POINTS);
400
     Shader::set2DState(false, false);
401
     Shader::set2DState(false, false);
401
 }
402
 }
402
 
403
 

+ 1
- 1
src/Console.cpp View File

110
         for (unsigned long i = 0; i < Log::size(); i++) {
110
         for (unsigned long i = 0; i < Log::size(); i++) {
111
             auto& entry = Log::getEntry(i);
111
             auto& entry = Log::getEntry(i);
112
 
112
 
113
-            assertLessThan(entry.level, LOG_COUNT);
113
+            orAssertLessThan(entry.level, LOG_COUNT);
114
             if (!visibleLogs[entry.level]) {
114
             if (!visibleLogs[entry.level]) {
115
                 continue;
115
                 continue;
116
             }
116
             }

+ 2
- 4
src/Entity.cpp View File

57
             }
57
             }
58
         }
58
         }
59
 
59
 
60
-        assertGreaterThan(cache, -1);
61
-        assertGreaterThan(cacheType, -1);
60
+        orAssertGreaterThan(cache, -1);
61
+        orAssertGreaterThan(cacheType, -1);
62
     }
62
     }
63
 
63
 
64
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));
64
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));
80
     } else if (cacheType == CACHE_MODEL) {
80
     } else if (cacheType == CACHE_MODEL) {
81
         if (showEntityModels)
81
         if (showEntityModels)
82
             getWorld().getSkeletalModel(cache).display(MVP, animation, frame);
82
             getWorld().getSkeletalModel(cache).display(MVP, animation, frame);
83
-    } else {
84
-        assert(false && "This should not happen...");
85
     }
83
     }
86
 }
84
 }
87
 
85
 

+ 5
- 5
src/Game.cpp View File

82
 }
82
 }
83
 
83
 
84
 void Game::handleAction(ActionEvents action, bool isFinished) {
84
 void Game::handleAction(ActionEvents action, bool isFinished) {
85
-    assertLessThan(action, ActionEventCount);
85
+    orAssertLessThan(action, ActionEventCount);
86
 
86
 
87
     if (!mLoaded)
87
     if (!mLoaded)
88
         return;
88
         return;
113
 }
113
 }
114
 
114
 
115
 Entity& Game::getLara() {
115
 Entity& Game::getLara() {
116
-    assertGreaterThanEqual(mLara, 0);
117
-    assertLessThan(mLara, getWorld().sizeEntity());
116
+    orAssertGreaterThanEqual(mLara, 0);
117
+    orAssertLessThan(mLara, getWorld().sizeEntity());
118
     return getWorld().getEntity(mLara);
118
     return getWorld().getEntity(mLara);
119
 }
119
 }
120
 
120
 
121
 void Game::setLara(long lara) {
121
 void Game::setLara(long lara) {
122
-    assertGreaterThanEqual(lara, 0);
123
-    assertLessThan(lara, getWorld().sizeEntity());
122
+    orAssertGreaterThanEqual(lara, 0);
123
+    orAssertLessThan(lara, getWorld().sizeEntity());
124
     mLara = lara;
124
     mLara = lara;
125
 }
125
 }
126
 
126
 

+ 2
- 2
src/Log.cpp View File

17
 }
17
 }
18
 
18
 
19
 LogLevel& Log::get(int level) {
19
 LogLevel& Log::get(int level) {
20
-    assertGreaterThanEqual(level, 0);
21
-    assertLessThan(level, LOG_COUNT);
20
+    orAssertGreaterThanEqual(level, 0);
21
+    orAssertLessThan(level, LOG_COUNT);
22
     return logs.at(level);
22
     return logs.at(level);
23
 }
23
 }
24
 
24
 

+ 8
- 6
src/Mesh.cpp View File

9
 #include "TextureManager.h"
9
 #include "TextureManager.h"
10
 #include "Mesh.h"
10
 #include "Mesh.h"
11
 
11
 
12
+#include <glbinding/gl/gl33.h>
13
+
12
 Mesh::Mesh(const std::vector<glm::vec3>& vert,
14
 Mesh::Mesh(const std::vector<glm::vec3>& vert,
13
            const std::vector<IndexedRectangle>& rect,
15
            const std::vector<IndexedRectangle>& rect,
14
            const std::vector<IndexedRectangle>& tri,
16
            const std::vector<IndexedRectangle>& tri,
78
         vertIndex += (indicesBuff.at(i) == 0) ? 4 : 3;
80
         vertIndex += (indicesBuff.at(i) == 0) ? 4 : 3;
79
     }
81
     }
80
 
82
 
81
-    assertEqual(ind.size() % 3, 0);
82
-    assertEqual(vert.size(), tex.size());
83
-    assertEqual(vert.size(), uvBuff.size());
83
+    orAssertEqual(ind.size() % 3, 0);
84
+    orAssertEqual(vert.size(), tex.size());
85
+    orAssertEqual(vert.size(), uvBuff.size());
84
 
86
 
85
     indicesBuff = std::move(ind);
87
     indicesBuff = std::move(ind);
86
     vertices.bufferData(vert);
88
     vertices.bufferData(vert);
113
         vertIndex += (indicesColorBuff.at(i) == 0) ? 4 : 3;
115
         vertIndex += (indicesColorBuff.at(i) == 0) ? 4 : 3;
114
     }
116
     }
115
 
117
 
116
-    assertEqual(indCol.size() % 3, 0);
117
-    assertEqual(vertCol.size(), cols.size());
118
+    orAssertEqual(indCol.size() % 3, 0);
119
+    orAssertEqual(vertCol.size(), cols.size());
118
 
120
 
119
     indicesColor.bufferData(indCol);
121
     indicesColor.bufferData(indCol);
120
     verticesColor.bufferData(vertCol);
122
     verticesColor.bufferData(vertCol);
152
     }
154
     }
153
 
155
 
154
     if (indicesColor.getSize() > 0)
156
     if (indicesColor.getSize() > 0)
155
-        Shader::drawGL(verticesColor, colors, indicesColor, MVP, GL_TRIANGLES, shaderTexture);
157
+        Shader::drawGL(verticesColor, colors, indicesColor, MVP, gl::GL_TRIANGLES, shaderTexture);
156
 }
158
 }
157
 
159
 

+ 7
- 6
src/Render.cpp View File

21
 #include "Render.h"
21
 #include "Render.h"
22
 
22
 
23
 #include <glm/gtc/matrix_transform.hpp>
23
 #include <glm/gtc/matrix_transform.hpp>
24
+#include <glbinding/gl/gl33.h>
24
 
25
 
25
 #include "imgui/imgui.h"
26
 #include "imgui/imgui.h"
26
 #include "stb/stb_image_write.h"
27
 #include "stb/stb_image_write.h"
30
 bool Render::displayViewFrustum = false;
31
 bool Render::displayViewFrustum = false;
31
 
32
 
32
 void Render::display() {
33
 void Render::display() {
33
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
34
+    gl::glClear(gl::GL_COLOR_BUFFER_BIT | gl::GL_DEPTH_BUFFER_BIT);
34
 
35
 
35
     if (mode == RenderMode::LoadScreen) {
36
     if (mode == RenderMode::LoadScreen) {
36
         glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f);
37
         glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f);
40
     }
41
     }
41
 
42
 
42
     if (mode == RenderMode::Wireframe) {
43
     if (mode == RenderMode::Wireframe) {
43
-        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
44
+        gl::glPolygonMode(gl::GL_FRONT_AND_BACK, gl::GL_LINE);
44
     } else {
45
     } else {
45
-        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
46
+        gl::glPolygonMode(gl::GL_FRONT_AND_BACK, gl::GL_FILL);
46
     }
47
     }
47
 
48
 
48
     if (Camera::update()) {
49
     if (Camera::update()) {
74
         Camera::displayFrustum(VP);
75
         Camera::displayFrustum(VP);
75
 
76
 
76
     if (mode == RenderMode::Wireframe) {
77
     if (mode == RenderMode::Wireframe) {
77
-        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
78
+        gl::glPolygonMode(gl::GL_FRONT_AND_BACK, gl::GL_FILL);
78
     }
79
     }
79
 }
80
 }
80
 
81
 
119
 }
120
 }
120
 
121
 
121
 void Render::screenShot(const char* filenameBase) {
122
 void Render::screenShot(const char* filenameBase) {
122
-    assert(filenameBase != nullptr);
123
+    orAssert(filenameBase != nullptr);
123
 
124
 
124
     int w = Window::getSize().x;
125
     int w = Window::getSize().x;
125
     int h = Window::getSize().y;
126
     int h = Window::getSize().y;
126
     int sz = w * h;
127
     int sz = w * h;
127
     unsigned char* image = new unsigned char[sz * 3];
128
     unsigned char* image = new unsigned char[sz * 3];
128
-    glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, image);
129
+    gl::glReadPixels(0, 0, w, h, gl::GL_RGB, gl::GL_UNSIGNED_BYTE, image);
129
 
130
 
130
     unsigned char* buffer = new unsigned char[sz * 3];
131
     unsigned char* buffer = new unsigned char[sz * 3];
131
     for (int x = 0; x < w; x++) {
132
     for (int x = 0; x < w; x++) {

+ 3
- 3
src/Room.cpp View File

46
 }
46
 }
47
 
47
 
48
 bool Room::isWall(unsigned long sector) {
48
 bool Room::isWall(unsigned long sector) {
49
-    assertLessThan(sector, sectors.size());
49
+    orAssertLessThan(sector, sectors.size());
50
 
50
 
51
     //! \fixme is (sector > 0) correct??
51
     //! \fixme is (sector > 0) correct??
52
     return ((sector > 0) && sectors.at(sector)->isWall());
52
     return ((sector > 0) && sectors.at(sector)->isWall());
53
 }
53
 }
54
 
54
 
55
 long Room::getSector(float x, float z, float* floor, float* ceiling) {
55
 long Room::getSector(float x, float z, float* floor, float* ceiling) {
56
-    assert(floor != nullptr);
57
-    assert(ceiling != nullptr);
56
+    orAssert(floor != nullptr);
57
+    orAssert(ceiling != nullptr);
58
 
58
 
59
     long sector = getSector(x, z);
59
     long sector = getSector(x, z);
60
 
60
 

+ 4
- 3
src/RoomData.cpp View File

11
 #include "system/Shader.h"
11
 #include "system/Shader.h"
12
 #include "RoomData.h"
12
 #include "RoomData.h"
13
 
13
 
14
+#include <glbinding/gl/gl33.h>
14
 #include <glm/gtc/matrix_transform.hpp>
15
 #include <glm/gtc/matrix_transform.hpp>
15
 
16
 
16
 void BoundingBox::display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot) {
17
 void BoundingBox::display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot) {
44
     vert.bufferData(verts);
45
     vert.bufferData(verts);
45
     col.bufferData(cols);
46
     col.bufferData(cols);
46
     ind.bufferData(inds);
47
     ind.bufferData(inds);
47
-    Shader::drawGL(vert, col, ind, VP, GL_LINE_STRIP);
48
+    Shader::drawGL(vert, col, ind, VP, gl::GL_LINE_STRIP);
48
 
49
 
49
     cols.clear();
50
     cols.clear();
50
     inds.clear();
51
     inds.clear();
58
     vert2.bufferData(verts);
59
     vert2.bufferData(verts);
59
     col2.bufferData(cols);
60
     col2.bufferData(cols);
60
     ind2.bufferData(inds);
61
     ind2.bufferData(inds);
61
-    Shader::drawGL(vert2, col2, ind2, VP, GL_POINTS);
62
+    Shader::drawGL(vert2, col2, ind2, VP, gl::GL_POINTS);
62
 }
63
 }
63
 
64
 
64
 // ----------------------------------------------------------------------------
65
 // ----------------------------------------------------------------------------
76
                 cache = i;
77
                 cache = i;
77
             }
78
             }
78
         }
79
         }
79
-        assertGreaterThanEqual(cache, 0);
80
+        orAssertGreaterThanEqual(cache, 0);
80
     }
81
     }
81
 
82
 
82
     getWorld().getStaticMesh(cache).display(VP * model);
83
     getWorld().getStaticMesh(cache).display(VP * model);

+ 3
- 3
src/RoomMesh.cpp View File

59
         vertIndex += (indicesBuff.at(i) == 0) ? 4 : 3;
59
         vertIndex += (indicesBuff.at(i) == 0) ? 4 : 3;
60
     }
60
     }
61
 
61
 
62
-    assertEqual(ind.size() % 3, 0);
63
-    assertEqual(vert.size(), tex.size());
64
-    assertEqual(vert.size(), uvBuff.size());
62
+    orAssertEqual(ind.size() % 3, 0);
63
+    orAssertEqual(vert.size(), tex.size());
64
+    orAssertEqual(vert.size(), uvBuff.size());
65
 
65
 
66
     indicesBuff = std::move(ind);
66
     indicesBuff = std::move(ind);
67
     vertices.bufferData(vert);
67
     vertices.bufferData(vert);

+ 2
- 2
src/RunTime.cpp View File

54
 }
54
 }
55
 
55
 
56
 KeyboardButton RunTime::getKeyBinding(ActionEvents event) {
56
 KeyboardButton RunTime::getKeyBinding(ActionEvents event) {
57
-    assertLessThan(event, ActionEventCount);
57
+    orAssertLessThan(event, ActionEventCount);
58
     return keyBindings[event];
58
     return keyBindings[event];
59
 }
59
 }
60
 
60
 
61
 void RunTime::setKeyBinding(ActionEvents event, KeyboardButton button) {
61
 void RunTime::setKeyBinding(ActionEvents event, KeyboardButton button) {
62
-    assertLessThan(event, ActionEventCount);
62
+    orAssertLessThan(event, ActionEventCount);
63
     keyBindings[event] = button;
63
     keyBindings[event] = button;
64
 }
64
 }
65
 
65
 

+ 19
- 19
src/Script.cpp View File

54
     description = desc;
54
     description = desc;
55
 
55
 
56
     uint16_t gameflowSize = f.readU16();
56
     uint16_t gameflowSize = f.readU16();
57
-    assertEqual(gameflowSize, 128);
57
+    orAssertEqual(gameflowSize, 128);
58
 
58
 
59
     firstOption = f.readU32();
59
     firstOption = f.readU32();
60
     titleReplace = f.read32();
60
     titleReplace = f.read32();
150
     uint16_t* offset = new uint16_t[n];
150
     uint16_t* offset = new uint16_t[n];
151
     for (unsigned int i = 0; i < n; i++) {
151
     for (unsigned int i = 0; i < n; i++) {
152
         offset[i] = f.readU16();
152
         offset[i] = f.readU16();
153
-        assertEqual(offset[i] % 2, 0);
153
+        orAssertEqual(offset[i] % 2, 0);
154
     }
154
     }
155
 
155
 
156
     uint16_t numBytes = f.readU16();
156
     uint16_t numBytes = f.readU16();
157
-    assertEqual(numBytes % 2, 0); // 16 bit opcodes and operands
157
+    orAssertEqual(numBytes % 2, 0); // 16 bit opcodes and operands
158
 
158
 
159
     uint16_t* list = new uint16_t[(numBytes + 6) / 2];
159
     uint16_t* list = new uint16_t[(numBytes + 6) / 2];
160
     for (uint16_t i = 0; i < (numBytes / 2); i++) {
160
     for (uint16_t i = 0; i < (numBytes / 2); i++) {
231
 }
231
 }
232
 
232
 
233
 std::string Script::getLevelName(unsigned int i) {
233
 std::string Script::getLevelName(unsigned int i) {
234
-    assertLessThan(i, numLevels);
234
+    orAssertLessThan(i, numLevels);
235
     return levelNames.at(i);
235
     return levelNames.at(i);
236
 }
236
 }
237
 
237
 
238
 std::string Script::getLevelFilename(unsigned int i) {
238
 std::string Script::getLevelFilename(unsigned int i) {
239
-    assertLessThan(i, numLevels);
239
+    orAssertLessThan(i, numLevels);
240
     return levelFilenames.at(i);
240
     return levelFilenames.at(i);
241
 }
241
 }
242
 
242
 
245
 }
245
 }
246
 
246
 
247
 std::string Script::getPictureFilename(unsigned int i) {
247
 std::string Script::getPictureFilename(unsigned int i) {
248
-    assertLessThan(i, numPictures);
248
+    orAssertLessThan(i, numPictures);
249
     return pictureFilenames.at(i);
249
     return pictureFilenames.at(i);
250
 }
250
 }
251
 
251
 
254
 }
254
 }
255
 
255
 
256
 std::string Script::getCutsceneFilename(unsigned int i) {
256
 std::string Script::getCutsceneFilename(unsigned int i) {
257
-    assertLessThan(i, numCutscenes);
257
+    orAssertLessThan(i, numCutscenes);
258
     return cutsceneFilenames.at(i);
258
     return cutsceneFilenames.at(i);
259
 }
259
 }
260
 
260
 
263
 }
263
 }
264
 
264
 
265
 std::string Script::getTitleFilename(unsigned int i) {
265
 std::string Script::getTitleFilename(unsigned int i) {
266
-    assertLessThan(i, numTitles);
266
+    orAssertLessThan(i, numTitles);
267
     return titleFilenames.at(i);
267
     return titleFilenames.at(i);
268
 }
268
 }
269
 
269
 
272
 }
272
 }
273
 
273
 
274
 std::string Script::getVideoFilename(unsigned int i) {
274
 std::string Script::getVideoFilename(unsigned int i) {
275
-    assertLessThan(i, numFMVs);
275
+    orAssertLessThan(i, numFMVs);
276
     return fmvFilenames.at(i);
276
     return fmvFilenames.at(i);
277
 }
277
 }
278
 
278
 
281
 }
281
 }
282
 
282
 
283
 std::string Script::getGameString(unsigned int i) {
283
 std::string Script::getGameString(unsigned int i) {
284
-    assertLessThan(i, numGameStrings);
284
+    orAssertLessThan(i, numGameStrings);
285
     return gameStrings.at(i);
285
     return gameStrings.at(i);
286
 }
286
 }
287
 
287
 
290
 }
290
 }
291
 
291
 
292
 std::string Script::getPCString(unsigned int i) {
292
 std::string Script::getPCString(unsigned int i) {
293
-    assertLessThan(i, numPCStrings);
293
+    orAssertLessThan(i, numPCStrings);
294
     return pcStrings.at(i);
294
     return pcStrings.at(i);
295
 }
295
 }
296
 
296
 
297
 std::string Script::getPuzzleString(unsigned int i, unsigned int j) {
297
 std::string Script::getPuzzleString(unsigned int i, unsigned int j) {
298
-    assertLessThan(i, 4);
299
-    assertLessThan(j, numLevels);
298
+    orAssertLessThan(i, 4);
299
+    orAssertLessThan(j, numLevels);
300
     return puzzles.at(i).at(j);
300
     return puzzles.at(i).at(j);
301
 }
301
 }
302
 
302
 
303
 std::string Script::getPickupString(unsigned int i, unsigned int j) {
303
 std::string Script::getPickupString(unsigned int i, unsigned int j) {
304
-    assertLessThan(i, 2);
305
-    assertLessThan(j, numLevels);
304
+    orAssertLessThan(i, 2);
305
+    orAssertLessThan(j, numLevels);
306
     return pickups.at(i).at(j);
306
     return pickups.at(i).at(j);
307
 }
307
 }
308
 
308
 
309
 std::string Script::getKeyString(unsigned int i, unsigned int j) {
309
 std::string Script::getKeyString(unsigned int i, unsigned int j) {
310
-    assertLessThan(i, 4);
311
-    assertLessThan(j, numLevels);
310
+    orAssertLessThan(i, 4);
311
+    orAssertLessThan(j, numLevels);
312
     return keys.at(i).at(j);
312
     return keys.at(i).at(j);
313
 }
313
 }
314
 
314
 
315
 void Script::registerScriptHandler(ScriptOpCode op, std::function<int (bool, uint16_t)> func) {
315
 void Script::registerScriptHandler(ScriptOpCode op, std::function<int (bool, uint16_t)> func) {
316
-    assertLessThan(op, OP_UNKNOWN);
316
+    orAssertLessThan(op, OP_UNKNOWN);
317
     scriptHandlers[op] = func;
317
     scriptHandlers[op] = func;
318
 }
318
 }
319
 
319
 
320
 int Script::runScript(unsigned int level) {
320
 int Script::runScript(unsigned int level) {
321
-    assertLessThan(level, (numLevels + 1));
321
+    orAssertLessThan(level, (numLevels + 1));
322
     std::vector<uint16_t> s = script.at(level);
322
     std::vector<uint16_t> s = script.at(level);
323
 
323
 
324
     for (unsigned int i = 0; i < s.size(); i++) {
324
     for (unsigned int i = 0; i < s.size(); i++) {

+ 8
- 8
src/SkeletalModel.cpp View File

29
 }
29
 }
30
 
30
 
31
 BoneTag& BoneFrame::get(unsigned long i) {
31
 BoneTag& BoneFrame::get(unsigned long i) {
32
-    assertLessThan(i, tag.size());
32
+    orAssertLessThan(i, tag.size());
33
     return *tag.at(i);
33
     return *tag.at(i);
34
 }
34
 }
35
 
35
 
49
 }
49
 }
50
 
50
 
51
 BoneFrame& AnimationFrame::get(unsigned long i) {
51
 BoneFrame& AnimationFrame::get(unsigned long i) {
52
-    assertLessThan(i, frame.size());
52
+    orAssertLessThan(i, frame.size());
53
     return *frame.at(i);
53
     return *frame.at(i);
54
 }
54
 }
55
 
55
 
64
     MatrixStack(glm::mat4 start) : startVal(start) { stack.push_back(startVal); }
64
     MatrixStack(glm::mat4 start) : startVal(start) { stack.push_back(startVal); }
65
 
65
 
66
     void push() {
66
     void push() {
67
-        //assertGreaterThan(stack.size(), 0);
67
+        //orAssertGreaterThan(stack.size(), 0);
68
         if (stack.size() > 0)
68
         if (stack.size() > 0)
69
             stack.push_back(stack.at(stack.size() - 1));
69
             stack.push_back(stack.at(stack.size() - 1));
70
     }
70
     }
71
 
71
 
72
     void pop() {
72
     void pop() {
73
-        //assertGreaterThan(stack.size(), 0);
73
+        //orAssertGreaterThan(stack.size(), 0);
74
         if (stack.size() > 0)
74
         if (stack.size() > 0)
75
             stack.pop_back();
75
             stack.pop_back();
76
     }
76
     }
77
 
77
 
78
     glm::mat4 get() {
78
     glm::mat4 get() {
79
-        //assertGreaterThan(stack.size(), 0);
79
+        //orAssertGreaterThan(stack.size(), 0);
80
         if (stack.size() > 0)
80
         if (stack.size() > 0)
81
             return stack.at(stack.size() - 1);
81
             return stack.at(stack.size() - 1);
82
         return startVal;
82
         return startVal;
101
 #endif
101
 #endif
102
 
102
 
103
 void SkeletalModel::display(glm::mat4 MVP, int aframe, int bframe, ShaderTexture* shaderTexture) {
103
 void SkeletalModel::display(glm::mat4 MVP, int aframe, int bframe, ShaderTexture* shaderTexture) {
104
-    assertLessThan(aframe, size());
105
-    assertLessThan(bframe, get(aframe).size());
104
+    orAssertLessThan(aframe, size());
105
+    orAssertLessThan(bframe, get(aframe).size());
106
 
106
 
107
     AnimationFrame& anim = get(aframe);
107
     AnimationFrame& anim = get(aframe);
108
     BoneFrame& boneframe = anim.get(bframe);
108
     BoneFrame& boneframe = anim.get(bframe);
173
 }
173
 }
174
 
174
 
175
 AnimationFrame& SkeletalModel::get(unsigned long i) {
175
 AnimationFrame& SkeletalModel::get(unsigned long i) {
176
-    assertLessThan(i, animation.size());
176
+    orAssertLessThan(i, animation.size());
177
     return *animation.at(i);
177
     return *animation.at(i);
178
 }
178
 }
179
 
179
 

+ 2
- 2
src/Sprite.cpp View File

52
 // ----------------------------------------------------------------------------
52
 // ----------------------------------------------------------------------------
53
 
53
 
54
 void SpriteSequence::display(glm::mat4 MVP, int index) {
54
 void SpriteSequence::display(glm::mat4 MVP, int index) {
55
-    assertGreaterThanEqual(index, 0);
56
-    assertLessThan(index, length);
55
+    orAssertGreaterThanEqual(index, 0);
56
+    orAssertLessThan(index, length);
57
     getWorld().getSprite(start + index).display(MVP);
57
     getWorld().getSprite(start + index).display(MVP);
58
 }
58
 }
59
 
59
 

+ 42
- 40
src/TextureManager.cpp View File

21
 #include "utils/strings.h"
21
 #include "utils/strings.h"
22
 #include "TextureManager.h"
22
 #include "TextureManager.h"
23
 
23
 
24
+#include <glbinding/gl/gl33.h>
25
+
24
 glm::vec2 TextureTile::getUV(unsigned int i) {
26
 glm::vec2 TextureTile::getUV(unsigned int i) {
25
     glm::vec2 uv(vertices.at(i).xPixel,
27
     glm::vec2 uv(vertices.at(i).xPixel,
26
                  vertices.at(i).yPixel);
28
                  vertices.at(i).yPixel);
60
 std::vector<std::tuple<unsigned char*, unsigned int, unsigned int>> TextureManager::indexedTextures;
62
 std::vector<std::tuple<unsigned char*, unsigned int, unsigned int>> TextureManager::indexedTextures;
61
 
63
 
62
 int TextureManager::initialize() {
64
 int TextureManager::initialize() {
63
-    assertEqual(mTextureIdsGame.size(), 0);
64
-    assertEqual(mTextureIdsSystem.size(), 0);
65
+    orAssertEqual(mTextureIdsGame.size(), 0);
66
+    orAssertEqual(mTextureIdsSystem.size(), 0);
65
 
67
 
66
     while (mTextureIdsSystem.size() < 2) {
68
     while (mTextureIdsSystem.size() < 2) {
67
         unsigned int id;
69
         unsigned int id;
68
-        glGenTextures(1, &id);
70
+        gl::glGenTextures(1, &id);
69
         mTextureIdsSystem.push_back(id);
71
         mTextureIdsSystem.push_back(id);
70
     }
72
     }
71
 
73
 
107
 void TextureManager::shutdown() {
109
 void TextureManager::shutdown() {
108
     while (mTextureIdsSystem.size() > 0) {
110
     while (mTextureIdsSystem.size() > 0) {
109
         unsigned int id = mTextureIdsSystem.at(mTextureIdsSystem.size() - 1);
111
         unsigned int id = mTextureIdsSystem.at(mTextureIdsSystem.size() - 1);
110
-        glDeleteTextures(1, &id);
112
+        gl::glDeleteTextures(1, &id);
111
         mTextureIdsSystem.pop_back();
113
         mTextureIdsSystem.pop_back();
112
     }
114
     }
113
 
115
 
120
 void TextureManager::clear() {
122
 void TextureManager::clear() {
121
     while (mTextureIdsGame.size() > 0) {
123
     while (mTextureIdsGame.size() > 0) {
122
         unsigned int id = mTextureIdsGame.at(mTextureIdsGame.size() - 1);
124
         unsigned int id = mTextureIdsGame.at(mTextureIdsGame.size() - 1);
123
-        glDeleteTextures(1, &id);
125
+        gl::glDeleteTextures(1, &id);
124
         mTextureIdsGame.pop_back();
126
         mTextureIdsGame.pop_back();
125
     }
127
     }
126
 
128
 
142
                                    unsigned int width, unsigned int height,
144
                                    unsigned int width, unsigned int height,
143
                                    ColorMode mode, unsigned int bpp,
145
                                    ColorMode mode, unsigned int bpp,
144
                                    TextureStorage s, int slot, bool filter) {
146
                                    TextureStorage s, int slot, bool filter) {
145
-    assertGreaterThan(width, 0);
146
-    assertGreaterThan(height, 0);
147
-    assert((mode == ColorMode::RGB)
147
+    orAssertGreaterThan(width, 0);
148
+    orAssertGreaterThan(height, 0);
149
+    orAssert((mode == ColorMode::RGB)
148
            || (mode == ColorMode::BGR)
150
            || (mode == ColorMode::BGR)
149
            || (mode == ColorMode::ARGB)
151
            || (mode == ColorMode::ARGB)
150
            || (mode == ColorMode::RGBA)
152
            || (mode == ColorMode::RGBA)
151
            || (mode ==  ColorMode::BGRA));
153
            || (mode ==  ColorMode::BGRA));
152
-    assert((bpp == 8) || (bpp == 24) || (bpp == 32));
154
+    orAssert((bpp == 8) || (bpp == 24) || (bpp == 32));
153
 
155
 
154
     if (slot < 0)
156
     if (slot < 0)
155
         slot = getIds(s).size();
157
         slot = getIds(s).size();
156
 
158
 
157
     while (getIds(s).size() <= slot) {
159
     while (getIds(s).size() <= slot) {
158
         unsigned int id;
160
         unsigned int id;
159
-        glGenTextures(1, &id);
161
+        gl::glGenTextures(1, &id);
160
         getIds(s).push_back(id);
162
         getIds(s).push_back(id);
161
     }
163
     }
162
 
164
 
163
-    GLenum glcMode;
165
+    gl::GLenum glcMode;
164
     switch (mode) {
166
     switch (mode) {
165
         case ColorMode::BGR:
167
         case ColorMode::BGR:
166
-            glcMode = GL_BGR;
168
+            glcMode = gl::GL_BGR;
167
             break;
169
             break;
168
 
170
 
169
         case ColorMode::RGB:
171
         case ColorMode::RGB:
170
-            glcMode = GL_RGB;
172
+            glcMode = gl::GL_RGB;
171
             break;
173
             break;
172
 
174
 
173
         case ColorMode::ARGB:
175
         case ColorMode::ARGB:
174
             if (image != nullptr)
176
             if (image != nullptr)
175
                 argb2rgba32(image, width, height);
177
                 argb2rgba32(image, width, height);
176
-            glcMode = GL_RGBA;
178
+            glcMode = gl::GL_RGBA;
177
             break;
179
             break;
178
 
180
 
179
         case ColorMode::BGRA:
181
         case ColorMode::BGRA:
180
-            glcMode = GL_BGRA;
182
+            glcMode = gl::GL_BGRA;
181
             break;
183
             break;
182
 
184
 
183
         case ColorMode::RGBA:
185
         case ColorMode::RGBA:
184
-            glcMode = GL_RGBA;
186
+            glcMode = gl::GL_RGBA;
185
             break;
187
             break;
186
     }
188
     }
187
 
189
 
188
-    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
190
+    gl::glPixelStorei(gl::GL_UNPACK_ALIGNMENT, 1);
189
     bindTexture(slot, s);
191
     bindTexture(slot, s);
190
-    glTexImage2D(GL_TEXTURE_2D, 0, GLint(GL_RGBA), width, height, 0, glcMode, GL_UNSIGNED_BYTE, image);
192
+    gl::glTexImage2D(gl::GL_TEXTURE_2D, 0, gl::GLint(gl::GL_RGBA), width, height, 0, glcMode, gl::GL_UNSIGNED_BYTE, image);
191
 
193
 
192
     if (filter) {
194
     if (filter) {
193
         // Trilinear filtering
195
         // Trilinear filtering
194
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GLint(GL_REPEAT));
195
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GLint(GL_REPEAT));
196
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GLint(GL_LINEAR));
197
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GLint(GL_LINEAR_MIPMAP_LINEAR));
198
-        glGenerateMipmap(GL_TEXTURE_2D);
196
+        gl::glTexParameteri(gl::GL_TEXTURE_2D, gl::GL_TEXTURE_WRAP_S, gl::GLint(gl::GL_REPEAT));
197
+        gl::glTexParameteri(gl::GL_TEXTURE_2D, gl::GL_TEXTURE_WRAP_T, gl::GLint(gl::GL_REPEAT));
198
+        gl::glTexParameteri(gl::GL_TEXTURE_2D, gl::GL_TEXTURE_MAG_FILTER, gl::GLint(gl::GL_LINEAR));
199
+        gl::glTexParameteri(gl::GL_TEXTURE_2D, gl::GL_TEXTURE_MIN_FILTER, gl::GLint(gl::GL_LINEAR_MIPMAP_LINEAR));
200
+        gl::glGenerateMipmap(gl::GL_TEXTURE_2D);
199
     } else {
201
     } else {
200
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GLint(GL_NEAREST));
201
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GLint(GL_NEAREST));
202
+        gl::glTexParameteri(gl::GL_TEXTURE_2D, gl::GL_TEXTURE_MIN_FILTER, gl::GLint(gl::GL_NEAREST));
203
+        gl::glTexParameteri(gl::GL_TEXTURE_2D, gl::GL_TEXTURE_MAG_FILTER, gl::GLint(gl::GL_NEAREST));
202
     }
204
     }
203
 
205
 
204
     return slot;
206
     return slot;
209
 }
211
 }
210
 
212
 
211
 void TextureManager::bindTextureId(unsigned int n, TextureStorage s, unsigned int unit) {
213
 void TextureManager::bindTextureId(unsigned int n, TextureStorage s, unsigned int unit) {
212
-    assertLessThan(n, getIds(s).size());
213
-    assertLessThan(unit, 80); //! \fixme Query GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
214
+    orAssertLessThan(n, getIds(s).size());
215
+    orAssertLessThan(unit, 80); //! \fixme Query GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
214
 
216
 
215
-    glActiveTexture(GL_TEXTURE0 + unit);
216
-    glBindTexture(GL_TEXTURE_2D, getIds(s).at(n));
217
+    gl::glActiveTexture(gl::GL_TEXTURE0 + unit);
218
+    gl::glBindTexture(gl::GL_TEXTURE_2D, getIds(s).at(n));
217
 }
219
 }
218
 
220
 
219
 int TextureManager::bindTexture(unsigned int n, TextureStorage s) {
221
 int TextureManager::bindTexture(unsigned int n, TextureStorage s) {
220
-    assertLessThan(n, getIds(s).size());
222
+    orAssertLessThan(n, getIds(s).size());
221
 
223
 
222
     if ((n < getUnits(s).size()) && (getUnits(s).at(n) >= 0)) {
224
     if ((n < getUnits(s).size()) && (getUnits(s).at(n) >= 0)) {
223
         bindTextureId(n, s, getUnits(s).at(n));
225
         bindTextureId(n, s, getUnits(s).at(n));
233
 }
235
 }
234
 
236
 
235
 unsigned int TextureManager::getTextureID(int n, TextureStorage s) {
237
 unsigned int TextureManager::getTextureID(int n, TextureStorage s) {
236
-    assertLessThan(n, getIds(s).size());
238
+    orAssertLessThan(n, getIds(s).size());
237
     return getIds(s).at(n);
239
     return getIds(s).at(n);
238
 }
240
 }
239
 
241
 
246
 }
248
 }
247
 
249
 
248
 TextureTile& TextureManager::getTile(int index) {
250
 TextureTile& TextureManager::getTile(int index) {
249
-    assertGreaterThanEqual(index, 0);
250
-    assertLessThan(index, tiles.size());
251
+    orAssertGreaterThanEqual(index, 0);
252
+    orAssertLessThan(index, tiles.size());
251
     return *tiles.at(index);
253
     return *tiles.at(index);
252
 }
254
 }
253
 
255
 
263
 }
265
 }
264
 
266
 
265
 int TextureManager::getFirstTileAnimation(int index) {
267
 int TextureManager::getFirstTileAnimation(int index) {
266
-    assertLessThan(index, animations.size());
267
-    assertGreaterThan(animations.at(index).size(), 0);
268
+    orAssertLessThan(index, animations.size());
269
+    orAssertGreaterThan(animations.at(index).size(), 0);
268
     return animations.at(index).at(0);
270
     return animations.at(index).at(0);
269
 }
271
 }
270
 
272
 
271
 int TextureManager::getNextTileAnimation(int index, int tile) {
273
 int TextureManager::getNextTileAnimation(int index, int tile) {
272
-    assertLessThan(index, animations.size());
274
+    orAssertLessThan(index, animations.size());
273
     for (int i = 0; i < animations.at(index).size(); i++) {
275
     for (int i = 0; i < animations.at(index).size(); i++) {
274
         if (animations.at(index).at(i) == tile) {
276
         if (animations.at(index).at(i) == tile) {
275
             if (i < (animations.at(index).size() - 1))
277
             if (i < (animations.at(index).size() - 1))
290
 }
292
 }
291
 
293
 
292
 void TextureManager::setPalette(int index, glm::vec4 color) {
294
 void TextureManager::setPalette(int index, glm::vec4 color) {
293
-    assertGreaterThanEqual(index, 0);
294
-    assertLessThan(index, COLOR_PALETTE_SIZE);
295
+    orAssertGreaterThanEqual(index, 0);
296
+    orAssertLessThan(index, COLOR_PALETTE_SIZE);
295
     colorPalette[index] = color;
297
     colorPalette[index] = color;
296
 }
298
 }
297
 
299
 
298
 glm::vec4 TextureManager::getPalette(int index) {
300
 glm::vec4 TextureManager::getPalette(int index) {
299
-    assertGreaterThanEqual(index, 0);
300
-    assertLessThan(index, COLOR_PALETTE_SIZE);
301
+    orAssertGreaterThanEqual(index, 0);
302
+    orAssertLessThan(index, COLOR_PALETTE_SIZE);
301
     return colorPalette[index];
303
     return colorPalette[index];
302
 }
304
 }
303
 
305
 

+ 6
- 5
src/UI.cpp View File

23
 #include "utils/time.h"
23
 #include "utils/time.h"
24
 #include "UI.h"
24
 #include "UI.h"
25
 
25
 
26
+#include <glbinding/gl/gl33.h>
26
 #include <glm/gtc/matrix_transform.hpp>
27
 #include <glm/gtc/matrix_transform.hpp>
27
 
28
 
28
 Shader UI::imguiShader;
29
 Shader UI::imguiShader;
480
 
481
 
481
     static ShaderBuffer vert, uv, col;
482
     static ShaderBuffer vert, uv, col;
482
 
483
 
483
-    glEnable(GL_SCISSOR_TEST);
484
+    gl::glEnable(gl::GL_SCISSOR_TEST);
484
     Shader::set2DState(true);
485
     Shader::set2DState(true);
485
 
486
 
486
     imguiShader.use();
487
     imguiShader.use();
523
             col.bufferData(colors);
524
             col.bufferData(colors);
524
 
525
 
525
             auto bm = static_cast<BufferManager*>(commands[n].texture_id);
526
             auto bm = static_cast<BufferManager*>(commands[n].texture_id);
526
-            assert(bm != nullptr);
527
+            orAssert(bm != nullptr);
527
             imguiShader.loadUniform(1, bm->getTextureID(), bm->getTextureStorage());
528
             imguiShader.loadUniform(1, bm->getTextureID(), bm->getTextureStorage());
528
 
529
 
529
-            glScissor(commands[n].clip_rect.x,
530
+            gl::glScissor(commands[n].clip_rect.x,
530
                       Window::getSize().y - commands[n].clip_rect.w,
531
                       Window::getSize().y - commands[n].clip_rect.w,
531
                       commands[n].clip_rect.z - commands[n].clip_rect.x,
532
                       commands[n].clip_rect.z - commands[n].clip_rect.x,
532
                       commands[n].clip_rect.w - commands[n].clip_rect.y);
533
                       commands[n].clip_rect.w - commands[n].clip_rect.y);
533
 
534
 
534
-            glDrawArrays(GL_TRIANGLES, 0, vertices.size());
535
+            gl::glDrawArrays(gl::GL_TRIANGLES, 0, vertices.size());
535
         }
536
         }
536
     }
537
     }
537
 
538
 
540
     col.unbind(2);
541
     col.unbind(2);
541
 
542
 
542
     Shader::set2DState(false);
543
     Shader::set2DState(false);
543
-    glDisable(GL_SCISSOR_TEST);
544
+    gl::glDisable(gl::GL_SCISSOR_TEST);
544
 }
545
 }
545
 
546
 
546
 // --------------------------------------
547
 // --------------------------------------

+ 7
- 7
src/World.cpp View File

31
 }
31
 }
32
 
32
 
33
 Room& World::getRoom(unsigned long index) {
33
 Room& World::getRoom(unsigned long index) {
34
-    assertLessThan(index, mRooms.size());
34
+    orAssertLessThan(index, mRooms.size());
35
     return *mRooms.at(index);
35
     return *mRooms.at(index);
36
 }
36
 }
37
 
37
 
44
 }
44
 }
45
 
45
 
46
 Sprite& World::getSprite(unsigned long index) {
46
 Sprite& World::getSprite(unsigned long index) {
47
-    assertLessThan(index, mSprites.size());
47
+    orAssertLessThan(index, mSprites.size());
48
     return *mSprites.at(index);
48
     return *mSprites.at(index);
49
 }
49
 }
50
 
50
 
57
 }
57
 }
58
 
58
 
59
 SpriteSequence& World::getSpriteSequence(unsigned long index) {
59
 SpriteSequence& World::getSpriteSequence(unsigned long index) {
60
-    assertLessThan(index, mSpriteSequences.size());
60
+    orAssertLessThan(index, mSpriteSequences.size());
61
     return *mSpriteSequences.at(index);
61
     return *mSpriteSequences.at(index);
62
 }
62
 }
63
 
63
 
70
 }
70
 }
71
 
71
 
72
 Entity& World::getEntity(unsigned long index) {
72
 Entity& World::getEntity(unsigned long index) {
73
-    assertLessThan(index, mEntities.size());
73
+    orAssertLessThan(index, mEntities.size());
74
     return *mEntities.at(index);
74
     return *mEntities.at(index);
75
 }
75
 }
76
 
76
 
83
 }
83
 }
84
 
84
 
85
 SkeletalModel& World::getSkeletalModel(unsigned long index) {
85
 SkeletalModel& World::getSkeletalModel(unsigned long index) {
86
-    assertLessThan(index, mModels.size());
86
+    orAssertLessThan(index, mModels.size());
87
     return *mModels.at(index);
87
     return *mModels.at(index);
88
 }
88
 }
89
 
89
 
96
 }
96
 }
97
 
97
 
98
 StaticMesh& World::getStaticMesh(unsigned long index) {
98
 StaticMesh& World::getStaticMesh(unsigned long index) {
99
-    assertLessThan(index, mStaticMeshes.size());
99
+    orAssertLessThan(index, mStaticMeshes.size());
100
     return *mStaticMeshes.at(index);
100
     return *mStaticMeshes.at(index);
101
 }
101
 }
102
 
102
 
109
 }
109
 }
110
 
110
 
111
 Mesh& World::getMesh(unsigned long index) {
111
 Mesh& World::getMesh(unsigned long index) {
112
-    assertLessThan(index, mMeshes.size());
112
+    orAssertLessThan(index, mMeshes.size());
113
     return *mMeshes.at(index);
113
     return *mMeshes.at(index);
114
 }
114
 }
115
 
115
 

+ 1
- 1
src/deps/imgui/imconfig.h View File

13
 
13
 
14
 //---- Define assertion handler. Defaults to calling assert().
14
 //---- Define assertion handler. Defaults to calling assert().
15
 #include "global.h"
15
 #include "global.h"
16
-#define IM_ASSERT(_EXPR)  assert(_EXPR)
16
+#define IM_ASSERT(_EXPR)  orAssert(_EXPR)
17
 
17
 
18
 //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
18
 //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
19
 //#define IMGUI_API __declspec( dllexport )
19
 //#define IMGUI_API __declspec( dllexport )

+ 3
- 3
src/deps/stb/stb.cpp View File

8
 #include "global.h"
8
 #include "global.h"
9
 
9
 
10
 #define STB_IMAGE_IMPLEMENTATION
10
 #define STB_IMAGE_IMPLEMENTATION
11
-#define STBI_ASSERT(x) assert(x)
11
+#define STBI_ASSERT(x) orAssert(x)
12
 #define STBI_NO_SIMD
12
 #define STBI_NO_SIMD
13
 #include "stb/stb_image.h"
13
 #include "stb/stb_image.h"
14
 
14
 
16
 #include "stb/stb_image_write.h"
16
 #include "stb/stb_image_write.h"
17
 
17
 
18
 #define STB_RECT_PACK_IMPLEMENTATION
18
 #define STB_RECT_PACK_IMPLEMENTATION
19
-#define STBRP_ASSERT assert
19
+#define STBRP_ASSERT orAssert
20
 #include "stb/stb_rect_pack.h"
20
 #include "stb/stb_rect_pack.h"
21
 
21
 
22
 #define STB_TRUETYPE_IMPLEMENTATION
22
 #define STB_TRUETYPE_IMPLEMENTATION
23
-#define STBTT_assert(x) assert(x)
23
+#define STBTT_assert(x) orAssert(x)
24
 #include "stb/stb_truetype.h"
24
 #include "stb/stb_truetype.h"
25
 
25
 

+ 2
- 0
src/loader/Loader.cpp View File

55
     }
55
     }
56
 }
56
 }
57
 
57
 
58
+Loader::~Loader() { }
59
+

+ 2
- 2
src/loader/LoaderTR1.cpp View File

266
     for (unsigned int i = 0; i < numSampleIndices; i++) {
266
     for (unsigned int i = 0; i < numSampleIndices; i++) {
267
         SoundManager::addSampleIndex(i);
267
         SoundManager::addSampleIndex(i);
268
         uint32_t sampleOffset = file.readU32();
268
         uint32_t sampleOffset = file.readU32();
269
-        assertLessThan(sampleOffset, soundSampleSize);
269
+        orAssertLessThan(sampleOffset, soundSampleSize);
270
         char* tmpPtr = reinterpret_cast<char*>(&buffer[sampleOffset]);
270
         char* tmpPtr = reinterpret_cast<char*>(&buffer[sampleOffset]);
271
         BinaryMemory sample(tmpPtr, soundSampleSize - sampleOffset);
271
         BinaryMemory sample(tmpPtr, soundSampleSize - sampleOffset);
272
         int ret = loadSoundFiles(sample, 1);
272
         int ret = loadSoundFiles(sample, 1);
273
-        assertEqual(ret, 1);
273
+        orAssertEqual(ret, 1);
274
     }
274
     }
275
 
275
 
276
     if (numSampleIndices > 0)
276
     if (numSampleIndices > 0)

+ 7
- 7
src/loader/LoaderTR2.cpp View File

95
         int r = TextureManager::loadBufferSlot(img, 256, 256,
95
         int r = TextureManager::loadBufferSlot(img, 256, 256,
96
                                                ColorMode::ARGB, 32,
96
                                                ColorMode::ARGB, 32,
97
                                                TextureStorage::GAME, i);
97
                                                TextureStorage::GAME, i);
98
-        assertGreaterThanEqual(r, 0); //! \fixme properly handle error when texture could not be loaded!
98
+        orAssertGreaterThanEqual(r, 0); //! \fixme properly handle error when texture could not be loaded!
99
         delete [] img;
99
         delete [] img;
100
     }
100
     }
101
 
101
 
137
             uint8_t yCoordinate = file.readU8();
137
             uint8_t yCoordinate = file.readU8();
138
             uint8_t yPixel = file.readU8();
138
             uint8_t yPixel = file.readU8();
139
 
139
 
140
-            assert((xCoordinate == 1) || (xCoordinate == 255) || (xCoordinate == 0));
141
-            assert((yCoordinate == 1) || (yCoordinate == 255) || (yCoordinate == 0));
140
+            orAssert((xCoordinate == 1) || (xCoordinate == 255) || (xCoordinate == 0));
141
+            orAssert((yCoordinate == 1) || (yCoordinate == 255) || (yCoordinate == 0));
142
 
142
 
143
             t->add(TextureTileVertex(xCoordinate, xPixel, yCoordinate, yPixel));
143
             t->add(TextureTileVertex(xCoordinate, xPixel, yCoordinate, yPixel));
144
         }
144
         }
502
         int16_t negativeLength = file.read16(); // Negative sprite count
502
         int16_t negativeLength = file.read16(); // Negative sprite count
503
         int16_t offset = file.read16(); // Where sequence starts in sprite texture list
503
         int16_t offset = file.read16(); // Where sequence starts in sprite texture list
504
 
504
 
505
-        assertLessThan(negativeLength, 0);
506
-        assertGreaterThanEqual(offset, 0);
507
-        assertLessThanEqual(offset + (negativeLength * -1), numSpriteTextures);
505
+        orAssertLessThan(negativeLength, 0);
506
+        orAssertGreaterThanEqual(offset, 0);
507
+        orAssertLessThanEqual(offset + (negativeLength * -1), numSpriteTextures);
508
 
508
 
509
         SpriteSequence* ss = new SpriteSequence(objectID, offset, (negativeLength * -1));
509
         SpriteSequence* ss = new SpriteSequence(objectID, offset, (negativeLength * -1));
510
         getWorld().addSpriteSequence(ss);
510
         getWorld().addSpriteSequence(ss);
1197
 
1197
 
1198
         int ret = Sound::loadBuffer(buff, riffSize + 8);
1198
         int ret = Sound::loadBuffer(buff, riffSize + 8);
1199
         delete [] buff;
1199
         delete [] buff;
1200
-        assertGreaterThanEqual(ret, 0);
1200
+        orAssertGreaterThanEqual(ret, 0);
1201
 
1201
 
1202
         riffCount++;
1202
         riffCount++;
1203
     }
1203
     }

+ 4
- 2
src/main.cpp View File

26
 #include "system/Window.h"
26
 #include "system/Window.h"
27
 #include "utils/time.h"
27
 #include "utils/time.h"
28
 
28
 
29
+#include <glbinding/Binding.h>
30
+
29
 static std::string configFileToUse;
31
 static std::string configFileToUse;
30
 static std::shared_ptr<World> gWorld;
32
 static std::shared_ptr<World> gWorld;
31
 
33
 
153
 }
155
 }
154
 
156
 
155
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
157
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
156
-#ifndef NODEBUG
158
+#ifndef NDEBUG
157
 
159
 
158
 #include <exception>
160
 #include <exception>
159
 #include <execinfo.h>
161
 #include <execinfo.h>
177
     abort();
179
     abort();
178
 }
180
 }
179
 
181
 
180
-#endif // NODEBUG
182
+#endif // NDEBUG
181
 #endif // HAVE_EXECINFO_H && HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS
183
 #endif // HAVE_EXECINFO_H && HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS
182
 
184
 

+ 1
- 1
src/system/Font.cpp View File

122
     uv.bufferData(uvs);
122
     uv.bufferData(uvs);
123
 
123
 
124
     Shader::drawGL(vert, uv, glm::vec4(1.0f, 1.0f, 0.0f, 1.0f), TEXTURE_WHITE,
124
     Shader::drawGL(vert, uv, glm::vec4(1.0f, 1.0f, 0.0f, 1.0f), TEXTURE_WHITE,
125
-                   TextureStorage::SYSTEM, GL_LINE_STRIP);
125
+                   TextureStorage::SYSTEM, gl::GL_LINE_STRIP);
126
 }
126
 }
127
 
127
 

+ 10
- 10
src/system/FontTRLE.cpp View File

26
 }
26
 }
27
 
27
 
28
 int FontTRLE::initialize(std::string font) {
28
 int FontTRLE::initialize(std::string font) {
29
-    assert(stringEndsWith(font, ".pc") == true);
29
+    orAssert(stringEndsWith(font, ".pc") == true);
30
 
30
 
31
     shutdown();
31
     shutdown();
32
 
32
 
90
 
90
 
91
 void FontTRLE::writeChar(unsigned int index, unsigned int xDraw, unsigned int yDraw, float scale,
91
 void FontTRLE::writeChar(unsigned int index, unsigned int xDraw, unsigned int yDraw, float scale,
92
                          std::vector<glm::vec2>& vertices, std::vector<glm::vec2>& uvs) {
92
                          std::vector<glm::vec2>& vertices, std::vector<glm::vec2>& uvs) {
93
-    assert(mFontInit == true);
93
+    orAssert(mFontInit == true);
94
 
94
 
95
     float width = ((float)offsets[index][2]) * scale * SCALING;
95
     float width = ((float)offsets[index][2]) * scale * SCALING;
96
     float height = ((float)offsets[index][3]) * scale * SCALING;
96
     float height = ((float)offsets[index][3]) * scale * SCALING;
126
 }
126
 }
127
 
127
 
128
 unsigned int FontTRLE::widthText(float scale, std::string s) {
128
 unsigned int FontTRLE::widthText(float scale, std::string s) {
129
-    assert(mFontInit == true);
130
-    assert(s.length() > 0);
129
+    orAssert(mFontInit == true);
130
+    orAssert(s.length() > 0);
131
 
131
 
132
     unsigned int width = 0;
132
     unsigned int width = 0;
133
     for (unsigned int i = 0; i < s.length(); i++) {
133
     for (unsigned int i = 0; i < s.length(); i++) {
148
 
148
 
149
 void FontTRLE::drawText(unsigned int x, unsigned int y, float scale,
149
 void FontTRLE::drawText(unsigned int x, unsigned int y, float scale,
150
                         glm::vec4 color, std::string s) {
150
                         glm::vec4 color, std::string s) {
151
-    assert(mFontInit == true);
152
-    assert(s.length() > 0);
151
+    orAssert(mFontInit == true);
152
+    orAssert(s.length() > 0);
153
 
153
 
154
     std::vector<glm::vec2> vertices;
154
     std::vector<glm::vec2> vertices;
155
     std::vector<glm::vec2> uvs;
155
     std::vector<glm::vec2> uvs;
173
 }
173
 }
174
 
174
 
175
 unsigned int FontTRLE::heightText(float scale, unsigned int maxWidth, std::string s) {
175
 unsigned int FontTRLE::heightText(float scale, unsigned int maxWidth, std::string s) {
176
-    assert(mFontInit == true);
177
-    assert(s.length() > 0);
176
+    orAssert(mFontInit == true);
177
+    orAssert(s.length() > 0);
178
 
178
 
179
     unsigned int x = 0;
179
     unsigned int x = 0;
180
     unsigned int yMax = 0;
180
     unsigned int yMax = 0;
207
 
207
 
208
 void FontTRLE::drawTextWrapped(unsigned int x, unsigned int y, float scale,
208
 void FontTRLE::drawTextWrapped(unsigned int x, unsigned int y, float scale,
209
                                glm::vec4 color, unsigned int maxWidth, std::string s) {
209
                                glm::vec4 color, unsigned int maxWidth, std::string s) {
210
-    assert(mFontInit == true);
211
-    assert(s.length() > 0);
210
+    orAssert(mFontInit == true);
211
+    orAssert(s.length() > 0);
212
 
212
 
213
     unsigned int xStart = x;
213
     unsigned int xStart = x;
214
     unsigned int yMax = 0;
214
     unsigned int yMax = 0;

+ 5
- 5
src/system/FontTTF.cpp View File

81
 }
81
 }
82
 
82
 
83
 bool FontMapTTF::contains(int c) {
83
 bool FontMapTTF::contains(int c) {
84
-    assert(begin >= 0);
84
+    orAssert(begin >= 0);
85
     return (begin >= 0) && (c >= begin) && (c < (begin + MAP_NUM_CHARS));
85
     return (begin >= 0) && (c >= begin) && (c < (begin + MAP_NUM_CHARS));
86
 }
86
 }
87
 
87
 
88
 void FontMapTTF::getQuad(int c, float* xpos, float* ypos, stbtt_aligned_quad* quad) {
88
 void FontMapTTF::getQuad(int c, float* xpos, float* ypos, stbtt_aligned_quad* quad) {
89
-    assert(contains(c));
89
+    orAssert(contains(c));
90
     stbtt_GetPackedQuad(charInfo, MAP_WIDTH, MAP_HEIGHT, c - begin, xpos, ypos, quad, 0);
90
     stbtt_GetPackedQuad(charInfo, MAP_WIDTH, MAP_HEIGHT, c - begin, xpos, ypos, quad, 0);
91
 }
91
 }
92
 
92
 
98
 ShaderBuffer FontTTF::uvBuffer;
98
 ShaderBuffer FontTTF::uvBuffer;
99
 
99
 
100
 int FontTTF::initialize(std::string f) {
100
 int FontTTF::initialize(std::string f) {
101
-    assert(f.length() > 0);
101
+    orAssert(f.length() > 0);
102
 
102
 
103
     std::ifstream file(f, std::ios::binary);
103
     std::ifstream file(f, std::ios::binary);
104
     if (!file) {
104
     if (!file) {
108
 
108
 
109
     file.seekg(0, std::ios::end);
109
     file.seekg(0, std::ios::end);
110
     auto size = file.tellg();
110
     auto size = file.tellg();
111
-    assert(size > 0);
111
+    orAssert(size > 0);
112
     file.seekg(0);
112
     file.seekg(0);
113
 
113
 
114
     maps.clear();
114
     maps.clear();
272
     }
272
     }
273
 
273
 
274
     int map = charIsMapped(c);
274
     int map = charIsMapped(c);
275
-    assert(map >= 0);
275
+    orAssert(map >= 0);
276
     maps.at(map).getQuad(c, xpos, ypos, quad);
276
     maps.at(map).getQuad(c, xpos, ypos, quad);
277
     return maps.at(map).getTexture();
277
     return maps.at(map).getTexture();
278
 }
278
 }

+ 137
- 123
src/system/Shader.cpp View File

12
 #include "system/Window.h"
12
 #include "system/Window.h"
13
 #include "system/Shader.h"
13
 #include "system/Shader.h"
14
 
14
 
15
+#include <glbinding/gl/gl33.h>
16
+
15
 ShaderBuffer::~ShaderBuffer() {
17
 ShaderBuffer::~ShaderBuffer() {
16
     if (created)
18
     if (created)
17
-        glDeleteBuffers(1, &buffer);
19
+        gl::glDeleteBuffers(1, &buffer);
18
 }
20
 }
19
 
21
 
20
 void ShaderBuffer::bufferData(int elem, int size, void* data) {
22
 void ShaderBuffer::bufferData(int elem, int size, void* data) {
21
     if (!created) {
23
     if (!created) {
22
-        glGenBuffers(1, &buffer);
24
+        gl::glGenBuffers(1, &buffer);
23
         created = true;
25
         created = true;
24
     }
26
     }
25
 
27
 
26
     boundSize = elem;
28
     boundSize = elem;
27
-    glBindBuffer(GL_ARRAY_BUFFER, buffer);
28
-    glBufferData(GL_ARRAY_BUFFER, elem * size, data, GL_STATIC_DRAW);
29
+    gl::glBindBuffer(gl::GL_ARRAY_BUFFER, buffer);
30
+    gl::glBufferData(gl::GL_ARRAY_BUFFER, elem * size, data, gl::GL_STATIC_DRAW);
29
 }
31
 }
30
 
32
 
31
 void ShaderBuffer::bindBuffer() {
33
 void ShaderBuffer::bindBuffer() {
32
     if (!created) {
34
     if (!created) {
33
-        glGenBuffers(1, &buffer);
35
+        gl::glGenBuffers(1, &buffer);
34
         created = true;
36
         created = true;
35
     }
37
     }
36
 
38
 
37
-    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
39
+    gl::glBindBuffer(gl::GL_ELEMENT_ARRAY_BUFFER, buffer);
38
 }
40
 }
39
 
41
 
40
 void ShaderBuffer::bindBuffer(int location, int size) {
42
 void ShaderBuffer::bindBuffer(int location, int size) {
41
     if (!created) {
43
     if (!created) {
42
-        glGenBuffers(1, &buffer);
44
+        gl::glGenBuffers(1, &buffer);
43
         created = true;
45
         created = true;
44
     }
46
     }
45
 
47
 
46
-    glEnableVertexAttribArray(location);
47
-    glBindBuffer(GL_ARRAY_BUFFER, buffer);
48
-    glVertexAttribPointer(location, size, GL_FLOAT, GL_FALSE, 0, nullptr);
48
+    gl::glEnableVertexAttribArray(location);
49
+    gl::glBindBuffer(gl::GL_ARRAY_BUFFER, buffer);
50
+    gl::glVertexAttribPointer(location, size, gl::GL_FLOAT, gl::GL_FALSE, 0, nullptr);
49
 }
51
 }
50
 
52
 
51
 void ShaderBuffer::unbind(int location) {
53
 void ShaderBuffer::unbind(int location) {
52
-    assert(created == true);
53
-    glDisableVertexAttribArray(location);
54
+    orAssert(created == true);
55
+    gl::glDisableVertexAttribArray(location);
54
 }
56
 }
55
 
57
 
56
 // ----------------------------------------------------------------------------
58
 // ----------------------------------------------------------------------------
57
 
59
 
58
 ShaderTexture::ShaderTexture(int w, int h) : width(w), height(h) {
60
 ShaderTexture::ShaderTexture(int w, int h) : width(w), height(h) {
59
-    glGenFramebuffers(1, &framebuffer);
61
+    gl::glGenFramebuffers(1, &framebuffer);
60
     bind();
62
     bind();
61
 
63
 
62
     texture = TextureManager::loadBufferSlot(nullptr, width, height, ColorMode::RGBA,
64
     texture = TextureManager::loadBufferSlot(nullptr, width, height, ColorMode::RGBA,
63
               32, TextureStorage::SYSTEM, -1, false);
65
               32, TextureStorage::SYSTEM, -1, false);
64
 
66
 
65
-    glGenRenderbuffers(1, &depth);
66
-    glBindRenderbuffer(GL_RENDERBUFFER, depth);
67
-    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
68
-    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);
67
+    gl::glGenRenderbuffers(1, &depth);
68
+    gl::glBindRenderbuffer(gl::GL_RENDERBUFFER, depth);
69
+    gl::glRenderbufferStorage(gl::GL_RENDERBUFFER, gl::GL_DEPTH_COMPONENT, width, height);
70
+    gl::glFramebufferRenderbuffer(gl::GL_FRAMEBUFFER, gl::GL_DEPTH_ATTACHMENT, gl::GL_RENDERBUFFER, depth);
69
 
71
 
70
-    glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
72
+    gl::glFramebufferTexture(gl::GL_FRAMEBUFFER, gl::GL_COLOR_ATTACHMENT0,
71
                          TextureManager::getTextureID(texture, TextureStorage::SYSTEM), 0);
73
                          TextureManager::getTextureID(texture, TextureStorage::SYSTEM), 0);
72
 
74
 
73
-    GLenum drawBuffer = GL_COLOR_ATTACHMENT0;
74
-    glDrawBuffers(1, &drawBuffer);
75
+    gl::GLenum drawBuffer = gl::GL_COLOR_ATTACHMENT0;
76
+    gl::glDrawBuffers(1, &drawBuffer);
75
 
77
 
76
-    assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
78
+    orAssert(gl::glCheckFramebufferStatus(gl::GL_FRAMEBUFFER) == gl::GL_FRAMEBUFFER_COMPLETE);
77
 }
79
 }
78
 
80
 
79
 ShaderTexture::~ShaderTexture() {
81
 ShaderTexture::~ShaderTexture() {
80
-    glDeleteRenderbuffers(1, &depth);
81
-    glDeleteFramebuffers(1,  &framebuffer);
82
+    gl::glDeleteRenderbuffers(1, &depth);
83
+    gl::glDeleteFramebuffers(1,  &framebuffer);
82
 
84
 
83
     //! \fixme free texture slot
85
     //! \fixme free texture slot
84
 }
86
 }
85
 
87
 
86
 void ShaderTexture::clear() {
88
 void ShaderTexture::clear() {
87
     bind();
89
     bind();
88
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
90
+    gl::glClear(gl::GL_COLOR_BUFFER_BIT | gl::GL_DEPTH_BUFFER_BIT);
89
 }
91
 }
90
 
92
 
91
 void ShaderTexture::bind() {
93
 void ShaderTexture::bind() {
92
-    glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
93
-    glViewport(0, 0, width, height);
94
+    gl::glBindFramebuffer(gl::GL_FRAMEBUFFER, framebuffer);
95
+    gl::glViewport(0, 0, width, height);
94
 }
96
 }
95
 
97
 
96
 // ----------------------------------------------------------------------------
98
 // ----------------------------------------------------------------------------
97
 
99
 
98
 Shader::~Shader() {
100
 Shader::~Shader() {
99
     if (programID >= 0)
101
     if (programID >= 0)
100
-        glDeleteProgram(programID);
102
+        gl::glDeleteProgram(programID);
101
 }
103
 }
102
 
104
 
103
 int Shader::addUniform(const char* name) {
105
 int Shader::addUniform(const char* name) {
104
-    assert(programID >= 0);
105
-    int r = glGetUniformLocation(programID, name);
106
+    orAssert(programID >= 0);
107
+    int r = gl::glGetUniformLocation(programID, name);
106
     if (r < 0) {
108
     if (r < 0) {
107
         Log::get(LOG_ERROR) << "Can't find GLSL Uniform \"" << name << "\"!" << Log::endl;
109
         Log::get(LOG_ERROR) << "Can't find GLSL Uniform \"" << name << "\"!" << Log::endl;
108
         return -1;
110
         return -1;
112
 }
114
 }
113
 
115
 
114
 unsigned int Shader::getUniform(int n) {
116
 unsigned int Shader::getUniform(int n) {
115
-    assert(n >= 0);
116
-    assert(n < uniforms.size());
117
+    orAssert(n >= 0);
118
+    orAssert(n < uniforms.size());
117
     return uniforms.at(n);
119
     return uniforms.at(n);
118
 }
120
 }
119
 
121
 
120
 void Shader::loadUniform(int uni, glm::vec2 vec) {
122
 void Shader::loadUniform(int uni, glm::vec2 vec) {
121
-    glUniform2f(getUniform(uni), vec.x, vec.y);
123
+    gl::glUniform2f(getUniform(uni), vec.x, vec.y);
122
 }
124
 }
123
 
125
 
124
 void Shader::loadUniform(int uni, glm::vec4 vec) {
126
 void Shader::loadUniform(int uni, glm::vec4 vec) {
125
-    glUniform4f(getUniform(uni), vec.r, vec.g, vec.b, vec.a);
127
+    gl::glUniform4f(getUniform(uni), vec.r, vec.g, vec.b, vec.a);
126
 }
128
 }
127
 
129
 
128
 void Shader::loadUniform(int uni, glm::mat4 mat) {
130
 void Shader::loadUniform(int uni, glm::mat4 mat) {
129
-    glUniformMatrix4fv(getUniform(uni), 1, GL_FALSE, &mat[0][0]);
131
+    gl::glUniformMatrix4fv(getUniform(uni), 1, gl::GL_FALSE, &mat[0][0]);
130
 }
132
 }
131
 
133
 
132
 void Shader::loadUniform(int uni, int texture, TextureStorage store) {
134
 void Shader::loadUniform(int uni, int texture, TextureStorage store) {
133
-    glUniform1i(getUniform(uni), TextureManager::bindTexture(texture, store));
135
+    gl::glUniform1i(getUniform(uni), TextureManager::bindTexture(texture, store));
134
 }
136
 }
135
 
137
 
136
 void Shader::use() {
138
 void Shader::use() {
137
-    assert(programID >= 0);
138
-    glUseProgram(programID);
139
+    orAssert(programID >= 0);
140
+    gl::glUseProgram(programID);
139
 }
141
 }
140
 
142
 
141
 int Shader::compile(const char* vertex, const char* fragment) {
143
 int Shader::compile(const char* vertex, const char* fragment) {
142
-    assert(vertex != nullptr);
143
-    assert(fragment != nullptr);
144
+    orAssert(vertex != nullptr);
145
+    orAssert(fragment != nullptr);
144
 
146
 
145
-    GLuint vertexID = glCreateShader(GL_VERTEX_SHADER);
146
-    GLuint fragmentID = glCreateShader(GL_FRAGMENT_SHADER);
147
+    gl::GLuint vertexID = gl::glCreateShader(gl::GL_VERTEX_SHADER);
148
+    gl::GLuint fragmentID = gl::glCreateShader(gl::GL_FRAGMENT_SHADER);
147
 
149
 
148
-    GLint result = GLint(GL_FALSE);
149
-    GLint logLength = 0;
150
+    gl::GLint result = gl::GLint(gl::GL_FALSE);
151
+    gl::GLint logLength = 0;
150
 
152
 
151
     // Compile vertex shader
153
     // Compile vertex shader
152
-    glShaderSource(vertexID, 1, &vertex, nullptr);
153
-    glCompileShader(vertexID);
154
+    gl::glShaderSource(vertexID, 1, &vertex, nullptr);
155
+    gl::glCompileShader(vertexID);
154
 
156
 
155
     // Check vertex shader
157
     // Check vertex shader
156
-    glGetShaderiv(vertexID, GL_COMPILE_STATUS, &result);
157
-    glGetShaderiv(vertexID, GL_INFO_LOG_LENGTH, &logLength);
158
-    if ((logLength > 0) && (result != GLint(GL_TRUE))) {
158
+    gl::glGetShaderiv(vertexID, gl::GL_COMPILE_STATUS, &result);
159
+    gl::glGetShaderiv(vertexID, gl::GL_INFO_LOG_LENGTH, &logLength);
160
+    if ((logLength > 0) && (result != gl::GLint(gl::GL_TRUE))) {
159
         std::vector<char> message(logLength + 1);
161
         std::vector<char> message(logLength + 1);
160
-        glGetShaderInfoLog(vertexID, logLength, nullptr, &message[0]);
162
+        gl::glGetShaderInfoLog(vertexID, logLength, nullptr, &message[0]);
161
         Log::get(LOG_ERROR) << "Vertex Shader compilation error:" << Log::endl;
163
         Log::get(LOG_ERROR) << "Vertex Shader compilation error:" << Log::endl;
162
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
164
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
163
-        glDeleteShader(vertexID);
164
-        glDeleteShader(fragmentID);
165
+        gl::glDeleteShader(vertexID);
166
+        gl::glDeleteShader(fragmentID);
165
         return -1;
167
         return -1;
166
     }
168
     }
167
 
169
 
168
     // Compile fragment shader
170
     // Compile fragment shader
169
-    glShaderSource(fragmentID, 1, &fragment, nullptr);
170
-    glCompileShader(fragmentID);
171
+    gl::glShaderSource(fragmentID, 1, &fragment, nullptr);
172
+    gl::glCompileShader(fragmentID);
171
 
173
 
172
     // Check fragment shader
174
     // Check fragment shader
173
-    glGetShaderiv(fragmentID, GL_COMPILE_STATUS, &result);
174
-    glGetShaderiv(fragmentID, GL_INFO_LOG_LENGTH, &logLength);
175
-    if ((logLength > 0) && (result != GLint(GL_TRUE))) {
175
+    gl::glGetShaderiv(fragmentID, gl::GL_COMPILE_STATUS, &result);
176
+    gl::glGetShaderiv(fragmentID, gl::GL_INFO_LOG_LENGTH, &logLength);
177
+    if ((logLength > 0) && (result != gl::GLint(gl::GL_TRUE))) {
176
         std::vector<char> message(logLength + 1);
178
         std::vector<char> message(logLength + 1);
177
-        glGetShaderInfoLog(fragmentID, logLength, nullptr, &message[0]);
179
+        gl::glGetShaderInfoLog(fragmentID, logLength, nullptr, &message[0]);
178
         Log::get(LOG_ERROR) << "Fragment Shader compilation error:" << Log::endl;
180
         Log::get(LOG_ERROR) << "Fragment Shader compilation error:" << Log::endl;
179
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
181
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
180
-        glDeleteShader(vertexID);
181
-        glDeleteShader(fragmentID);
182
+        gl::glDeleteShader(vertexID);
183
+        gl::glDeleteShader(fragmentID);
182
         return -2;
184
         return -2;
183
     }
185
     }
184
 
186
 
185
     // Link both shaders
187
     // Link both shaders
186
-    programID = glCreateProgram();
187
-    glAttachShader(programID, vertexID);
188
-    glAttachShader(programID, fragmentID);
189
-    glLinkProgram(programID);
188
+    programID = gl::glCreateProgram();
189
+    gl::glAttachShader(programID, vertexID);
190
+    gl::glAttachShader(programID, fragmentID);
191
+    gl::glLinkProgram(programID);
190
 
192
 
191
     // Check resulting program
193
     // Check resulting program
192
-    glGetProgramiv(programID, GL_LINK_STATUS, &result);
193
-    glGetProgramiv(programID, GL_INFO_LOG_LENGTH, &logLength);
194
-    if ((logLength > 0) && (result != GLint(GL_TRUE))) {
194
+    gl::glGetProgramiv(programID, gl::GL_LINK_STATUS, &result);
195
+    gl::glGetProgramiv(programID, gl::GL_INFO_LOG_LENGTH, &logLength);
196
+    if ((logLength > 0) && (result != gl::GLint(gl::GL_TRUE))) {
195
         std::vector<char> message(logLength + 1);
197
         std::vector<char> message(logLength + 1);
196
-        glGetProgramInfoLog(programID, logLength, nullptr, &message[0]);
198
+        gl::glGetProgramInfoLog(programID, logLength, nullptr, &message[0]);
197
         Log::get(LOG_ERROR) << "Shader link error:" << Log::endl;
199
         Log::get(LOG_ERROR) << "Shader link error:" << Log::endl;
198
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
200
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
199
-        glDeleteShader(vertexID);
200
-        glDeleteShader(fragmentID);
201
-        glDeleteProgram(programID);
201
+        gl::glDeleteShader(vertexID);
202
+        gl::glDeleteShader(fragmentID);
203
+        gl::glDeleteProgram(programID);
202
         return -3;
204
         return -3;
203
     }
205
     }
204
 
206
 
205
-    glDeleteShader(vertexID);
206
-    glDeleteShader(fragmentID);
207
+    gl::glDeleteShader(vertexID);
208
+    gl::glDeleteShader(fragmentID);
207
     return programID;
209
     return programID;
208
 }
210
 }
209
 
211
 
210
 // ----------------------------------------------------------------------------
212
 // ----------------------------------------------------------------------------
211
 
213
 
212
 std::string Shader::getVersion(bool linked) {
214
 std::string Shader::getVersion(bool linked) {
213
-    std::ostringstream str;
214
-    if (!linked) {
215
-        str << "OpenGL v" << glGetString(GL_VERSION);
215
+    static std::string cache;
216
+    static std::string cacheLinked;
217
+    static bool cacheFilled = false;
218
+
219
+    if (!cacheFilled) {
220
+        std::ostringstream str;
221
+        str << "OpenGL v" << gl::glGetString(gl::GL_VERSION);
222
+        cache = str.str();
223
+        str.str("");
224
+        str << "OpenGL " << gl::glGetString(gl::GL_SHADING_LANGUAGE_VERSION) << " "
225
+            << gl::glGetString(gl::GL_RENDERER) << " (" << gl::glGetString(gl::GL_VENDOR) << ")";
226
+        cacheLinked = str.str();
227
+        cacheFilled = true;
228
+    }
229
+
230
+    if (linked) {
231
+        return cacheLinked;
216
     } else {
232
     } else {
217
-        str << "OpenGL " << glGetString(GL_SHADING_LANGUAGE_VERSION) << " "
218
-            << glGetString(GL_RENDERER) << " (" << glGetString(GL_VENDOR) << ")";
233
+        return cache;
219
     }
234
     }
220
-    return str.str();
221
 }
235
 }
222
 
236
 
223
 Shader Shader::textShader;
237
 Shader Shader::textShader;
226
 unsigned int Shader::vertexArrayID = 0;
240
 unsigned int Shader::vertexArrayID = 0;
227
 
241
 
228
 int Shader::initialize() {
242
 int Shader::initialize() {
229
-    glGenVertexArrays(1, &vertexArrayID);
230
-    glBindVertexArray(vertexArrayID);
243
+    gl::glGenVertexArrays(1, &vertexArrayID);
244
+    gl::glBindVertexArray(vertexArrayID);
231
 
245
 
232
     // Set background color
246
     // Set background color
233
-    glClearColor(0.0f, 0.0f, 0.4f, 1.0f);
247
+    gl::glClearColor(0.0f, 0.0f, 0.4f, 1.0f);
234
 
248
 
235
     set2DState(false);
249
     set2DState(false);
236
-    glDepthFunc(GL_LESS);
250
+    gl::glDepthFunc(gl::GL_LESS);
237
 
251
 
238
-    glEnable(GL_BLEND);
239
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
252
+    gl::glEnable(gl::GL_BLEND);
253
+    gl::glBlendFunc(gl::GL_SRC_ALPHA, gl::GL_ONE_MINUS_SRC_ALPHA);
240
 
254
 
241
-    glPointSize(5.0f);
255
+    gl::glPointSize(5.0f);
242
 
256
 
243
     if (textShader.compile(textShaderVertex, textShaderFragment) < 0)
257
     if (textShader.compile(textShaderVertex, textShaderFragment) < 0)
244
         return -1;
258
         return -1;
265
 }
279
 }
266
 
280
 
267
 void Shader::shutdown() {
281
 void Shader::shutdown() {
268
-    glDeleteVertexArrays(1, &vertexArrayID);
282
+    gl::glDeleteVertexArrays(1, &vertexArrayID);
269
 }
283
 }
270
 
284
 
271
 void Shader::set2DState(bool on, bool depth) {
285
 void Shader::set2DState(bool on, bool depth) {
272
     if (on) {
286
     if (on) {
273
-        glDisable(GL_CULL_FACE);
287
+        gl::glDisable(gl::GL_CULL_FACE);
274
         if (depth)
288
         if (depth)
275
-            glDisable(GL_DEPTH_TEST);
289
+            gl::glDisable(gl::GL_DEPTH_TEST);
276
     } else {
290
     } else {
277
-        glEnable(GL_CULL_FACE);
291
+        gl::glEnable(gl::GL_CULL_FACE);
278
         if (depth)
292
         if (depth)
279
-            glEnable(GL_DEPTH_TEST);
293
+            gl::glEnable(gl::GL_DEPTH_TEST);
280
     }
294
     }
281
 }
295
 }
282
 
296
 
283
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, glm::vec4 color,
297
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, glm::vec4 color,
284
-                    unsigned int texture, TextureStorage store, GLenum mode,
298
+                    unsigned int texture, TextureStorage store, gl::GLenum mode,
285
                     ShaderTexture* target, Shader& shader) {
299
                     ShaderTexture* target, Shader& shader) {
286
-    assert(vertices.getSize() == uvs.getSize());
287
-    if (mode == GL_TRIANGLES) {
288
-        assert((vertices.getSize() % 3) == 0);
300
+    orAssert(vertices.getSize() == uvs.getSize());
301
+    if (mode == gl::GL_TRIANGLES) {
302
+        orAssert((vertices.getSize() % 3) == 0);
289
     }
303
     }
290
 
304
 
291
     if (target == nullptr) {
305
     if (target == nullptr) {
292
-        glBindFramebuffer(GL_FRAMEBUFFER, 0);
293
-        glViewport(0, 0, Window::getSize().x, Window::getSize().y);
306
+        gl::glBindFramebuffer(gl::GL_FRAMEBUFFER, 0);
307
+        gl::glViewport(0, 0, Window::getSize().x, Window::getSize().y);
294
     } else {
308
     } else {
295
         target->bind();
309
         target->bind();
296
     }
310
     }
303
     uvs.bindBuffer(1, 2);
317
     uvs.bindBuffer(1, 2);
304
 
318
 
305
     set2DState(true);
319
     set2DState(true);
306
-    glDrawArrays(mode, 0, vertices.getSize());
320
+    gl::glDrawArrays(mode, 0, vertices.getSize());
307
     set2DState(false);
321
     set2DState(false);
308
 
322
 
309
     vertices.unbind(0);
323
     vertices.unbind(0);
313
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, unsigned int texture,
327
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, unsigned int texture,
314
                     glm::mat4 MVP, TextureStorage store, ShaderTexture* target,
328
                     glm::mat4 MVP, TextureStorage store, ShaderTexture* target,
315
                     Shader& shader) {
329
                     Shader& shader) {
316
-    assert(vertices.getSize() == uvs.getSize());
317
-    assert((vertices.getSize() % 3) == 0);
330
+    orAssert(vertices.getSize() == uvs.getSize());
331
+    orAssert((vertices.getSize() % 3) == 0);
318
 
332
 
319
     if (target == nullptr) {
333
     if (target == nullptr) {
320
-        glBindFramebuffer(GL_FRAMEBUFFER, 0);
321
-        glViewport(0, 0, Window::getSize().x, Window::getSize().y);
334
+        gl::glBindFramebuffer(gl::GL_FRAMEBUFFER, 0);
335
+        gl::glViewport(0, 0, Window::getSize().x, Window::getSize().y);
322
     } else {
336
     } else {
323
         target->bind();
337
         target->bind();
324
     }
338
     }
328
     shader.loadUniform(1, texture, store);
342
     shader.loadUniform(1, texture, store);
329
     vertices.bindBuffer(0, 3);
343
     vertices.bindBuffer(0, 3);
330
     uvs.bindBuffer(1, 2);
344
     uvs.bindBuffer(1, 2);
331
-    glDrawArrays(GL_TRIANGLES, 0, vertices.getSize());
345
+    gl::glDrawArrays(gl::GL_TRIANGLES, 0, vertices.getSize());
332
     vertices.unbind(0);
346
     vertices.unbind(0);
333
     uvs.unbind(1);
347
     uvs.unbind(1);
334
 }
348
 }
336
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, ShaderBuffer& indices,
350
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, ShaderBuffer& indices,
337
                     unsigned int texture, glm::mat4 MVP, TextureStorage store,
351
                     unsigned int texture, glm::mat4 MVP, TextureStorage store,
338
                     ShaderTexture* target, Shader& shader) {
352
                     ShaderTexture* target, Shader& shader) {
339
-    assert(vertices.getSize() == uvs.getSize());
340
-    assert((indices.getSize() % 3) == 0);
353
+    orAssert(vertices.getSize() == uvs.getSize());
354
+    orAssert((indices.getSize() % 3) == 0);
341
 
355
 
342
     if (target == nullptr) {
356
     if (target == nullptr) {
343
-        glBindFramebuffer(GL_FRAMEBUFFER, 0);
344
-        glViewport(0, 0, Window::getSize().x, Window::getSize().y);
357
+        gl::glBindFramebuffer(gl::GL_FRAMEBUFFER, 0);
358
+        gl::glViewport(0, 0, Window::getSize().x, Window::getSize().y);
345
     } else {
359
     } else {
346
         target->bind();
360
         target->bind();
347
 
361
 
348
         unsigned int sz = vertices.getSize();
362
         unsigned int sz = vertices.getSize();
349
         glm::vec3* buffer = new glm::vec3[sz];
363
         glm::vec3* buffer = new glm::vec3[sz];
350
-        glBindBuffer(GL_ARRAY_BUFFER, vertices.getBuffer());
351
-        glGetBufferSubData(GL_ARRAY_BUFFER, 0, sz * sizeof(glm::vec3), buffer);
364
+        gl::glBindBuffer(gl::GL_ARRAY_BUFFER, vertices.getBuffer());
365
+        gl::glGetBufferSubData(gl::GL_ARRAY_BUFFER, 0, sz * sizeof(glm::vec3), buffer);
352
 
366
 
353
         Log::get(LOG_DEBUG) << "drawGL Vertex dump:" << Log::endl;
367
         Log::get(LOG_DEBUG) << "drawGL Vertex dump:" << Log::endl;
354
         for (unsigned int i = 0; i < sz; i++) {
368
         for (unsigned int i = 0; i < sz; i++) {
367
     vertices.bindBuffer(0, 3);
381
     vertices.bindBuffer(0, 3);
368
     uvs.bindBuffer(1, 2);
382
     uvs.bindBuffer(1, 2);
369
     indices.bindBuffer();
383
     indices.bindBuffer();
370
-    glDrawElements(GL_TRIANGLES, indices.getSize(), GL_UNSIGNED_SHORT, nullptr);
384
+    gl::glDrawElements(gl::GL_TRIANGLES, indices.getSize(), gl::GL_UNSIGNED_SHORT, nullptr);
371
     vertices.unbind(0);
385
     vertices.unbind(0);
372
     uvs.unbind(1);
386
     uvs.unbind(1);
373
 }
387
 }
374
 
388
 
375
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, glm::mat4 MVP,
389
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, glm::mat4 MVP,
376
-                    GLenum mode, ShaderTexture* target, Shader& shader) {
377
-    assert(vertices.getSize() == colors.getSize());
378
-    if (mode == GL_TRIANGLES) {
379
-        assert((vertices.getSize() % 3) == 0);
390
+                    gl::GLenum mode, ShaderTexture* target, Shader& shader) {
391
+    orAssert(vertices.getSize() == colors.getSize());
392
+    if (mode == gl::GL_TRIANGLES) {
393
+        orAssert((vertices.getSize() % 3) == 0);
380
     }
394
     }
381
 
395
 
382
     if (target == nullptr) {
396
     if (target == nullptr) {
383
-        glBindFramebuffer(GL_FRAMEBUFFER, 0);
384
-        glViewport(0, 0, Window::getSize().x, Window::getSize().y);
397
+        gl::glBindFramebuffer(gl::GL_FRAMEBUFFER, 0);
398
+        gl::glViewport(0, 0, Window::getSize().x, Window::getSize().y);
385
     } else {
399
     } else {
386
         target->bind();
400
         target->bind();
387
     }
401
     }
390
     shader.loadUniform(0, MVP);
404
     shader.loadUniform(0, MVP);
391
     vertices.bindBuffer(0, 3);
405
     vertices.bindBuffer(0, 3);
392
     colors.bindBuffer(1, 3);
406
     colors.bindBuffer(1, 3);
393
-    glDrawArrays(mode, 0, vertices.getSize());
407
+    gl::glDrawArrays(mode, 0, vertices.getSize());
394
     vertices.unbind(0);
408
     vertices.unbind(0);
395
     colors.unbind(1);
409
     colors.unbind(1);
396
 }
410
 }
397
 
411
 
398
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, ShaderBuffer& indices,
412
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, ShaderBuffer& indices,
399
-                    glm::mat4 MVP, GLenum mode, ShaderTexture* target, Shader& shader) {
400
-    assert(vertices.getSize() == colors.getSize());
401
-    if (mode == GL_TRIANGLES) {
402
-        assert((indices.getSize() % 3) == 0);
413
+                    glm::mat4 MVP, gl::GLenum mode, ShaderTexture* target, Shader& shader) {
414
+    orAssert(vertices.getSize() == colors.getSize());
415
+    if (mode == gl::GL_TRIANGLES) {
416
+        orAssert((indices.getSize() % 3) == 0);
403
     }
417
     }
404
 
418
 
405
     if (target == nullptr) {
419
     if (target == nullptr) {
406
-        glBindFramebuffer(GL_FRAMEBUFFER, 0);
407
-        glViewport(0, 0, Window::getSize().x, Window::getSize().y);
420
+        gl::glBindFramebuffer(gl::GL_FRAMEBUFFER, 0);
421
+        gl::glViewport(0, 0, Window::getSize().x, Window::getSize().y);
408
     } else {
422
     } else {
409
         target->bind();
423
         target->bind();
410
     }
424
     }
414
     vertices.bindBuffer(0, 3);
428
     vertices.bindBuffer(0, 3);
415
     colors.bindBuffer(1, 3);
429
     colors.bindBuffer(1, 3);
416
     indices.bindBuffer();
430
     indices.bindBuffer();
417
-    glDrawElements(mode, indices.getSize(), GL_UNSIGNED_SHORT, nullptr);
431
+    gl::glDrawElements(mode, indices.getSize(), gl::GL_UNSIGNED_SHORT, nullptr);
418
     vertices.unbind(0);
432
     vertices.unbind(0);
419
     colors.unbind(1);
433
     colors.unbind(1);
420
 }
434
 }

+ 2
- 2
src/system/SoundAL.cpp View File

134
         return sources.size();
134
         return sources.size();
135
 }
135
 }
136
 
136
 
137
-int SoundAL::addSource(int buffer, float volume, bool atListener, bool loop) {
137
+int SoundAL::addSource(int buffer, float vol, bool atListener, bool loop) {
138
     if (!init) {
138
     if (!init) {
139
         Log::get(LOG_ERROR) << "SoundAL Error: Adding source, but not initialized!" << Log::endl;
139
         Log::get(LOG_ERROR) << "SoundAL Error: Adding source, but not initialized!" << Log::endl;
140
         return -1;
140
         return -1;
156
     }
156
     }
157
 
157
 
158
     alSourcei(id, AL_BUFFER, buffers.at(buffer));
158
     alSourcei(id, AL_BUFFER, buffers.at(buffer));
159
-    alSourcef(id, AL_GAIN, volume);
159
+    alSourcef(id, AL_GAIN, vol);
160
     alSourcef(id, AL_REFERENCE_DISTANCE, referenceDistance);
160
     alSourcef(id, AL_REFERENCE_DISTANCE, referenceDistance);
161
     alSourcef(id, AL_MAX_DISTANCE, maxDistance);
161
     alSourcef(id, AL_MAX_DISTANCE, maxDistance);
162
 
162
 

+ 3
- 1
src/system/Window.cpp View File

18
 #error "No windowing library selected!"
18
 #error "No windowing library selected!"
19
 #endif
19
 #endif
20
 
20
 
21
+#include <glbinding/gl/gl33.h>
22
+
21
 int Window::initialize() {
23
 int Window::initialize() {
22
     int res;
24
     int res;
23
 
25
 
65
 
67
 
66
     UI::setSize(s);
68
     UI::setSize(s);
67
     Camera::setSize(s);
69
     Camera::setSize(s);
68
-    glViewport(0, 0, s.x, s.y);
70
+    gl::glViewport(0, 0, s.x, s.y);
69
 }
71
 }
70
 
72
 
71
 glm::i32vec2 Window::getSize() {
73
 glm::i32vec2 Window::getSize() {

+ 4
- 2
src/system/WindowGLFW.cpp View File

18
 #include "system/Window.h"
18
 #include "system/Window.h"
19
 #include "system/WindowGLFW.h"
19
 #include "system/WindowGLFW.h"
20
 
20
 
21
+#include <glbinding/gl/gl33.h>
22
+
21
 glm::i32vec2 WindowGLFW::size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
23
 glm::i32vec2 WindowGLFW::size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
22
 bool WindowGLFW::fullscreen = false;
24
 bool WindowGLFW::fullscreen = false;
23
 bool WindowGLFW::mousegrab = false;
25
 bool WindowGLFW::mousegrab = false;
40
     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
42
     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
41
     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
43
     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
42
     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
44
     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
43
-    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, int(GL_TRUE));
45
+    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, int(gl::GL_TRUE));
44
 
46
 
45
     window = glfwCreateWindow(size.x, size.y, VERSION,
47
     window = glfwCreateWindow(size.x, size.y, VERSION,
46
                               fullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
48
                               fullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
89
 }
91
 }
90
 
92
 
91
 void WindowGLFW::setSize(glm::i32vec2 s) {
93
 void WindowGLFW::setSize(glm::i32vec2 s) {
92
-    assert((s.x > 0) && (s.y > 0));
94
+    orAssert((s.x > 0) && (s.y > 0));
93
     if (window) {
95
     if (window) {
94
         if ((size.x != s.x) || (size.y != s.y)) {
96
         if ((size.x != s.x) || (size.y != s.y)) {
95
             glfwSetWindowSize(window, s.x, s.y);
97
             glfwSetWindowSize(window, s.x, s.y);

+ 1
- 1
src/system/WindowSDL.cpp View File

518
 }
518
 }
519
 
519
 
520
 void WindowSDL::setSize(glm::i32vec2 s) {
520
 void WindowSDL::setSize(glm::i32vec2 s) {
521
-    assert((s.x > 0) && (s.y > 0));
521
+    orAssert((s.x > 0) && (s.y > 0));
522
     if (window) {
522
     if (window) {
523
         if ((s.x != size.x) || (s.y != size.y)) {
523
         if ((s.x != size.x) || (s.y != size.y)) {
524
             SDL_SetWindowSize(window, s.x, s.y);
524
             SDL_SetWindowSize(window, s.x, s.y);

+ 2
- 2
src/utils/Folder.cpp View File

85
 
85
 
86
 File& Folder::getFile(unsigned long i) {
86
 File& Folder::getFile(unsigned long i) {
87
     createFolderItems();
87
     createFolderItems();
88
-    assert(i < files.size());
88
+    orAssert(i < files.size());
89
     return files.at(i);
89
     return files.at(i);
90
 }
90
 }
91
 
91
 
96
 
96
 
97
 Folder& Folder::getFolder(unsigned long i) {
97
 Folder& Folder::getFolder(unsigned long i) {
98
     createFolderItems();
98
     createFolderItems();
99
-    assert(i < folders.size());
99
+    orAssert(i < folders.size());
100
     return folders.at(i);
100
     return folders.at(i);
101
 }
101
 }
102
 
102
 

+ 4
- 4
src/utils/FolderRecursive.cpp View File

26
 
26
 
27
 std::string Folder::getRecursiveFileName(unsigned long i) {
27
 std::string Folder::getRecursiveFileName(unsigned long i) {
28
     createFolderItems();
28
     createFolderItems();
29
-    assert(i < countRecursiveFiles());
29
+    orAssert(i < countRecursiveFiles());
30
     if (i < fileCount()) {
30
     if (i < fileCount()) {
31
         return getFile(i).getName();
31
         return getFile(i).getName();
32
     } else {
32
     } else {
40
         }
40
         }
41
     }
41
     }
42
 
42
 
43
-    assert(false);
43
+    orAssert(false);
44
     return "";
44
     return "";
45
 }
45
 }
46
 
46
 
47
 File& Folder::getRecursiveFile(unsigned long i) {
47
 File& Folder::getRecursiveFile(unsigned long i) {
48
     createFolderItems();
48
     createFolderItems();
49
-    assert(i < countRecursiveFiles());
49
+    orAssert(i < countRecursiveFiles());
50
     if (i < fileCount()) {
50
     if (i < fileCount()) {
51
         return getFile(i);
51
         return getFile(i);
52
     } else {
52
     } else {
59
         }
59
         }
60
     }
60
     }
61
 
61
 
62
-    assert(false);
62
+    orAssert(false);
63
     return files.at(0);
63
     return files.at(0);
64
 }
64
 }
65
 
65
 

+ 11
- 11
src/utils/binary.cpp View File

101
 // ----------------------------------------------------------------------------
101
 // ----------------------------------------------------------------------------
102
 
102
 
103
 BinaryFile::BinaryFile(std::string f) {
103
 BinaryFile::BinaryFile(std::string f) {
104
-    assertEqual(open(f), 0);
104
+    orAssertEqual(open(f), 0);
105
 }
105
 }
106
 
106
 
107
 BinaryFile::~BinaryFile() {
107
 BinaryFile::~BinaryFile() {
121
 }
121
 }
122
 
122
 
123
 long long BinaryFile::tell() {
123
 long long BinaryFile::tell() {
124
-    assert(file.is_open());
124
+    orAssert(file.is_open());
125
     return file.tellg();
125
     return file.tellg();
126
 }
126
 }
127
 
127
 
128
 void BinaryFile::seek(long long pos) {
128
 void BinaryFile::seek(long long pos) {
129
-    assert(file.is_open());
129
+    orAssert(file.is_open());
130
     file.seekg(pos);
130
     file.seekg(pos);
131
 }
131
 }
132
 
132
 
136
 }
136
 }
137
 
137
 
138
 void BinaryFile::read(char* d, int c) {
138
 void BinaryFile::read(char* d, int c) {
139
-    assert(file.is_open());
140
-    assert(file.good());
139
+    orAssert(file.is_open());
140
+    orAssert(file.good());
141
     file.read(d, c);
141
     file.read(d, c);
142
 }
142
 }
143
 
143
 
144
 // ----------------------------------------------------------------------------
144
 // ----------------------------------------------------------------------------
145
 
145
 
146
 BinaryMemory::BinaryMemory(const char* d, long long m) : data(nullptr), offset(0), max(-1) {
146
 BinaryMemory::BinaryMemory(const char* d, long long m) : data(nullptr), offset(0), max(-1) {
147
-    assertEqual(open(d, m), 0);
147
+    orAssertEqual(open(d, m), 0);
148
 }
148
 }
149
 
149
 
150
 BinaryMemory::~BinaryMemory() {
150
 BinaryMemory::~BinaryMemory() {
164
 }
164
 }
165
 
165
 
166
 long long BinaryMemory::tell() {
166
 long long BinaryMemory::tell() {
167
-    assertGreaterThanEqual(offset, 0);
167
+    orAssertGreaterThanEqual(offset, 0);
168
     return offset;
168
     return offset;
169
 }
169
 }
170
 
170
 
171
 void BinaryMemory::seek(long long pos) {
171
 void BinaryMemory::seek(long long pos) {
172
-    assertGreaterThanEqual(pos, 0);
172
+    orAssertGreaterThanEqual(pos, 0);
173
     offset = pos;
173
     offset = pos;
174
 }
174
 }
175
 
175
 
178
 }
178
 }
179
 
179
 
180
 void BinaryMemory::read(char* d, int c) {
180
 void BinaryMemory::read(char* d, int c) {
181
-    assertGreaterThanEqual(offset, 0);
182
-    assertGreaterThan(c, 0);
183
-    assertLessThanEqual(offset + c, max);
181
+    orAssertGreaterThanEqual(offset, 0);
182
+    orAssertGreaterThan(c, 0);
183
+    orAssertLessThanEqual(offset + c, max);
184
     for (int i = 0; i < c; i++) {
184
     for (int i = 0; i < c; i++) {
185
         d[i] = data[offset + i];
185
         d[i] = data[offset + i];
186
     }
186
     }

+ 5
- 5
src/utils/filesystem.cpp View File

25
 #if defined(HAVE_UNISTD_H) && defined(HAVE_GETCWD)
25
 #if defined(HAVE_UNISTD_H) && defined(HAVE_GETCWD)
26
 
26
 
27
     char path[1024];
27
     char path[1024];
28
-    assertEqual(getcwd(path, 1024), path);
28
+    orAssertEqual(getcwd(path, 1024), path);
29
     return std::string(path);
29
     return std::string(path);
30
 
30
 
31
 #else
31
 #else
32
 
32
 
33
-    assert(false);
33
+    orAssert(false);
34
     return "";
34
     return "";
35
 
35
 
36
 #endif
36
 #endif
40
 #if defined(HAVE_STDLIB_H) && defined(HAVE_GETENV)
40
 #if defined(HAVE_STDLIB_H) && defined(HAVE_GETENV)
41
 
41
 
42
     char* path = getenv("HOME");
42
     char* path = getenv("HOME");
43
-    assert(path != nullptr);
43
+    orAssert(path != nullptr);
44
     return path;
44
     return path;
45
 
45
 
46
 #elif defined(_WIN32)
46
 #elif defined(_WIN32)
47
 
47
 
48
     char path[MAX_PATH];
48
     char path[MAX_PATH];
49
-    assertEqual(SHGetFolderPath(nullptr, CSIDL_PROFILE, nullptr, 0, path), S_OK);
49
+    orAssertEqual(SHGetFolderPath(nullptr, CSIDL_PROFILE, nullptr, 0, path), S_OK);
50
     size_t lenPath = strlen(path);
50
     size_t lenPath = strlen(path);
51
     for (unsigned int i = 0; i < lenPath; i++)
51
     for (unsigned int i = 0; i < lenPath; i++)
52
         if (path[i] == '\\')
52
         if (path[i] == '\\')
55
 
55
 
56
 #else
56
 #else
57
 
57
 
58
-    assert(false);
58
+    orAssert(false);
59
     return "";
59
     return "";
60
 
60
 
61
 #endif
61
 #endif

+ 9
- 9
src/utils/pcx.cpp View File

15
 #include "utils/pcx.h"
15
 #include "utils/pcx.h"
16
 
16
 
17
 int pcxCheck(const char* filename) {
17
 int pcxCheck(const char* filename) {
18
-    assert(filename != nullptr);
19
-    assert(filename[0] != '\0');
18
+    orAssert(filename != nullptr);
19
+    orAssert(filename[0] != '\0');
20
 
20
 
21
     std::ifstream file(filename, std::ios::in | std::ios::binary);
21
     std::ifstream file(filename, std::ios::in | std::ios::binary);
22
 
22
 
69
 int pcxLoad(const char* filename, unsigned char** image,
69
 int pcxLoad(const char* filename, unsigned char** image,
70
             unsigned int* width, unsigned int* height,
70
             unsigned int* width, unsigned int* height,
71
             ColorMode* mode, unsigned int* bpp) {
71
             ColorMode* mode, unsigned int* bpp) {
72
-    assert(filename != nullptr);
73
-    assert(filename[0] != '\0');
74
-    assert(image != nullptr);
75
-    assert(width != nullptr);
76
-    assert(height != nullptr);
77
-    assert(mode != nullptr);
78
-    assert(bpp != nullptr);
72
+    orAssert(filename != nullptr);
73
+    orAssert(filename[0] != '\0');
74
+    orAssert(image != nullptr);
75
+    orAssert(width != nullptr);
76
+    orAssert(height != nullptr);
77
+    orAssert(mode != nullptr);
78
+    orAssert(bpp != nullptr);
79
 
79
 
80
     std::ifstream file(filename, std::ios::in | std::ios::binary);
80
     std::ifstream file(filename, std::ios::in | std::ios::binary);
81
 
81
 

+ 16
- 16
src/utils/pixel.cpp View File

10
 
10
 
11
 unsigned char* generateColorTexture(glm::vec4 rgba, unsigned int width,
11
 unsigned char* generateColorTexture(glm::vec4 rgba, unsigned int width,
12
                                     unsigned int height, unsigned int bpp) {
12
                                     unsigned int height, unsigned int bpp) {
13
-    assert(width > 0);
14
-    assert(height > 0);
15
-    assert((bpp == 24) || (bpp == 32));
13
+    orAssert(width > 0);
14
+    orAssert(height > 0);
15
+    orAssert((bpp == 24) || (bpp == 32));
16
 
16
 
17
     unsigned char* image = new unsigned char[height * width * (bpp / 8)];
17
     unsigned char* image = new unsigned char[height * width * (bpp / 8)];
18
     for (unsigned int i = 0; i < (width * height); i++) {
18
     for (unsigned int i = 0; i < (width * height); i++) {
27
 }
27
 }
28
 
28
 
29
 void argb2rgba32(unsigned char* image, unsigned int w, unsigned int h) {
29
 void argb2rgba32(unsigned char* image, unsigned int w, unsigned int h) {
30
-    assert(image != nullptr);
31
-    assert(w > 0);
32
-    assert(h > 0);
30
+    orAssert(image != nullptr);
31
+    orAssert(w > 0);
32
+    orAssert(h > 0);
33
 
33
 
34
     for (unsigned int i = 0; i < (w * h); ++i) {
34
     for (unsigned int i = 0; i < (w * h); ++i) {
35
         // 32-bit ARGB to RGBA
35
         // 32-bit ARGB to RGBA
42
 }
42
 }
43
 
43
 
44
 unsigned char* argb16to32(unsigned char* image, unsigned int w, unsigned int h) {
44
 unsigned char* argb16to32(unsigned char* image, unsigned int w, unsigned int h) {
45
-    assert(image != nullptr);
46
-    assert(w > 0);
47
-    assert(h > 0);
45
+    orAssert(image != nullptr);
46
+    orAssert(w > 0);
47
+    orAssert(h > 0);
48
 
48
 
49
     unsigned char* img = new unsigned char[w * h * 4];
49
     unsigned char* img = new unsigned char[w * h * 4];
50
     for (unsigned int i = 0; i < (w * h); ++i) {
50
     for (unsigned int i = 0; i < (w * h); ++i) {
63
 }
63
 }
64
 
64
 
65
 unsigned char* grayscale2rgba(unsigned char* image, unsigned int w, unsigned int h) {
65
 unsigned char* grayscale2rgba(unsigned char* image, unsigned int w, unsigned int h) {
66
-    assert(image != nullptr);
67
-    assert(w > 0);
68
-    assert(h > 0);
66
+    orAssert(image != nullptr);
67
+    orAssert(w > 0);
68
+    orAssert(h > 0);
69
 
69
 
70
     unsigned char* img = new unsigned char[w * h * 4];
70
     unsigned char* img = new unsigned char[w * h * 4];
71
     for (unsigned int i = 0; i < (w * h); i++) {
71
     for (unsigned int i = 0; i < (w * h); i++) {
88
                            unsigned int bpp) {
88
                            unsigned int bpp) {
89
     unsigned int width = *w;
89
     unsigned int width = *w;
90
     unsigned int height = *h;
90
     unsigned int height = *h;
91
-    assert(image != nullptr);
92
-    assert(width > 0);
93
-    assert(height > 0);
94
-    assert((bpp % 8) == 0);
91
+    orAssert(image != nullptr);
92
+    orAssert(width > 0);
93
+    orAssert(height > 0);
94
+    orAssert((bpp % 8) == 0);
95
 
95
 
96
     unsigned int components = bpp / 8;
96
     unsigned int components = bpp / 8;
97
     unsigned int original_height = height;
97
     unsigned int original_height = height;

+ 1
- 1
src/utils/random.cpp View File

21
     if (max == min)
21
     if (max == min)
22
         return max;
22
         return max;
23
 
23
 
24
-    assertGreaterThan(max, min);
24
+    orAssertGreaterThan(max, min);
25
 
25
 
26
     if (!engineIsSeeded) {
26
     if (!engineIsSeeded) {
27
         engine.seed(std::chrono::system_clock::now().time_since_epoch().count());
27
         engine.seed(std::chrono::system_clock::now().time_since_epoch().count());

+ 3
- 3
test/Script.cpp View File

163
 }
163
 }
164
 
164
 
165
 static int runForPayload(unsigned int n, bool print, bool printData) {
165
 static int runForPayload(unsigned int n, bool print, bool printData) {
166
-    assert(n < testPayloadCount);
166
+    orAssert(n < testPayloadCount);
167
     // Get temp file name
167
     // Get temp file name
168
     char tmpFile[] = "/tmp/openraider_unit_test_0";
168
     char tmpFile[] = "/tmp/openraider_unit_test_0";
169
     FILE* f;
169
     FILE* f;
205
             if (strcmp(argv[1], "--printScript") == 0) {
205
             if (strcmp(argv[1], "--printScript") == 0) {
206
                 printData = false;
206
                 printData = false;
207
             }
207
             }
208
-            assert(testPayloadCount < 10);
208
+            orAssert(testPayloadCount < 10);
209
             if ((argv[2][0] >= '0')
209
             if ((argv[2][0] >= '0')
210
                 && (static_cast<unsigned int>(argv[2][0]) <= (testPayloadCount + '0'))) {
210
                 && (static_cast<unsigned int>(argv[2][0]) <= (testPayloadCount + '0'))) {
211
                 whichFile = argv[2][0] - '0';
211
                 whichFile = argv[2][0] - '0';
228
         if (whichFile == -1) {
228
         if (whichFile == -1) {
229
             // From given path
229
             // From given path
230
             Script s;
230
             Script s;
231
-            assertEqual(s.load(argv[2]), 0);
231
+            orAssertEqual(s.load(argv[2]), 0);
232
             return printDataScript(s, printData);
232
             return printDataScript(s, printData);
233
         } else {
233
         } else {
234
             // From payload
234
             // From payload

Loading…
Cancel
Save