소스 검색

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

Thomas Buck 9 년 전
부모
커밋
9121091e5e

+ 27
- 22
ChangeLog.md 파일 보기

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

+ 1
- 4
cmake/travis_script_linux.sh 파일 보기

@@ -11,10 +11,7 @@ if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.5"; fi
11 11
 #curl -L https://github.com/hpicgs/glbinding/archive/${GLBVER}.tar.gz | tar xzf -
12 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 15
 git clone https://github.com/hpicgs/glbinding.git
19 16
 cd glbinding
20 17
 

+ 4
- 4
include/RoomData.h 파일 보기

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

+ 35
- 46
include/global.h 파일 보기

@@ -66,29 +66,21 @@ typedef enum {
66 66
     unknownKey // Should always be at the end
67 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 74
 // If available, use our own assert that prints the call stack
83 75
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
84 76
 
85
-#ifndef NODEBUG
77
+#ifndef NDEBUG
86 78
 
87 79
 #include <iostream>
88 80
 #include <execinfo.h>
89 81
 
90 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 84
         const char* str = nullptr) {
93 85
     const unsigned int maxSize = 128;
94 86
     void* callstack[maxSize];
@@ -108,85 +100,82 @@ template<typename T, typename U>
108 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 104
     auto assertEvalTemp = x; \
116 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 110
     auto assertEvalTemp = x; \
122 111
     auto assertEvalTemp2 = y; \
123 112
     if (assertEvalTemp != assertEvalTemp2) \
124
-        assertEqualImplementation(#x " == " #y, assertEvalTemp, assertEvalTemp2, \
113
+        orAssertImplementation(#x " == " #y, assertEvalTemp, assertEvalTemp2, \
125 114
                                   __FILE__, __LINE__, "!="); \
126 115
 }
127 116
 
128
-#define assertNotEqual(x, y) { \
117
+#define orAssertNotEqual(x, y) { \
129 118
     auto assertEvalTemp = x; \
130 119
     auto assertEvalTemp2 = y; \
131 120
     if (assertEvalTemp == assertEvalTemp2) \
132
-        assertEqualImplementation(#x " != " #y, assertEvalTemp, assertEvalTemp2, \
121
+        orAssertImplementation(#x " != " #y, assertEvalTemp, assertEvalTemp2, \
133 122
                                   __FILE__, __LINE__, "=="); \
134 123
 }
135 124
 
136
-#define assertLessThan(x, y) { \
125
+#define orAssertLessThan(x, y) { \
137 126
     auto assertEvalTemp = x; \
138 127
     auto assertEvalTemp2 = y; \
139 128
     if (assertEvalTemp >= assertEvalTemp2) \
140
-        assertEqualImplementation(#x " < " #y, assertEvalTemp, assertEvalTemp2, \
129
+        orAssertImplementation(#x " < " #y, assertEvalTemp, assertEvalTemp2, \
141 130
                                   __FILE__, __LINE__, ">="); \
142 131
 }
143 132
 
144
-#define assertLessThanEqual(x, y) { \
133
+#define orAssertLessThanEqual(x, y) { \
145 134
     auto assertEvalTemp = x; \
146 135
     auto assertEvalTemp2 = y; \
147 136
     if (assertEvalTemp > assertEvalTemp2) \
148
-        assertEqualImplementation(#x " <= " #y, assertEvalTemp, assertEvalTemp2, \
137
+        orAssertImplementation(#x " <= " #y, assertEvalTemp, assertEvalTemp2, \
149 138
                                   __FILE__, __LINE__, ">"); \
150 139
 }
151 140
 
152
-#define assertGreaterThan(x, y) { \
141
+#define orAssertGreaterThan(x, y) { \
153 142
     auto assertEvalTemp = x; \
154 143
     auto assertEvalTemp2 = y; \
155 144
     if (assertEvalTemp <= assertEvalTemp2) \
156
-        assertEqualImplementation(#x " > " #y, assertEvalTemp, assertEvalTemp2, \
145
+        orAssertImplementation(#x " > " #y, assertEvalTemp, assertEvalTemp2, \
157 146
                                   __FILE__, __LINE__, "<="); \
158 147
 }
159 148
 
160
-#define assertGreaterThanEqual(x, y) { \
149
+#define orAssertGreaterThanEqual(x, y) { \
161 150
     auto assertEvalTemp = x; \
162 151
     auto assertEvalTemp2 = y; \
163 152
     if (assertEvalTemp < assertEvalTemp2) \
164
-        assertEqualImplementation(#x " >= " #y, assertEvalTemp, assertEvalTemp2, \
153
+        orAssertImplementation(#x " >= " #y, assertEvalTemp, assertEvalTemp2, \
165 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 169
 #else // EXECINFO
181 170
 
182 171
 // Fall back to the default C assert
183 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 180
 #endif // EXECINFO
192 181
 

+ 1
- 0
include/loader/Loader.h 파일 보기

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

+ 6
- 4
include/system/Shader.h 파일 보기

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

+ 1
- 1
include/system/SoundAL.h 파일 보기

@@ -21,7 +21,7 @@ class SoundAL {
21 21
     static int loadBuffer(unsigned char* buffer, unsigned int length);
22 22
 
23 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 26
     static int sourceAt(int source, glm::vec3 pos);
27 27
     static void listenAt(glm::vec3 pos, glm::vec3 at, glm::vec3 up);

+ 1
- 1
include/system/WindowGLFW.h 파일 보기

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

+ 2
- 1
src/Camera.cpp 파일 보기

@@ -17,6 +17,7 @@
17 17
 #include "system/Window.h"
18 18
 #include "Camera.h"
19 19
 
20
+#include <glbinding/gl/gl33.h>
20 21
 #include <glm/gtc/epsilon.hpp>
21 22
 #include <glm/gtc/matrix_transform.hpp>
22 23
 #include <glm/gtc/quaternion.hpp>
@@ -396,7 +397,7 @@ bool Camera::boxInFrustum(BoundingBox b) {
396 397
 void Camera::displayFrustum(glm::mat4 MVP) {
397 398
     Shader::set2DState(true, false);
398 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 401
     Shader::set2DState(false, false);
401 402
 }
402 403
 

+ 1
- 1
src/Console.cpp 파일 보기

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

+ 2
- 4
src/Entity.cpp 파일 보기

@@ -57,8 +57,8 @@ void Entity::display(glm::mat4 VP) {
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 64
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));
@@ -80,8 +80,6 @@ void Entity::display(glm::mat4 VP) {
80 80
     } else if (cacheType == CACHE_MODEL) {
81 81
         if (showEntityModels)
82 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 파일 보기

@@ -82,7 +82,7 @@ int Game::loadLevel(std::string level) {
82 82
 }
83 83
 
84 84
 void Game::handleAction(ActionEvents action, bool isFinished) {
85
-    assertLessThan(action, ActionEventCount);
85
+    orAssertLessThan(action, ActionEventCount);
86 86
 
87 87
     if (!mLoaded)
88 88
         return;
@@ -113,14 +113,14 @@ void Game::handleControllerAxis(float value, KeyboardButton axis) {
113 113
 }
114 114
 
115 115
 Entity& Game::getLara() {
116
-    assertGreaterThanEqual(mLara, 0);
117
-    assertLessThan(mLara, getWorld().sizeEntity());
116
+    orAssertGreaterThanEqual(mLara, 0);
117
+    orAssertLessThan(mLara, getWorld().sizeEntity());
118 118
     return getWorld().getEntity(mLara);
119 119
 }
120 120
 
121 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 124
     mLara = lara;
125 125
 }
126 126
 

+ 2
- 2
src/Log.cpp 파일 보기

@@ -17,8 +17,8 @@ void Log::initialize() {
17 17
 }
18 18
 
19 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 22
     return logs.at(level);
23 23
 }
24 24
 

+ 8
- 6
src/Mesh.cpp 파일 보기

@@ -9,6 +9,8 @@
9 9
 #include "TextureManager.h"
10 10
 #include "Mesh.h"
11 11
 
12
+#include <glbinding/gl/gl33.h>
13
+
12 14
 Mesh::Mesh(const std::vector<glm::vec3>& vert,
13 15
            const std::vector<IndexedRectangle>& rect,
14 16
            const std::vector<IndexedRectangle>& tri,
@@ -78,9 +80,9 @@ void Mesh::prepare() {
78 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 87
     indicesBuff = std::move(ind);
86 88
     vertices.bufferData(vert);
@@ -113,8 +115,8 @@ void Mesh::prepare() {
113 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 121
     indicesColor.bufferData(indCol);
120 122
     verticesColor.bufferData(vertCol);
@@ -152,6 +154,6 @@ void Mesh::display(glm::mat4 MVP, ShaderTexture* shaderTexture) {
152 154
     }
153 155
 
154 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 파일 보기

@@ -21,6 +21,7 @@
21 21
 #include "Render.h"
22 22
 
23 23
 #include <glm/gtc/matrix_transform.hpp>
24
+#include <glbinding/gl/gl33.h>
24 25
 
25 26
 #include "imgui/imgui.h"
26 27
 #include "stb/stb_image_write.h"
@@ -30,7 +31,7 @@ std::vector<Room*> Render::roomList;
30 31
 bool Render::displayViewFrustum = false;
31 32
 
32 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 36
     if (mode == RenderMode::LoadScreen) {
36 37
         glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f);
@@ -40,9 +41,9 @@ void Render::display() {
40 41
     }
41 42
 
42 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 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 49
     if (Camera::update()) {
@@ -74,7 +75,7 @@ void Render::display() {
74 75
         Camera::displayFrustum(VP);
75 76
 
76 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,13 +120,13 @@ void Render::buildRoomList(int room, int budget) {
119 120
 }
120 121
 
121 122
 void Render::screenShot(const char* filenameBase) {
122
-    assert(filenameBase != nullptr);
123
+    orAssert(filenameBase != nullptr);
123 124
 
124 125
     int w = Window::getSize().x;
125 126
     int h = Window::getSize().y;
126 127
     int sz = w * h;
127 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 131
     unsigned char* buffer = new unsigned char[sz * 3];
131 132
     for (int x = 0; x < w; x++) {

+ 3
- 3
src/Room.cpp 파일 보기

@@ -46,15 +46,15 @@ void Room::display(glm::mat4 VP) {
46 46
 }
47 47
 
48 48
 bool Room::isWall(unsigned long sector) {
49
-    assertLessThan(sector, sectors.size());
49
+    orAssertLessThan(sector, sectors.size());
50 50
 
51 51
     //! \fixme is (sector > 0) correct??
52 52
     return ((sector > 0) && sectors.at(sector)->isWall());
53 53
 }
54 54
 
55 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 59
     long sector = getSector(x, z);
60 60
 

+ 4
- 3
src/RoomData.cpp 파일 보기

@@ -11,6 +11,7 @@
11 11
 #include "system/Shader.h"
12 12
 #include "RoomData.h"
13 13
 
14
+#include <glbinding/gl/gl33.h>
14 15
 #include <glm/gtc/matrix_transform.hpp>
15 16
 
16 17
 void BoundingBox::display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot) {
@@ -44,7 +45,7 @@ void BoundingBox::display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot)
44 45
     vert.bufferData(verts);
45 46
     col.bufferData(cols);
46 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 50
     cols.clear();
50 51
     inds.clear();
@@ -58,7 +59,7 @@ void BoundingBox::display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot)
58 59
     vert2.bufferData(verts);
59 60
     col2.bufferData(cols);
60 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,7 +77,7 @@ void StaticModel::display(glm::mat4 VP) {
76 77
                 cache = i;
77 78
             }
78 79
         }
79
-        assertGreaterThanEqual(cache, 0);
80
+        orAssertGreaterThanEqual(cache, 0);
80 81
     }
81 82
 
82 83
     getWorld().getStaticMesh(cache).display(VP * model);

+ 3
- 3
src/RoomMesh.cpp 파일 보기

@@ -59,9 +59,9 @@ void RoomMesh::prepare() {
59 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 66
     indicesBuff = std::move(ind);
67 67
     vertices.bufferData(vert);

+ 2
- 2
src/RunTime.cpp 파일 보기

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

+ 19
- 19
src/Script.cpp 파일 보기

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

+ 8
- 8
src/SkeletalModel.cpp 파일 보기

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

+ 2
- 2
src/Sprite.cpp 파일 보기

@@ -52,8 +52,8 @@ void Sprite::display(glm::mat4 MVP) {
52 52
 // ----------------------------------------------------------------------------
53 53
 
54 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 57
     getWorld().getSprite(start + index).display(MVP);
58 58
 }
59 59
 

+ 42
- 40
src/TextureManager.cpp 파일 보기

@@ -21,6 +21,8 @@
21 21
 #include "utils/strings.h"
22 22
 #include "TextureManager.h"
23 23
 
24
+#include <glbinding/gl/gl33.h>
25
+
24 26
 glm::vec2 TextureTile::getUV(unsigned int i) {
25 27
     glm::vec2 uv(vertices.at(i).xPixel,
26 28
                  vertices.at(i).yPixel);
@@ -60,12 +62,12 @@ std::array<glm::vec4, 256> TextureManager::colorPalette;
60 62
 std::vector<std::tuple<unsigned char*, unsigned int, unsigned int>> TextureManager::indexedTextures;
61 63
 
62 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 68
     while (mTextureIdsSystem.size() < 2) {
67 69
         unsigned int id;
68
-        glGenTextures(1, &id);
70
+        gl::glGenTextures(1, &id);
69 71
         mTextureIdsSystem.push_back(id);
70 72
     }
71 73
 
@@ -107,7 +109,7 @@ int TextureManager::initializeSplash() {
107 109
 void TextureManager::shutdown() {
108 110
     while (mTextureIdsSystem.size() > 0) {
109 111
         unsigned int id = mTextureIdsSystem.at(mTextureIdsSystem.size() - 1);
110
-        glDeleteTextures(1, &id);
112
+        gl::glDeleteTextures(1, &id);
111 113
         mTextureIdsSystem.pop_back();
112 114
     }
113 115
 
@@ -120,7 +122,7 @@ void TextureManager::shutdown() {
120 122
 void TextureManager::clear() {
121 123
     while (mTextureIdsGame.size() > 0) {
122 124
         unsigned int id = mTextureIdsGame.at(mTextureIdsGame.size() - 1);
123
-        glDeleteTextures(1, &id);
125
+        gl::glDeleteTextures(1, &id);
124 126
         mTextureIdsGame.pop_back();
125 127
     }
126 128
 
@@ -142,63 +144,63 @@ int TextureManager::loadBufferSlot(unsigned char* image,
142 144
                                    unsigned int width, unsigned int height,
143 145
                                    ColorMode mode, unsigned int bpp,
144 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 150
            || (mode == ColorMode::BGR)
149 151
            || (mode == ColorMode::ARGB)
150 152
            || (mode == ColorMode::RGBA)
151 153
            || (mode ==  ColorMode::BGRA));
152
-    assert((bpp == 8) || (bpp == 24) || (bpp == 32));
154
+    orAssert((bpp == 8) || (bpp == 24) || (bpp == 32));
153 155
 
154 156
     if (slot < 0)
155 157
         slot = getIds(s).size();
156 158
 
157 159
     while (getIds(s).size() <= slot) {
158 160
         unsigned int id;
159
-        glGenTextures(1, &id);
161
+        gl::glGenTextures(1, &id);
160 162
         getIds(s).push_back(id);
161 163
     }
162 164
 
163
-    GLenum glcMode;
165
+    gl::GLenum glcMode;
164 166
     switch (mode) {
165 167
         case ColorMode::BGR:
166
-            glcMode = GL_BGR;
168
+            glcMode = gl::GL_BGR;
167 169
             break;
168 170
 
169 171
         case ColorMode::RGB:
170
-            glcMode = GL_RGB;
172
+            glcMode = gl::GL_RGB;
171 173
             break;
172 174
 
173 175
         case ColorMode::ARGB:
174 176
             if (image != nullptr)
175 177
                 argb2rgba32(image, width, height);
176
-            glcMode = GL_RGBA;
178
+            glcMode = gl::GL_RGBA;
177 179
             break;
178 180
 
179 181
         case ColorMode::BGRA:
180
-            glcMode = GL_BGRA;
182
+            glcMode = gl::GL_BGRA;
181 183
             break;
182 184
 
183 185
         case ColorMode::RGBA:
184
-            glcMode = GL_RGBA;
186
+            glcMode = gl::GL_RGBA;
185 187
             break;
186 188
     }
187 189
 
188
-    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
190
+    gl::glPixelStorei(gl::GL_UNPACK_ALIGNMENT, 1);
189 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 194
     if (filter) {
193 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 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 206
     return slot;
@@ -209,15 +211,15 @@ int TextureManager::numTextures(TextureStorage s) {
209 211
 }
210 212
 
211 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 221
 int TextureManager::bindTexture(unsigned int n, TextureStorage s) {
220
-    assertLessThan(n, getIds(s).size());
222
+    orAssertLessThan(n, getIds(s).size());
221 223
 
222 224
     if ((n < getUnits(s).size()) && (getUnits(s).at(n) >= 0)) {
223 225
         bindTextureId(n, s, getUnits(s).at(n));
@@ -233,7 +235,7 @@ int TextureManager::bindTexture(unsigned int n, TextureStorage s) {
233 235
 }
234 236
 
235 237
 unsigned int TextureManager::getTextureID(int n, TextureStorage s) {
236
-    assertLessThan(n, getIds(s).size());
238
+    orAssertLessThan(n, getIds(s).size());
237 239
     return getIds(s).at(n);
238 240
 }
239 241
 
@@ -246,8 +248,8 @@ int TextureManager::numTiles() {
246 248
 }
247 249
 
248 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 253
     return *tiles.at(index);
252 254
 }
253 255
 
@@ -263,13 +265,13 @@ int TextureManager::numAnimatedTiles() {
263 265
 }
264 266
 
265 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 270
     return animations.at(index).at(0);
269 271
 }
270 272
 
271 273
 int TextureManager::getNextTileAnimation(int index, int tile) {
272
-    assertLessThan(index, animations.size());
274
+    orAssertLessThan(index, animations.size());
273 275
     for (int i = 0; i < animations.at(index).size(); i++) {
274 276
         if (animations.at(index).at(i) == tile) {
275 277
             if (i < (animations.at(index).size() - 1))
@@ -290,14 +292,14 @@ BufferManager* TextureManager::getBufferManager(int tex, TextureStorage store) {
290 292
 }
291 293
 
292 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 297
     colorPalette[index] = color;
296 298
 }
297 299
 
298 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 303
     return colorPalette[index];
302 304
 }
303 305
 

+ 6
- 5
src/UI.cpp 파일 보기

@@ -23,6 +23,7 @@
23 23
 #include "utils/time.h"
24 24
 #include "UI.h"
25 25
 
26
+#include <glbinding/gl/gl33.h>
26 27
 #include <glm/gtc/matrix_transform.hpp>
27 28
 
28 29
 Shader UI::imguiShader;
@@ -480,7 +481,7 @@ void UI::renderImGui(ImDrawList** const cmd_lists, int cmd_lists_count) {
480 481
 
481 482
     static ShaderBuffer vert, uv, col;
482 483
 
483
-    glEnable(GL_SCISSOR_TEST);
484
+    gl::glEnable(gl::GL_SCISSOR_TEST);
484 485
     Shader::set2DState(true);
485 486
 
486 487
     imguiShader.use();
@@ -523,15 +524,15 @@ void UI::renderImGui(ImDrawList** const cmd_lists, int cmd_lists_count) {
523 524
             col.bufferData(colors);
524 525
 
525 526
             auto bm = static_cast<BufferManager*>(commands[n].texture_id);
526
-            assert(bm != nullptr);
527
+            orAssert(bm != nullptr);
527 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 531
                       Window::getSize().y - commands[n].clip_rect.w,
531 532
                       commands[n].clip_rect.z - commands[n].clip_rect.x,
532 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,7 +541,7 @@ void UI::renderImGui(ImDrawList** const cmd_lists, int cmd_lists_count) {
540 541
     col.unbind(2);
541 542
 
542 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 파일 보기

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

+ 1
- 1
src/deps/imgui/imconfig.h 파일 보기

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

+ 3
- 3
src/deps/stb/stb.cpp 파일 보기

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

+ 2
- 0
src/loader/Loader.cpp 파일 보기

@@ -55,3 +55,5 @@ std::unique_ptr<Loader> Loader::createLoader(std::string f) {
55 55
     }
56 56
 }
57 57
 
58
+Loader::~Loader() { }
59
+

+ 2
- 2
src/loader/LoaderTR1.cpp 파일 보기

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

+ 7
- 7
src/loader/LoaderTR2.cpp 파일 보기

@@ -95,7 +95,7 @@ void LoaderTR2::loadTextures() {
95 95
         int r = TextureManager::loadBufferSlot(img, 256, 256,
96 96
                                                ColorMode::ARGB, 32,
97 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 99
         delete [] img;
100 100
     }
101 101
 
@@ -137,8 +137,8 @@ void LoaderTR2::loadTextiles() {
137 137
             uint8_t yCoordinate = file.readU8();
138 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 143
             t->add(TextureTileVertex(xCoordinate, xPixel, yCoordinate, yPixel));
144 144
         }
@@ -502,9 +502,9 @@ void LoaderTR2::loadSprites() {
502 502
         int16_t negativeLength = file.read16(); // Negative sprite count
503 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 509
         SpriteSequence* ss = new SpriteSequence(objectID, offset, (negativeLength * -1));
510 510
         getWorld().addSpriteSequence(ss);
@@ -1197,7 +1197,7 @@ int LoaderTR2::loadSoundFiles(BinaryReader& sfx, unsigned int count) {
1197 1197
 
1198 1198
         int ret = Sound::loadBuffer(buff, riffSize + 8);
1199 1199
         delete [] buff;
1200
-        assertGreaterThanEqual(ret, 0);
1200
+        orAssertGreaterThanEqual(ret, 0);
1201 1201
 
1202 1202
         riffCount++;
1203 1203
     }

+ 4
- 2
src/main.cpp 파일 보기

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

+ 1
- 1
src/system/Font.cpp 파일 보기

@@ -122,6 +122,6 @@ void Font::drawFontBox(unsigned int x, unsigned int y, unsigned int w, unsigned
122 122
     uv.bufferData(uvs);
123 123
 
124 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 파일 보기

@@ -26,7 +26,7 @@ void FontTRLE::shutdown() {
26 26
 }
27 27
 
28 28
 int FontTRLE::initialize(std::string font) {
29
-    assert(stringEndsWith(font, ".pc") == true);
29
+    orAssert(stringEndsWith(font, ".pc") == true);
30 30
 
31 31
     shutdown();
32 32
 
@@ -90,7 +90,7 @@ void FontTRLE::loadLPS(std::string f) {
90 90
 
91 91
 void FontTRLE::writeChar(unsigned int index, unsigned int xDraw, unsigned int yDraw, float scale,
92 92
                          std::vector<glm::vec2>& vertices, std::vector<glm::vec2>& uvs) {
93
-    assert(mFontInit == true);
93
+    orAssert(mFontInit == true);
94 94
 
95 95
     float width = ((float)offsets[index][2]) * scale * SCALING;
96 96
     float height = ((float)offsets[index][3]) * scale * SCALING;
@@ -126,8 +126,8 @@ void FontTRLE::writeChar(unsigned int index, unsigned int xDraw, unsigned int yD
126 126
 }
127 127
 
128 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 132
     unsigned int width = 0;
133 133
     for (unsigned int i = 0; i < s.length(); i++) {
@@ -148,8 +148,8 @@ unsigned int FontTRLE::widthText(float scale, std::string s) {
148 148
 
149 149
 void FontTRLE::drawText(unsigned int x, unsigned int y, float scale,
150 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 154
     std::vector<glm::vec2> vertices;
155 155
     std::vector<glm::vec2> uvs;
@@ -173,8 +173,8 @@ void FontTRLE::drawText(unsigned int x, unsigned int y, float scale,
173 173
 }
174 174
 
175 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 179
     unsigned int x = 0;
180 180
     unsigned int yMax = 0;
@@ -207,8 +207,8 @@ unsigned int FontTRLE::heightText(float scale, unsigned int maxWidth, std::strin
207 207
 
208 208
 void FontTRLE::drawTextWrapped(unsigned int x, unsigned int y, float scale,
209 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 213
     unsigned int xStart = x;
214 214
     unsigned int yMax = 0;

+ 5
- 5
src/system/FontTTF.cpp 파일 보기

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

+ 137
- 123
src/system/Shader.cpp 파일 보기

@@ -12,97 +12,99 @@
12 12
 #include "system/Window.h"
13 13
 #include "system/Shader.h"
14 14
 
15
+#include <glbinding/gl/gl33.h>
16
+
15 17
 ShaderBuffer::~ShaderBuffer() {
16 18
     if (created)
17
-        glDeleteBuffers(1, &buffer);
19
+        gl::glDeleteBuffers(1, &buffer);
18 20
 }
19 21
 
20 22
 void ShaderBuffer::bufferData(int elem, int size, void* data) {
21 23
     if (!created) {
22
-        glGenBuffers(1, &buffer);
24
+        gl::glGenBuffers(1, &buffer);
23 25
         created = true;
24 26
     }
25 27
 
26 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 33
 void ShaderBuffer::bindBuffer() {
32 34
     if (!created) {
33
-        glGenBuffers(1, &buffer);
35
+        gl::glGenBuffers(1, &buffer);
34 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 42
 void ShaderBuffer::bindBuffer(int location, int size) {
41 43
     if (!created) {
42
-        glGenBuffers(1, &buffer);
44
+        gl::glGenBuffers(1, &buffer);
43 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 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 60
 ShaderTexture::ShaderTexture(int w, int h) : width(w), height(h) {
59
-    glGenFramebuffers(1, &framebuffer);
61
+    gl::glGenFramebuffers(1, &framebuffer);
60 62
     bind();
61 63
 
62 64
     texture = TextureManager::loadBufferSlot(nullptr, width, height, ColorMode::RGBA,
63 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 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 81
 ShaderTexture::~ShaderTexture() {
80
-    glDeleteRenderbuffers(1, &depth);
81
-    glDeleteFramebuffers(1,  &framebuffer);
82
+    gl::glDeleteRenderbuffers(1, &depth);
83
+    gl::glDeleteFramebuffers(1,  &framebuffer);
82 84
 
83 85
     //! \fixme free texture slot
84 86
 }
85 87
 
86 88
 void ShaderTexture::clear() {
87 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 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 100
 Shader::~Shader() {
99 101
     if (programID >= 0)
100
-        glDeleteProgram(programID);
102
+        gl::glDeleteProgram(programID);
101 103
 }
102 104
 
103 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 108
     if (r < 0) {
107 109
         Log::get(LOG_ERROR) << "Can't find GLSL Uniform \"" << name << "\"!" << Log::endl;
108 110
         return -1;
@@ -112,112 +114,124 @@ int Shader::addUniform(const char* name) {
112 114
 }
113 115
 
114 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 119
     return uniforms.at(n);
118 120
 }
119 121
 
120 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 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 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 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 138
 void Shader::use() {
137
-    assert(programID >= 0);
138
-    glUseProgram(programID);
139
+    orAssert(programID >= 0);
140
+    gl::glUseProgram(programID);
139 141
 }
140 142
 
141 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 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 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 161
         std::vector<char> message(logLength + 1);
160
-        glGetShaderInfoLog(vertexID, logLength, nullptr, &message[0]);
162
+        gl::glGetShaderInfoLog(vertexID, logLength, nullptr, &message[0]);
161 163
         Log::get(LOG_ERROR) << "Vertex Shader compilation error:" << Log::endl;
162 164
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
163
-        glDeleteShader(vertexID);
164
-        glDeleteShader(fragmentID);
165
+        gl::glDeleteShader(vertexID);
166
+        gl::glDeleteShader(fragmentID);
165 167
         return -1;
166 168
     }
167 169
 
168 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 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 178
         std::vector<char> message(logLength + 1);
177
-        glGetShaderInfoLog(fragmentID, logLength, nullptr, &message[0]);
179
+        gl::glGetShaderInfoLog(fragmentID, logLength, nullptr, &message[0]);
178 180
         Log::get(LOG_ERROR) << "Fragment Shader compilation error:" << Log::endl;
179 181
         Log::get(LOG_ERROR) << &message[0] << Log::endl;
180
-        glDeleteShader(vertexID);
181
-        glDeleteShader(fragmentID);
182
+        gl::glDeleteShader(vertexID);
183
+        gl::glDeleteShader(fragmentID);
182 184
         return -2;
183 185
     }
184 186
 
185 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 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 197
         std::vector<char> message(logLength + 1);
196
-        glGetProgramInfoLog(programID, logLength, nullptr, &message[0]);
198
+        gl::glGetProgramInfoLog(programID, logLength, nullptr, &message[0]);
197 199
         Log::get(LOG_ERROR) << "Shader link error:" << Log::endl;
198 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 204
         return -3;
203 205
     }
204 206
 
205
-    glDeleteShader(vertexID);
206
-    glDeleteShader(fragmentID);
207
+    gl::glDeleteShader(vertexID);
208
+    gl::glDeleteShader(fragmentID);
207 209
     return programID;
208 210
 }
209 211
 
210 212
 // ----------------------------------------------------------------------------
211 213
 
212 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 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 237
 Shader Shader::textShader;
@@ -226,19 +240,19 @@ Shader Shader::colorShader;
226 240
 unsigned int Shader::vertexArrayID = 0;
227 241
 
228 242
 int Shader::initialize() {
229
-    glGenVertexArrays(1, &vertexArrayID);
230
-    glBindVertexArray(vertexArrayID);
243
+    gl::glGenVertexArrays(1, &vertexArrayID);
244
+    gl::glBindVertexArray(vertexArrayID);
231 245
 
232 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 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 257
     if (textShader.compile(textShaderVertex, textShaderFragment) < 0)
244 258
         return -1;
@@ -265,32 +279,32 @@ int Shader::initialize() {
265 279
 }
266 280
 
267 281
 void Shader::shutdown() {
268
-    glDeleteVertexArrays(1, &vertexArrayID);
282
+    gl::glDeleteVertexArrays(1, &vertexArrayID);
269 283
 }
270 284
 
271 285
 void Shader::set2DState(bool on, bool depth) {
272 286
     if (on) {
273
-        glDisable(GL_CULL_FACE);
287
+        gl::glDisable(gl::GL_CULL_FACE);
274 288
         if (depth)
275
-            glDisable(GL_DEPTH_TEST);
289
+            gl::glDisable(gl::GL_DEPTH_TEST);
276 290
     } else {
277
-        glEnable(GL_CULL_FACE);
291
+        gl::glEnable(gl::GL_CULL_FACE);
278 292
         if (depth)
279
-            glEnable(GL_DEPTH_TEST);
293
+            gl::glEnable(gl::GL_DEPTH_TEST);
280 294
     }
281 295
 }
282 296
 
283 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 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 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 308
     } else {
295 309
         target->bind();
296 310
     }
@@ -303,7 +317,7 @@ void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, glm::vec4 color,
303 317
     uvs.bindBuffer(1, 2);
304 318
 
305 319
     set2DState(true);
306
-    glDrawArrays(mode, 0, vertices.getSize());
320
+    gl::glDrawArrays(mode, 0, vertices.getSize());
307 321
     set2DState(false);
308 322
 
309 323
     vertices.unbind(0);
@@ -313,12 +327,12 @@ void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, glm::vec4 color,
313 327
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, unsigned int texture,
314 328
                     glm::mat4 MVP, TextureStorage store, ShaderTexture* target,
315 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 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 336
     } else {
323 337
         target->bind();
324 338
     }
@@ -328,7 +342,7 @@ void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, unsigned int text
328 342
     shader.loadUniform(1, texture, store);
329 343
     vertices.bindBuffer(0, 3);
330 344
     uvs.bindBuffer(1, 2);
331
-    glDrawArrays(GL_TRIANGLES, 0, vertices.getSize());
345
+    gl::glDrawArrays(gl::GL_TRIANGLES, 0, vertices.getSize());
332 346
     vertices.unbind(0);
333 347
     uvs.unbind(1);
334 348
 }
@@ -336,19 +350,19 @@ void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, unsigned int text
336 350
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, ShaderBuffer& indices,
337 351
                     unsigned int texture, glm::mat4 MVP, TextureStorage store,
338 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 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 359
     } else {
346 360
         target->bind();
347 361
 
348 362
         unsigned int sz = vertices.getSize();
349 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 367
         Log::get(LOG_DEBUG) << "drawGL Vertex dump:" << Log::endl;
354 368
         for (unsigned int i = 0; i < sz; i++) {
@@ -367,21 +381,21 @@ void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, ShaderBuffer& ind
367 381
     vertices.bindBuffer(0, 3);
368 382
     uvs.bindBuffer(1, 2);
369 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 385
     vertices.unbind(0);
372 386
     uvs.unbind(1);
373 387
 }
374 388
 
375 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 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 399
     } else {
386 400
         target->bind();
387 401
     }
@@ -390,21 +404,21 @@ void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, glm::mat4 MVP,
390 404
     shader.loadUniform(0, MVP);
391 405
     vertices.bindBuffer(0, 3);
392 406
     colors.bindBuffer(1, 3);
393
-    glDrawArrays(mode, 0, vertices.getSize());
407
+    gl::glDrawArrays(mode, 0, vertices.getSize());
394 408
     vertices.unbind(0);
395 409
     colors.unbind(1);
396 410
 }
397 411
 
398 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 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 422
     } else {
409 423
         target->bind();
410 424
     }
@@ -414,7 +428,7 @@ void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, ShaderBuffer&
414 428
     vertices.bindBuffer(0, 3);
415 429
     colors.bindBuffer(1, 3);
416 430
     indices.bindBuffer();
417
-    glDrawElements(mode, indices.getSize(), GL_UNSIGNED_SHORT, nullptr);
431
+    gl::glDrawElements(mode, indices.getSize(), gl::GL_UNSIGNED_SHORT, nullptr);
418 432
     vertices.unbind(0);
419 433
     colors.unbind(1);
420 434
 }

+ 2
- 2
src/system/SoundAL.cpp 파일 보기

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

+ 3
- 1
src/system/Window.cpp 파일 보기

@@ -18,6 +18,8 @@
18 18
 #error "No windowing library selected!"
19 19
 #endif
20 20
 
21
+#include <glbinding/gl/gl33.h>
22
+
21 23
 int Window::initialize() {
22 24
     int res;
23 25
 
@@ -65,7 +67,7 @@ void Window::setSize(glm::i32vec2 s) {
65 67
 
66 68
     UI::setSize(s);
67 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 73
 glm::i32vec2 Window::getSize() {

+ 4
- 2
src/system/WindowGLFW.cpp 파일 보기

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

+ 1
- 1
src/system/WindowSDL.cpp 파일 보기

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

+ 2
- 2
src/utils/Folder.cpp 파일 보기

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

+ 4
- 4
src/utils/FolderRecursive.cpp 파일 보기

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

+ 11
- 11
src/utils/binary.cpp 파일 보기

@@ -101,7 +101,7 @@ int64_t BinaryReader::read64() {
101 101
 // ----------------------------------------------------------------------------
102 102
 
103 103
 BinaryFile::BinaryFile(std::string f) {
104
-    assertEqual(open(f), 0);
104
+    orAssertEqual(open(f), 0);
105 105
 }
106 106
 
107 107
 BinaryFile::~BinaryFile() {
@@ -121,12 +121,12 @@ int BinaryFile::open(std::string f) {
121 121
 }
122 122
 
123 123
 long long BinaryFile::tell() {
124
-    assert(file.is_open());
124
+    orAssert(file.is_open());
125 125
     return file.tellg();
126 126
 }
127 127
 
128 128
 void BinaryFile::seek(long long pos) {
129
-    assert(file.is_open());
129
+    orAssert(file.is_open());
130 130
     file.seekg(pos);
131 131
 }
132 132
 
@@ -136,15 +136,15 @@ bool BinaryFile::eof() {
136 136
 }
137 137
 
138 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 141
     file.read(d, c);
142 142
 }
143 143
 
144 144
 // ----------------------------------------------------------------------------
145 145
 
146 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 150
 BinaryMemory::~BinaryMemory() {
@@ -164,12 +164,12 @@ int BinaryMemory::open(const char* d, long long m) {
164 164
 }
165 165
 
166 166
 long long BinaryMemory::tell() {
167
-    assertGreaterThanEqual(offset, 0);
167
+    orAssertGreaterThanEqual(offset, 0);
168 168
     return offset;
169 169
 }
170 170
 
171 171
 void BinaryMemory::seek(long long pos) {
172
-    assertGreaterThanEqual(pos, 0);
172
+    orAssertGreaterThanEqual(pos, 0);
173 173
     offset = pos;
174 174
 }
175 175
 
@@ -178,9 +178,9 @@ bool BinaryMemory::eof() {
178 178
 }
179 179
 
180 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 184
     for (int i = 0; i < c; i++) {
185 185
         d[i] = data[offset + i];
186 186
     }

+ 5
- 5
src/utils/filesystem.cpp 파일 보기

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

+ 9
- 9
src/utils/pcx.cpp 파일 보기

@@ -15,8 +15,8 @@
15 15
 #include "utils/pcx.h"
16 16
 
17 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 21
     std::ifstream file(filename, std::ios::in | std::ios::binary);
22 22
 
@@ -69,13 +69,13 @@ int pcxCheck(const char* filename) {
69 69
 int pcxLoad(const char* filename, unsigned char** image,
70 70
             unsigned int* width, unsigned int* height,
71 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 80
     std::ifstream file(filename, std::ios::in | std::ios::binary);
81 81
 

+ 16
- 16
src/utils/pixel.cpp 파일 보기

@@ -10,9 +10,9 @@
10 10
 
11 11
 unsigned char* generateColorTexture(glm::vec4 rgba, unsigned int width,
12 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 17
     unsigned char* image = new unsigned char[height * width * (bpp / 8)];
18 18
     for (unsigned int i = 0; i < (width * height); i++) {
@@ -27,9 +27,9 @@ unsigned char* generateColorTexture(glm::vec4 rgba, unsigned int width,
27 27
 }
28 28
 
29 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 34
     for (unsigned int i = 0; i < (w * h); ++i) {
35 35
         // 32-bit ARGB to RGBA
@@ -42,9 +42,9 @@ void argb2rgba32(unsigned char* image, unsigned int w, unsigned int h) {
42 42
 }
43 43
 
44 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 49
     unsigned char* img = new unsigned char[w * h * 4];
50 50
     for (unsigned int i = 0; i < (w * h); ++i) {
@@ -63,9 +63,9 @@ unsigned char* argb16to32(unsigned char* image, unsigned int w, unsigned int h)
63 63
 }
64 64
 
65 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 70
     unsigned char* img = new unsigned char[w * h * 4];
71 71
     for (unsigned int i = 0; i < (w * h); i++) {
@@ -88,10 +88,10 @@ unsigned char* scaleBuffer(unsigned char* image, unsigned int* w, unsigned int*
88 88
                            unsigned int bpp) {
89 89
     unsigned int width = *w;
90 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 96
     unsigned int components = bpp / 8;
97 97
     unsigned int original_height = height;

+ 1
- 1
src/utils/random.cpp 파일 보기

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

+ 3
- 3
test/Script.cpp 파일 보기

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

Loading…
취소
저장