浏览代码

New assert implementation, meta improvements

Thomas Buck 10 年前
父节点
当前提交
b8ee254b56

+ 7
- 0
ChangeLog.md 查看文件

@@ -2,6 +2,13 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140517 ]
6
+    * Wrote new assert() implementation for Unix that prints a call stack
7
+    * Service provider methods (getCamera(), etc...) are now prototyped
8
+      in the header of the service they provide, making main.h useless
9
+    * Also some more work on the way to making OR compilable under Windows
10
+    * Not using glu.h anywhere anymore
11
+
5 12
     [ 20140516 ]
6 13
     * Finished moving the Entity/SkeletalModel logic into classes
7 14
     * Currently seems as if wrong SkeletalModels are used for entities?

+ 2
- 0
include/Camera.h 查看文件

@@ -99,4 +99,6 @@ private:
99 99
     vec_t mRotationDeltaY;
100 100
 };
101 101
 
102
+Camera &getCamera();
103
+
102 104
 #endif

+ 2
- 0
include/Console.h 查看文件

@@ -60,4 +60,6 @@ private:
60 60
     unsigned int mLineOffset;
61 61
 };
62 62
 
63
+Console &getConsole();
64
+
63 65
 #endif

+ 2
- 1
include/Game.h 查看文件

@@ -12,7 +12,6 @@
12 12
 
13 13
 #include "Camera.h"
14 14
 #include "Entity.h"
15
-#include "global.h"
16 15
 #include "Render.h"
17 16
 #include "TombRaider.h"
18 17
 #include "World.h"
@@ -69,4 +68,6 @@ private:
69 68
     int mLara;
70 69
 };
71 70
 
71
+Game &getGame();
72
+
72 73
 #endif

+ 6
- 0
include/Menu.h 查看文件

@@ -38,6 +38,10 @@ public:
38 38
 
39 39
 private:
40 40
 
41
+#ifdef WIN32
42
+    void loadPakFolderHelper(std::vector<char *> &list);
43
+#endif
44
+
41 45
     void loadPakFolderRecursive(const char *dir);
42 46
 
43 47
     void fillMapList();
@@ -57,4 +61,6 @@ private:
57 61
     std::vector<char *> mMapList;
58 62
 };
59 63
 
64
+Menu &getMenu();
65
+
60 66
 #endif

+ 2
- 1
include/OpenRaider.h 查看文件

@@ -10,7 +10,6 @@
10 10
 
11 11
 #include <vector>
12 12
 
13
-#include "global.h"
14 13
 #include "Console.h"
15 14
 #include "Game.h"
16 15
 #include "Menu.h"
@@ -83,4 +82,6 @@ private:
83 82
     KeyboardButton keyBindings[ActionEventCount];
84 83
 };
85 84
 
85
+OpenRaider &getOpenRaider();
86
+
86 87
 #endif

+ 6
- 7
include/Render.h 查看文件

@@ -11,14 +11,11 @@
11 11
 
12 12
 #include <vector>
13 13
 
14
-#include "config.h"
15
-#include "math/Matrix.h"
16
-#include "ViewVolume.h"
17
-#include "World.h"
18
-#include "Mesh.h"
14
+#include "Room.h"
19 15
 #include "Texture.h"
20
-#include "Camera.h"
21
-#include "RoomData.h"
16
+#include "ViewVolume.h"
17
+
18
+#include "WorldData.h"
22 19
 
23 20
 /*!
24 21
  * \brief OpenRaider Renderer class
@@ -213,4 +210,6 @@ private:
213 210
     bool mSkyMeshRotation;                //!< Should Skymesh be rotated?
214 211
 };
215 212
 
213
+Render &getRender();
214
+
216 215
 #endif

+ 2
- 2
include/Sound.h 查看文件

@@ -94,9 +94,9 @@ public:
94 94
      * \param source sound source to stop
95 95
      */
96 96
     virtual void stop(int source) = 0;
97
-
98
-private:
99 97
 };
100 98
 
99
+Sound &getSound();
100
+
101 101
 #endif
102 102
 

+ 2
- 7
include/TombRaiderData.h 查看文件

@@ -10,12 +10,7 @@
10 10
 
11 11
 #include <cstdint>
12 12
 
13
-#ifdef WIN32
14
-// Have to remove GCC packing, by removing in preprocessor
15
-#define __attribute__(packed)
16
-
17
-// MSVC++ pragma to pack structs
18
-#define TR2_H 1
13
+#ifdef _MSC_VER
19 14
 #pragma pack(push, tr2_h, 1)
20 15
 #endif
21 16
 
@@ -1135,7 +1130,7 @@ typedef struct {
1135 1130
     unsigned int unknown[24];
1136 1131
 } tr5_cinematic_frame_t;
1137 1132
 
1138
-#ifdef WIN32
1133
+#ifdef _MSC_VER
1139 1134
 #pragma pack(pop, tr2_h, 1)
1140 1135
 #endif
1141 1136
 

+ 2
- 6
include/Window.h 查看文件

@@ -8,14 +8,8 @@
8 8
 #ifndef _WINDOW_H_
9 9
 #define _WINDOW_H_
10 10
 
11
-#ifdef WIN32
12
-#define __attribute__(x)
13
-#endif
14
-
15 11
 #include <ctime>
16 12
 
17
-#include "global.h"
18
-
19 13
 typedef struct {
20 14
     char *text;
21 15
     unsigned int x;
@@ -86,4 +80,6 @@ protected:
86 80
     char *mFontName;
87 81
 };
88 82
 
83
+Window &getWindow();
84
+
89 85
 #endif

+ 1
- 12
include/WindowSDL.h 查看文件

@@ -11,17 +11,6 @@
11 11
 #include "SDL.h"
12 12
 #include "SDL_ttf.h"
13 13
 
14
-#ifdef __APPLE__
15
-#include <OpenGL/gl.h>
16
-#include <OpenGL/glu.h>
17
-#elif defined WIN32
18
-#include <gl/glew.h>
19
-#include <gl/wglew.h>
20
-#else
21
-#include <GL/gl.h>
22
-#include <GL/glu.h>
23
-#endif
24
-
25 14
 #include "Window.h"
26 15
 
27 16
 /*!
@@ -73,7 +62,7 @@ private:
73 62
     SDL_GLContext mGLContext; //!< The OpenGL Context
74 63
 
75 64
     TTF_Font *mFont;
76
-    GLuint mFontTexture;
65
+    unsigned int mFontTexture;
77 66
 
78 67
     bool mTextInput;
79 68
 

+ 2
- 0
include/World.h 查看文件

@@ -140,4 +140,6 @@ private:
140 140
     std::vector<SkeletalModel *> mModels;
141 141
 };
142 142
 
143
+World &getWorld();
144
+
143 145
 #endif

+ 18
- 0
include/config.h.in 查看文件

@@ -1,3 +1,13 @@
1
+/*!
2
+ * \file include/config.h.in
3
+ * \brief Global config file template
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _CONFIG_H_
9
+#define _CONFIG_H_
10
+
1 11
 #define VERSION "OpenRaider-@OpenRaider_VERSION_MAJOR@.@OpenRaider_VERSION_MINOR@.@OpenRaider_VERSION_MICRO@@OpenRaider_VERSION_RELEASE@ (@CMAKE_BUILD_TYPE@)"
2 12
 #define BUILD_HOST "@OpenRaider_BUILD_HOST@ @OpenRaider_HOSTNAME@"
3 13
 
@@ -5,3 +15,11 @@
5 15
 #define DEFAULT_CONFIG_FILE "OpenRaider.ini"
6 16
 #define DEFAULT_WIDTH 640
7 17
 #define DEFAULT_HEIGHT 480
18
+
19
+#cmakedefine USING_AL
20
+#cmakedefine HAVE_EXECINFO_H
21
+#cmakedefine HAVE_BACKTRACE
22
+#cmakedefine HAVE_BACKTRACE_SYMBOLS
23
+
24
+#endif
25
+

+ 28
- 0
include/global.h 查看文件

@@ -7,6 +7,34 @@
7 7
 #ifndef _GLOBAL_H_
8 8
 #define _GLOBAL_H_
9 9
 
10
+#include "config.h"
11
+
12
+// Visual C++ does not understand __attribute__
13
+#ifdef _MSC_VER
14
+#define __attribute__(x)
15
+#endif
16
+
17
+// Globally include OpenGL header
18
+#ifdef __APPLE__
19
+#include <OpenGL/gl.h>
20
+#else
21
+#ifdef WIN32
22
+#include <Windows.h>
23
+#endif
24
+#include <GL/gl.h>
25
+#endif
26
+
27
+#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
28
+#ifndef NDEBUG
29
+[[noreturn]] void assertImplementation(const char *exp, const char *file, int line);
30
+#define assert(x) (void)((x) || (assertImplementation(#x, __FILE__, __LINE__),0))
31
+#else
32
+#define assert(x)
33
+#endif
34
+#else
35
+#include <cassert>
36
+#endif
37
+
10 38
 const float BLACK[]       = {  0.0f,  0.0f,  0.0f, 1.0f };
11 39
 const float DIM_WHITE[]   = {  0.5f,  0.5f,  0.5f, 1.0f };
12 40
 const float WHITE[]       = {  1.0f,  1.0f,  1.0f, 1.0f };

+ 0
- 47
include/main.h 查看文件

@@ -1,47 +0,0 @@
1
-/*!
2
- * \file include/main.h
3
- * \brief Service locator
4
- *
5
- * \author xythobuz
6
- */
7
-#ifndef _MAIN_H_
8
-#define _MAIN_H_
9
-
10
-#include "Camera.h"
11
-#include "Console.h"
12
-#include "Game.h"
13
-#include "Menu.h"
14
-#include "OpenRaider.h"
15
-#include "Render.h"
16
-#include "Sound.h"
17
-#include "Window.h"
18
-#include "World.h"
19
-
20
-Camera &getCamera();
21
-
22
-Console &getConsole();
23
-
24
-Game &getGame();
25
-
26
-Menu &getMenu();
27
-
28
-OpenRaider &getOpenRaider();
29
-
30
-Render &getRender();
31
-
32
-Sound &getSound();
33
-
34
-Window &getWindow();
35
-
36
-World &getWorld();
37
-
38
-/*!
39
- * \brief Program entry point
40
- * \param argc number of arguments
41
- * \param argv array with argc strings
42
- * \returns 0 on success
43
- */
44
-int main(int argc, char *argv[]);
45
-
46
-#endif
47
-

+ 0
- 4
include/utils/strings.h 查看文件

@@ -9,10 +9,6 @@
9 9
 #ifndef _UTILS_STRINGS_H_
10 10
 #define _UTILS_STRINGS_H_
11 11
 
12
-#ifdef WIN32
13
-#define __attribute__(x)
14
-#endif
15
-
16 12
 #include <cstdarg>
17 13
 #include <vector>
18 14
 

+ 0
- 4
include/utils/tga.h 查看文件

@@ -8,10 +8,6 @@
8 8
 #ifndef _UTILS_TGA_H
9 9
 #define _UTILS_TGA_H
10 10
 
11
-#ifdef WIN32
12
-#define __attribute__(x)
13
-#endif
14
-
15 11
 /*!
16 12
  * \brief Possible TGA image types
17 13
  */

+ 13
- 1
src/CMakeLists.txt 查看文件

@@ -64,9 +64,10 @@ set (SRCS ${SRCS} "World.cpp")
64 64
 option (ENABLE_AUDIO "Enable Sound Output" YES)
65 65
 if (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
66 66
     set (SRCS ${SRCS} "SoundAL.cpp")
67
-    set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -DUSING_AL")
67
+    set (USING_AL TRUE)
68 68
 else (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
69 69
     set (SRCS ${SRCS} "SoundNull.cpp")
70
+    set (USING_AL FALSE)
70 71
     message (STATUS "Disabled Sound support (no OpenAL and ALUT)!")
71 72
 endif (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
72 73
 
@@ -81,6 +82,17 @@ endif (SDL2_FOUND AND SDL2TTF_FOUND)
81 82
 
82 83
 #################################################################
83 84
 
85
+# Check for header/function presence
86
+include (CheckIncludeFiles)
87
+include (CheckFunctionExists)
88
+
89
+# backtrace() for assert with call stack output
90
+check_include_files (execinfo.h HAVE_EXECINFO_H)
91
+check_function_exists (backtrace HAVE_BACKTRACE)
92
+check_function_exists (backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
93
+
94
+#################################################################
95
+
84 96
 # Configuration Header file
85 97
 configure_file (
86 98
     "${PROJECT_SOURCE_DIR}/include/config.h.in"

+ 1
- 0
src/Camera.cpp 查看文件

@@ -9,6 +9,7 @@
9 9
 #include <stdio.h>
10 10
 #include <math.h>
11 11
 
12
+#include "global.h"
12 13
 #include "Camera.h"
13 14
 
14 15
 Camera::Camera() {

+ 1
- 3
src/Command.cpp 查看文件

@@ -7,15 +7,13 @@
7 7
 
8 8
 #include <cstdio>
9 9
 #include <cstring>
10
-#include <assert.h>
11 10
 
12 11
 #include "WindowSDL.h"
13 12
 
14
-#include "config.h"
13
+#include "global.h"
15 14
 #include "Console.h"
16 15
 #include "Entity.h"
17 16
 #include "Game.h"
18
-#include "main.h"
19 17
 #include "math/math.h"
20 18
 #include "Menu.h"
21 19
 #include "Sound.h"

+ 1
- 11
src/Console.cpp 查看文件

@@ -5,19 +5,9 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
-#ifdef __APPLE__
9
-#include <OpenGL/gl.h>
10
-#elif defined WIN32
11
-#include <gl/glew.h>
12
-#include <gl/wglew.h>
13
-#else
14
-#include <GL/gl.h>
15
-#endif
16
-
17
-#include "config.h"
18 8
 #include "global.h"
19 9
 #include "Console.h"
20
-#include "main.h"
10
+#include "OpenRaider.h"
21 11
 #include "utils/strings.h"
22 12
 #include "utils/time.h"
23 13
 

+ 3
- 12
src/Entity.cpp 查看文件

@@ -5,20 +5,11 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
-#ifdef __APPLE__
9
-#include <OpenGL/gl.h>
10
-#include <OpenGL/glu.h>
11
-#elif defined WIN32
12
-#include <gl/glew.h>
13
-#include <gl/wglew.h>
14
-#else
15
-#include <GL/gl.h>
16
-#include <GL/glu.h>
17
-#endif
18
-
8
+#include "global.h"
9
+#include "Console.h"
19 10
 #include "Entity.h"
20
-#include "main.h"
21 11
 #include "Render.h"
12
+#include "World.h"
22 13
 
23 14
 #include "games/TombRaider1.h"
24 15
 

+ 3
- 11
src/Game.cpp 查看文件

@@ -5,23 +5,15 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
-#ifdef __APPLE__
9
-#include <OpenGL/gl.h>
10
-#elif defined WIN32
11
-#include <gl/glew.h>
12
-#include <gl/wglew.h>
13
-#else
14
-#include <GL/gl.h>
15
-#endif
16
-
17 8
 #include <algorithm>
18 9
 #include <map>
19 10
 #include <cstdlib>
20
-#include <assert.h>
21 11
 
22
-#include "main.h"
12
+#include "global.h"
23 13
 #include "Console.h"
24 14
 #include "Game.h"
15
+#include "OpenRaider.h"
16
+#include "Sound.h"
25 17
 #include "utils/strings.h"
26 18
 
27 19
 #include "games/TombRaider1.h"

+ 6
- 18
src/Menu.cpp 查看文件

@@ -5,28 +5,16 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
-#include <assert.h>
9 8
 #include <cctype>
10 9
 
11
-#ifdef WIN32
12
-#include <Windows.h>
13
-#else
10
+#ifndef WIN32
14 11
 #include <dirent.h>
15 12
 #endif
16 13
 
17
-#ifdef __APPLE__
18
-#include <OpenGL/gl.h>
19
-#elif defined WIN32
20
-#include <GL/glew.h>
21
-#include <GL/wglew.h>
22
-#else
23
-#include <GL/gl.h>
24
-#endif
25
-
26
-#include "config.h"
27 14
 #include "global.h"
28
-#include "main.h"
15
+#include "Console.h"
29 16
 #include "Menu.h"
17
+#include "OpenRaider.h"
30 18
 #include "utils/strings.h"
31 19
 
32 20
 Menu::Menu() {
@@ -66,7 +54,7 @@ bool Menu::isVisible() {
66 54
 }
67 55
 
68 56
 #ifdef WIN32
69
-void loadPakFolderHelper(std::list<char *> &list) {
57
+void Menu::loadPakFolderHelper(std::vector<char *> &list) {
70 58
     WIN32_FIND_DATA fd;
71 59
     char *tmp = bufferString("%s\\*", list.at(0));
72 60
     HANDLE hFind = FindFirstFile(tmp, &fd);
@@ -101,7 +89,7 @@ void loadPakFolderHelper(std::list<char *> &list) {
101 89
     FindClose(hFind);
102 90
     delete [] tmp;
103 91
     delete [] list.at(0);
104
-    list.pop_front();
92
+    list.erase(list.begin());
105 93
 }
106 94
 #endif
107 95
 
@@ -109,7 +97,7 @@ void Menu::loadPakFolderRecursive(const char *dir) {
109 97
     assert(dir != NULL);
110 98
     assert(dir[0] != '\0');
111 99
 #ifdef WIN32
112
-    std::list<char *> list;
100
+    std::vector<char *> list;
113 101
     list.push_back(bufferString("%s", dir));
114 102
     do {
115 103
         loadPakFolderHelper(list);

+ 1
- 10
src/Mesh.cpp 查看文件

@@ -6,17 +6,8 @@
6 6
  */
7 7
 
8 8
 #include <stdlib.h>
9
-#include <assert.h>
10
-
11
-#ifdef __APPLE__
12
-#include <OpenGL/gl.h>
13
-#elif defined WIN32
14
-#include <gl/glew.h>
15
-#include <gl/wglew.h>
16
-#else
17
-#include <GL/gl.h>
18
-#endif
19 9
 
10
+#include "global.h"
20 11
 #include "Mesh.h"
21 12
 
22 13
 

+ 2
- 4
src/OpenRaider.cpp 查看文件

@@ -7,12 +7,10 @@
7 7
 
8 8
 #include <cstdio>
9 9
 #include <cstring>
10
-#include <assert.h>
11 10
 
12
-#include "config.h"
11
+#include "global.h"
13 12
 #include "Console.h"
14 13
 #include "Game.h"
15
-#include "main.h"
16 14
 #include "math/math.h"
17 15
 #include "Menu.h"
18 16
 #include "Sound.h"
@@ -147,7 +145,7 @@ int OpenRaider::command(const char *command) {
147 145
         returnValue = this->command(token, &args);
148 146
     }
149 147
 
150
-    free(cmd);
148
+    delete [] cmd;
151 149
     return returnValue;
152 150
 }
153 151
 

+ 0
- 10
src/Render.cpp 查看文件

@@ -8,21 +8,11 @@
8 8
 
9 9
 #include <algorithm>
10 10
 
11
-#ifdef __APPLE__
12
-#include <OpenGL/gl.h>
13
-#elif defined WIN32
14
-#include <gl/glew.h>
15
-#include <gl/wglew.h>
16
-#else
17
-#include <GL/gl.h>
18
-#endif
19
-
20 11
 #include <stdlib.h>
21 12
 #include <math.h>
22 13
 #include <string.h>
23 14
 
24 15
 #include "global.h"
25
-#include "main.h"
26 16
 #include "Game.h"
27 17
 #include "OpenRaider.h"
28 18
 #include "Render.h"

+ 4
- 10
src/Room.cpp 查看文件

@@ -5,18 +5,12 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
-#ifdef __APPLE__
9
-#include <OpenGL/gl.h>
10
-#include <OpenGL/glu.h>
11
-#else
12
-#include <GL/gl.h>
13
-#include <GL/glu.h>
14
-#endif
15
-
16 8
 #include <algorithm>
17
-#include <assert.h>
18 9
 
19
-#include "main.h"
10
+#include "global.h"
11
+#include "Console.h"
12
+#include "Game.h"
13
+#include "Render.h"
20 14
 #include "Room.h"
21 15
 
22 16
 Room::Room(TombRaider &tr, unsigned int index) {

+ 3
- 9
src/RoomData.cpp 查看文件

@@ -5,16 +5,10 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
-#ifdef __APPLE__
9
-#include <OpenGL/gl.h>
10
-#include <OpenGL/glu.h>
11
-#else
12
-#include <GL/gl.h>
13
-#include <GL/glu.h>
14
-#endif
15
-
16
-#include "main.h"
8
+#include "global.h"
9
+#include "Render.h"
17 10
 #include "RoomData.h"
11
+#include "World.h"
18 12
 
19 13
 BoundingBox::BoundingBox() {
20 14
     a[0] = a[1] = a[2] = 0;

+ 4
- 14
src/SkeletalModel.cpp 查看文件

@@ -6,21 +6,11 @@
6 6
  * \author xythobuz
7 7
  */
8 8
 
9
-#ifdef __APPLE__
10
-#include <OpenGL/gl.h>
11
-#include <OpenGL/glu.h>
12
-#elif defined WIN32
13
-#include <gl/glew.h>
14
-#include <gl/wglew.h>
15
-#else
16
-#include <GL/gl.h>
17
-#include <GL/glu.h>
18
-#endif
19
-
20
-#include <assert.h>
21
-
22
-#include "main.h"
9
+#include "global.h"
10
+#include "Console.h"
11
+#include "Render.h"
23 12
 #include "SkeletalModel.h"
13
+#include "World.h"
24 14
 
25 15
 BoneTag::BoneTag(TombRaider &tr, unsigned int index, int j, unsigned int *l, unsigned short **frame, unsigned int *frame_offset) {
26 16
     tr2_moveable_t *moveable = tr.Moveable();

+ 1
- 0
src/Sound.cpp 查看文件

@@ -5,6 +5,7 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
+#include "global.h"
8 9
 #include "Sound.h"
9 10
 
10 11
 Sound::~Sound() {

+ 1
- 1
src/SoundAL.cpp 查看文件

@@ -18,8 +18,8 @@
18 18
 
19 19
 #include <cstdio>
20 20
 #include <cstdlib>
21
-#include <assert.h>
22 21
 
22
+#include "global.h"
23 23
 #include "math/math.h"
24 24
 #include "SoundAL.h"
25 25
 

+ 1
- 0
src/SoundNull.cpp 查看文件

@@ -5,6 +5,7 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
+#include "global.h"
8 9
 #include "SoundNull.h"
9 10
 
10 11
 SoundNull::SoundNull() {

+ 4
- 12
src/Sprite.cpp 查看文件

@@ -5,18 +5,10 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
-#ifdef __APPLE__
9
-#include <OpenGL/gl.h>
10
-#include <OpenGL/glu.h>
11
-#elif defined WIN32
12
-#include <gl/glew.h>
13
-#include <gl/wglew.h>
14
-#else
15
-#include <GL/gl.h>
16
-#include <GL/glu.h>
17
-#endif
18
-
19
-#include "main.h"
8
+#include "global.h"
9
+#include "Camera.h"
10
+#include "Game.h"
11
+#include "Render.h"
20 12
 #include "Sprite.h"
21 13
 
22 14
 SpriteSequence::SpriteSequence(TombRaider &tr, unsigned int item, unsigned int sequence) {

+ 2
- 11
src/Texture.cpp 查看文件

@@ -10,17 +10,8 @@
10 10
 #include <stdlib.h>
11 11
 #include <stdio.h>
12 12
 #include <stdarg.h>
13
-#include <assert.h>
14
-
15
-#ifdef __APPLE__
16
-#include <OpenGL/gl.h>
17
-#elif defined WIN32
18
-#include <gl/glew.h>
19
-#include <gl/wglew.h>
20
-#else
21
-#include <GL/gl.h>
22
-#endif
23 13
 
14
+#include "global.h"
24 15
 #include "utils/strings.h"
25 16
 #include "utils/tga.h"
26 17
 #include "Texture.h"
@@ -312,7 +303,7 @@ void Texture::glScreenShot(char *base, unsigned int width, unsigned int height)
312 303
     }
313 304
 
314 305
     // Capture frame buffer
315
-    glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, image);
306
+    glReadPixels(0, 0, width, height, GL_BGR_EXT, GL_UNSIGNED_BYTE, image);
316 307
 
317 308
     tgaSaveFilename(image, width, height, 0, "%s", filename);
318 309
     printf("Took screenshot '%s'.\n", filename);

+ 1
- 0
src/TombRaider.cpp 查看文件

@@ -13,6 +13,7 @@
13 13
 
14 14
 #include <zlib.h>
15 15
 
16
+#include "global.h"
16 17
 #include "TombRaider.h"
17 18
 
18 19
 #ifdef __TEST_TR5_DUMP_TGA

+ 1
- 0
src/ViewVolume.cpp 查看文件

@@ -9,6 +9,7 @@
9 9
 
10 10
 #include <math.h>
11 11
 
12
+#include "global.h"
12 13
 #include "ViewVolume.h"
13 14
 
14 15
 ViewVolume::ViewVolume() {

+ 1
- 10
src/Window.cpp 查看文件

@@ -8,17 +8,8 @@
8 8
 #include <cstdio>
9 9
 #include <cstring>
10 10
 #include <cstdarg>
11
-#include <assert.h>
12
-
13
-#ifdef __APPLE__
14
-#include <OpenGL/gl.h>
15
-#elif defined WIN32
16
-#include <gl/glew.h>
17
-#include <gl/wglew.h>
18
-#else
19
-#include <GL/gl.h>
20
-#endif
21 11
 
12
+#include "global.h"
22 13
 #include "math/math.h"
23 14
 #include "Window.h"
24 15
 

+ 3
- 4
src/WindowSDL.cpp 查看文件

@@ -6,10 +6,9 @@
6 6
  */
7 7
 
8 8
 #include <cstdio>
9
-#include <assert.h>
10 9
 
11
-#include "config.h"
12
-#include "main.h"
10
+#include "global.h"
11
+#include "OpenRaider.h"
13 12
 #include "utils/strings.h"
14 13
 #include "WindowSDL.h"
15 14
 
@@ -570,7 +569,7 @@ void WindowSDL::writeString(WindowString *s) {
570 569
         if (surface->format->Rmask == 0x000000FF)
571 570
             textureFormat = GL_RGB;
572 571
         else
573
-            textureFormat = GL_BGR;
572
+            textureFormat = GL_BGR_EXT;
574 573
     }
575 574
 
576 575
     glBindTexture(GL_TEXTURE_2D, mFontTexture);

+ 1
- 1
src/World.cpp 查看文件

@@ -7,8 +7,8 @@
7 7
 
8 8
 #include <cstdio>
9 9
 #include <math.h>
10
-#include <assert.h>
11 10
 
11
+#include "global.h"
12 12
 #include "World.h"
13 13
 
14 14
 World::~World() {

+ 31
- 4
src/main.cpp 查看文件

@@ -8,10 +8,15 @@
8 8
 #include <cstdlib>
9 9
 #include <cstdio>
10 10
 #include <cstring>
11
-#include <assert.h>
12 11
 
13
-#include "config.h"
14
-#include "main.h"
12
+#include "global.h"
13
+#include "Camera.h"
14
+#include "Console.h"
15
+#include "Game.h"
16
+#include "Menu.h"
17
+#include "OpenRaider.h"
18
+#include "Render.h"
19
+#include "World.h"
15 20
 #include "utils/time.h"
16 21
 
17 22
 #ifdef USING_AL
@@ -37,7 +42,6 @@ World gWorld;
37 42
 #ifdef USING_AL
38 43
 SoundAL gSound;
39 44
 #else
40
-#warn Sound output deactivated!
41 45
 SoundNull gSound;
42 46
 #endif
43 47
 
@@ -154,3 +158,26 @@ int main(int argc, char *argv[]) {
154 158
     return 0;
155 159
 }
156 160
 
161
+#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS) && (!defined(NDEBUG))
162
+
163
+#include <execinfo.h>
164
+
165
+void assertImplementation(const char *exp, const char *file, int line) {
166
+    const unsigned int maxSize = 128;
167
+    void *callstack[maxSize];
168
+    int frames = backtrace(callstack, maxSize);
169
+    char **strs = backtrace_symbols(callstack, frames);
170
+
171
+    printf("\nassertion failed:\n");
172
+    printf("\t%s\n", exp);
173
+    printf("in %s:%d\n\n", file, line);
174
+
175
+    for (int i = 0; i < frames; i++)
176
+        printf("%s\n", strs[i]);
177
+
178
+    delete [] strs;
179
+    abort();
180
+}
181
+
182
+#endif
183
+

+ 1
- 0
src/math/Matrix.cpp 查看文件

@@ -8,6 +8,7 @@
8 8
 #include <stdio.h>
9 9
 #include <math.h>
10 10
 
11
+#include "global.h"
11 12
 #include "math/Matrix.h"
12 13
 
13 14
 Matrix::Matrix() {

+ 1
- 0
src/math/Quaternion.cpp 查看文件

@@ -7,6 +7,7 @@
7 7
 
8 8
 #include <math.h>
9 9
 
10
+#include "global.h"
10 11
 #include "math/Quaternion.h"
11 12
 
12 13
 Quaternion::Quaternion() {

+ 1
- 0
src/math/Vector3d.cpp 查看文件

@@ -7,6 +7,7 @@
7 7
 
8 8
 #include <math.h>
9 9
 
10
+#include "global.h"
10 11
 #include "math/Vector3d.h"
11 12
 
12 13
 Vector3d::Vector3d() {

+ 3
- 2
src/math/math.cpp 查看文件

@@ -10,15 +10,16 @@
10 10
 #include <stdlib.h>
11 11
 #include <math.h>
12 12
 #include <float.h>
13
-#include <assert.h>
13
+#include <algorithm>
14 14
 
15
+#include "global.h"
15 16
 #include "math/Vector3d.h"
16 17
 #include "math/Matrix.h"
17 18
 #include "math/math.h"
18 19
 
19 20
 bool equalEpsilon(vec_t a, vec_t b) {
20 21
     vec_t epsilon = FLT_EPSILON;
21
-    if (fabs(a - b) <= (fmax(fabs(a), fabs(b)) * epsilon))
22
+    if (fabs(a - b) <= (std::max(fabs(a), fabs(b)) * epsilon))
22 23
         return true;
23 24
     return false;
24 25
 }

+ 8
- 4
src/utils/strings.cpp 查看文件

@@ -9,14 +9,18 @@
9 9
 #include <cstdlib>
10 10
 #include <stdio.h>
11 11
 #include <string.h>
12
-#include <assert.h>
13 12
 
14 13
 #if defined(unix) || defined(__APPLE__) || defined(__linux__)
15 14
 #include <wordexp.h>
16 15
 #elif defined(WIN32)
17 16
 #include <Windows.h>
17
+#include <shlobj.h>
18
+#ifndef va_copy
19
+#define va_copy(d,s) ((d) = (s))
20
+#endif
18 21
 #endif
19 22
 
23
+#include "global.h"
20 24
 #include "utils/strings.h"
21 25
 
22 26
 char *stringRemoveQuotes(const char *s) {
@@ -169,11 +173,11 @@ char *fullPath(const char *path, char end) {
169 173
         wordfree(&word);
170 174
 #elif defined(WIN32)
171 175
         WCHAR newPath[MAX_PATH];
172
-        if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, newPath)) {
173
-            lenPath = strlen(newPath);
176
+        if (SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, newPath) == S_OK) {
177
+            lenPath = strlen((const char *)newPath);
174 178
             unsigned int lenPath2 = strlen(path);
175 179
             dir = new char[lenPath + lenPath2 + 2]; // space for end char
176
-            strncpy(dir, newPath, lenPath);
180
+            strncpy(dir, (const char *)newPath, lenPath);
177 181
             dir[lenPath] = '\\';
178 182
             strncpy((dir + lenPath + 1), (path + 1), lenPath2 - 1);
179 183
             lenPath += lenPath2;

+ 1
- 1
src/utils/tga.cpp 查看文件

@@ -11,8 +11,8 @@
11 11
 #include <stdio.h>
12 12
 #include <string.h>
13 13
 #include <stdarg.h>
14
-#include <assert.h>
15 14
 
15
+#include "global.h"
16 16
 #include "utils/tga.h"
17 17
 
18 18
 int tgaCheck(FILE *f) {

+ 2
- 4
src/utils/time.cpp 查看文件

@@ -5,6 +5,7 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
+#include "global.h"
8 9
 #include "utils/time.h"
9 10
 
10 11
 #if defined(unix) || defined(__APPLE__) || defined (__linux__)
@@ -40,11 +41,8 @@ void systemTimerReset() {
40 41
 }
41 42
 
42 43
 #else
43
-#warn "No support for timer on this platform!"
44 44
 
45
-unsigned long systemTimerGet() { return 0; }
46
-
47
-void systemTimerReset() { }
45
+#error "No support for timer on this platform!"
48 46
 
49 47
 #endif
50 48
 

正在加载...
取消
保存