Ver código fonte

New assert implementation, meta improvements

Thomas Buck 11 anos atrás
pai
commit
b8ee254b56

+ 7
- 0
ChangeLog.md Ver arquivo

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
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
     [ 20140516 ]
12
     [ 20140516 ]
6
     * Finished moving the Entity/SkeletalModel logic into classes
13
     * Finished moving the Entity/SkeletalModel logic into classes
7
     * Currently seems as if wrong SkeletalModels are used for entities?
14
     * Currently seems as if wrong SkeletalModels are used for entities?

+ 2
- 0
include/Camera.h Ver arquivo

99
     vec_t mRotationDeltaY;
99
     vec_t mRotationDeltaY;
100
 };
100
 };
101
 
101
 
102
+Camera &getCamera();
103
+
102
 #endif
104
 #endif

+ 2
- 0
include/Console.h Ver arquivo

60
     unsigned int mLineOffset;
60
     unsigned int mLineOffset;
61
 };
61
 };
62
 
62
 
63
+Console &getConsole();
64
+
63
 #endif
65
 #endif

+ 2
- 1
include/Game.h Ver arquivo

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

+ 6
- 0
include/Menu.h Ver arquivo

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

+ 2
- 1
include/OpenRaider.h Ver arquivo

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

+ 6
- 7
include/Render.h Ver arquivo

11
 
11
 
12
 #include <vector>
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
 #include "Texture.h"
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
  * \brief OpenRaider Renderer class
21
  * \brief OpenRaider Renderer class
213
     bool mSkyMeshRotation;                //!< Should Skymesh be rotated?
210
     bool mSkyMeshRotation;                //!< Should Skymesh be rotated?
214
 };
211
 };
215
 
212
 
213
+Render &getRender();
214
+
216
 #endif
215
 #endif

+ 2
- 2
include/Sound.h Ver arquivo

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

+ 2
- 7
include/TombRaiderData.h Ver arquivo

10
 
10
 
11
 #include <cstdint>
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
 #pragma pack(push, tr2_h, 1)
14
 #pragma pack(push, tr2_h, 1)
20
 #endif
15
 #endif
21
 
16
 
1135
     unsigned int unknown[24];
1130
     unsigned int unknown[24];
1136
 } tr5_cinematic_frame_t;
1131
 } tr5_cinematic_frame_t;
1137
 
1132
 
1138
-#ifdef WIN32
1133
+#ifdef _MSC_VER
1139
 #pragma pack(pop, tr2_h, 1)
1134
 #pragma pack(pop, tr2_h, 1)
1140
 #endif
1135
 #endif
1141
 
1136
 

+ 2
- 6
include/Window.h Ver arquivo

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

+ 1
- 12
include/WindowSDL.h Ver arquivo

11
 #include "SDL.h"
11
 #include "SDL.h"
12
 #include "SDL_ttf.h"
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
 #include "Window.h"
14
 #include "Window.h"
26
 
15
 
27
 /*!
16
 /*!
73
     SDL_GLContext mGLContext; //!< The OpenGL Context
62
     SDL_GLContext mGLContext; //!< The OpenGL Context
74
 
63
 
75
     TTF_Font *mFont;
64
     TTF_Font *mFont;
76
-    GLuint mFontTexture;
65
+    unsigned int mFontTexture;
77
 
66
 
78
     bool mTextInput;
67
     bool mTextInput;
79
 
68
 

+ 2
- 0
include/World.h Ver arquivo

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

+ 18
- 0
include/config.h.in Ver arquivo

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
 #define VERSION "OpenRaider-@OpenRaider_VERSION_MAJOR@.@OpenRaider_VERSION_MINOR@.@OpenRaider_VERSION_MICRO@@OpenRaider_VERSION_RELEASE@ (@CMAKE_BUILD_TYPE@)"
11
 #define VERSION "OpenRaider-@OpenRaider_VERSION_MAJOR@.@OpenRaider_VERSION_MINOR@.@OpenRaider_VERSION_MICRO@@OpenRaider_VERSION_RELEASE@ (@CMAKE_BUILD_TYPE@)"
2
 #define BUILD_HOST "@OpenRaider_BUILD_HOST@ @OpenRaider_HOSTNAME@"
12
 #define BUILD_HOST "@OpenRaider_BUILD_HOST@ @OpenRaider_HOSTNAME@"
3
 
13
 
5
 #define DEFAULT_CONFIG_FILE "OpenRaider.ini"
15
 #define DEFAULT_CONFIG_FILE "OpenRaider.ini"
6
 #define DEFAULT_WIDTH 640
16
 #define DEFAULT_WIDTH 640
7
 #define DEFAULT_HEIGHT 480
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 Ver arquivo

7
 #ifndef _GLOBAL_H_
7
 #ifndef _GLOBAL_H_
8
 #define _GLOBAL_H_
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
 const float BLACK[]       = {  0.0f,  0.0f,  0.0f, 1.0f };
38
 const float BLACK[]       = {  0.0f,  0.0f,  0.0f, 1.0f };
11
 const float DIM_WHITE[]   = {  0.5f,  0.5f,  0.5f, 1.0f };
39
 const float DIM_WHITE[]   = {  0.5f,  0.5f,  0.5f, 1.0f };
12
 const float WHITE[]       = {  1.0f,  1.0f,  1.0f, 1.0f };
40
 const float WHITE[]       = {  1.0f,  1.0f,  1.0f, 1.0f };

+ 0
- 47
include/main.h Ver arquivo

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 Ver arquivo

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

+ 0
- 4
include/utils/tga.h Ver arquivo

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

+ 13
- 1
src/CMakeLists.txt Ver arquivo

64
 option (ENABLE_AUDIO "Enable Sound Output" YES)
64
 option (ENABLE_AUDIO "Enable Sound Output" YES)
65
 if (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
65
 if (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
66
     set (SRCS ${SRCS} "SoundAL.cpp")
66
     set (SRCS ${SRCS} "SoundAL.cpp")
67
-    set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -DUSING_AL")
67
+    set (USING_AL TRUE)
68
 else (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
68
 else (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
69
     set (SRCS ${SRCS} "SoundNull.cpp")
69
     set (SRCS ${SRCS} "SoundNull.cpp")
70
+    set (USING_AL FALSE)
70
     message (STATUS "Disabled Sound support (no OpenAL and ALUT)!")
71
     message (STATUS "Disabled Sound support (no OpenAL and ALUT)!")
71
 endif (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
72
 endif (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
72
 
73
 
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
 # Configuration Header file
96
 # Configuration Header file
85
 configure_file (
97
 configure_file (
86
     "${PROJECT_SOURCE_DIR}/include/config.h.in"
98
     "${PROJECT_SOURCE_DIR}/include/config.h.in"

+ 1
- 0
src/Camera.cpp Ver arquivo

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

+ 1
- 3
src/Command.cpp Ver arquivo

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

+ 1
- 11
src/Console.cpp Ver arquivo

5
  * \author xythobuz
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
 #include "global.h"
8
 #include "global.h"
19
 #include "Console.h"
9
 #include "Console.h"
20
-#include "main.h"
10
+#include "OpenRaider.h"
21
 #include "utils/strings.h"
11
 #include "utils/strings.h"
22
 #include "utils/time.h"
12
 #include "utils/time.h"
23
 
13
 

+ 3
- 12
src/Entity.cpp Ver arquivo

5
  * \author xythobuz
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
 #include "Entity.h"
10
 #include "Entity.h"
20
-#include "main.h"
21
 #include "Render.h"
11
 #include "Render.h"
12
+#include "World.h"
22
 
13
 
23
 #include "games/TombRaider1.h"
14
 #include "games/TombRaider1.h"
24
 
15
 

+ 3
- 11
src/Game.cpp Ver arquivo

5
  * \author xythobuz
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 <algorithm>
8
 #include <algorithm>
18
 #include <map>
9
 #include <map>
19
 #include <cstdlib>
10
 #include <cstdlib>
20
-#include <assert.h>
21
 
11
 
22
-#include "main.h"
12
+#include "global.h"
23
 #include "Console.h"
13
 #include "Console.h"
24
 #include "Game.h"
14
 #include "Game.h"
15
+#include "OpenRaider.h"
16
+#include "Sound.h"
25
 #include "utils/strings.h"
17
 #include "utils/strings.h"
26
 
18
 
27
 #include "games/TombRaider1.h"
19
 #include "games/TombRaider1.h"

+ 6
- 18
src/Menu.cpp Ver arquivo

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

+ 1
- 10
src/Mesh.cpp Ver arquivo

6
  */
6
  */
7
 
7
 
8
 #include <stdlib.h>
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
 #include "Mesh.h"
11
 #include "Mesh.h"
21
 
12
 
22
 
13
 

+ 2
- 4
src/OpenRaider.cpp Ver arquivo

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

+ 0
- 10
src/Render.cpp Ver arquivo

8
 
8
 
9
 #include <algorithm>
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
 #include <stdlib.h>
11
 #include <stdlib.h>
21
 #include <math.h>
12
 #include <math.h>
22
 #include <string.h>
13
 #include <string.h>
23
 
14
 
24
 #include "global.h"
15
 #include "global.h"
25
-#include "main.h"
26
 #include "Game.h"
16
 #include "Game.h"
27
 #include "OpenRaider.h"
17
 #include "OpenRaider.h"
28
 #include "Render.h"
18
 #include "Render.h"

+ 4
- 10
src/Room.cpp Ver arquivo

5
  * \author xythobuz
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 <algorithm>
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
 #include "Room.h"
14
 #include "Room.h"
21
 
15
 
22
 Room::Room(TombRaider &tr, unsigned int index) {
16
 Room::Room(TombRaider &tr, unsigned int index) {

+ 3
- 9
src/RoomData.cpp Ver arquivo

5
  * \author xythobuz
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
 #include "RoomData.h"
10
 #include "RoomData.h"
11
+#include "World.h"
18
 
12
 
19
 BoundingBox::BoundingBox() {
13
 BoundingBox::BoundingBox() {
20
     a[0] = a[1] = a[2] = 0;
14
     a[0] = a[1] = a[2] = 0;

+ 4
- 14
src/SkeletalModel.cpp Ver arquivo

6
  * \author xythobuz
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
 #include "SkeletalModel.h"
12
 #include "SkeletalModel.h"
13
+#include "World.h"
24
 
14
 
25
 BoneTag::BoneTag(TombRaider &tr, unsigned int index, int j, unsigned int *l, unsigned short **frame, unsigned int *frame_offset) {
15
 BoneTag::BoneTag(TombRaider &tr, unsigned int index, int j, unsigned int *l, unsigned short **frame, unsigned int *frame_offset) {
26
     tr2_moveable_t *moveable = tr.Moveable();
16
     tr2_moveable_t *moveable = tr.Moveable();

+ 1
- 0
src/Sound.cpp Ver arquivo

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

+ 1
- 1
src/SoundAL.cpp Ver arquivo

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

+ 1
- 0
src/SoundNull.cpp Ver arquivo

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

+ 4
- 12
src/Sprite.cpp Ver arquivo

5
  * \author xythobuz
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
 #include "Sprite.h"
12
 #include "Sprite.h"
21
 
13
 
22
 SpriteSequence::SpriteSequence(TombRaider &tr, unsigned int item, unsigned int sequence) {
14
 SpriteSequence::SpriteSequence(TombRaider &tr, unsigned int item, unsigned int sequence) {

+ 2
- 11
src/Texture.cpp Ver arquivo

10
 #include <stdlib.h>
10
 #include <stdlib.h>
11
 #include <stdio.h>
11
 #include <stdio.h>
12
 #include <stdarg.h>
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
 #include "utils/strings.h"
15
 #include "utils/strings.h"
25
 #include "utils/tga.h"
16
 #include "utils/tga.h"
26
 #include "Texture.h"
17
 #include "Texture.h"
312
     }
303
     }
313
 
304
 
314
     // Capture frame buffer
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
     tgaSaveFilename(image, width, height, 0, "%s", filename);
308
     tgaSaveFilename(image, width, height, 0, "%s", filename);
318
     printf("Took screenshot '%s'.\n", filename);
309
     printf("Took screenshot '%s'.\n", filename);

+ 1
- 0
src/TombRaider.cpp Ver arquivo

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

+ 1
- 0
src/ViewVolume.cpp Ver arquivo

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

+ 1
- 10
src/Window.cpp Ver arquivo

8
 #include <cstdio>
8
 #include <cstdio>
9
 #include <cstring>
9
 #include <cstring>
10
 #include <cstdarg>
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
 #include "math/math.h"
13
 #include "math/math.h"
23
 #include "Window.h"
14
 #include "Window.h"
24
 
15
 

+ 3
- 4
src/WindowSDL.cpp Ver arquivo

6
  */
6
  */
7
 
7
 
8
 #include <cstdio>
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
 #include "utils/strings.h"
12
 #include "utils/strings.h"
14
 #include "WindowSDL.h"
13
 #include "WindowSDL.h"
15
 
14
 
570
         if (surface->format->Rmask == 0x000000FF)
569
         if (surface->format->Rmask == 0x000000FF)
571
             textureFormat = GL_RGB;
570
             textureFormat = GL_RGB;
572
         else
571
         else
573
-            textureFormat = GL_BGR;
572
+            textureFormat = GL_BGR_EXT;
574
     }
573
     }
575
 
574
 
576
     glBindTexture(GL_TEXTURE_2D, mFontTexture);
575
     glBindTexture(GL_TEXTURE_2D, mFontTexture);

+ 1
- 1
src/World.cpp Ver arquivo

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

+ 31
- 4
src/main.cpp Ver arquivo

8
 #include <cstdlib>
8
 #include <cstdlib>
9
 #include <cstdio>
9
 #include <cstdio>
10
 #include <cstring>
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
 #include "utils/time.h"
20
 #include "utils/time.h"
16
 
21
 
17
 #ifdef USING_AL
22
 #ifdef USING_AL
37
 #ifdef USING_AL
42
 #ifdef USING_AL
38
 SoundAL gSound;
43
 SoundAL gSound;
39
 #else
44
 #else
40
-#warn Sound output deactivated!
41
 SoundNull gSound;
45
 SoundNull gSound;
42
 #endif
46
 #endif
43
 
47
 
154
     return 0;
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 Ver arquivo

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

+ 1
- 0
src/math/Quaternion.cpp Ver arquivo

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

+ 1
- 0
src/math/Vector3d.cpp Ver arquivo

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

+ 3
- 2
src/math/math.cpp Ver arquivo

10
 #include <stdlib.h>
10
 #include <stdlib.h>
11
 #include <math.h>
11
 #include <math.h>
12
 #include <float.h>
12
 #include <float.h>
13
-#include <assert.h>
13
+#include <algorithm>
14
 
14
 
15
+#include "global.h"
15
 #include "math/Vector3d.h"
16
 #include "math/Vector3d.h"
16
 #include "math/Matrix.h"
17
 #include "math/Matrix.h"
17
 #include "math/math.h"
18
 #include "math/math.h"
18
 
19
 
19
 bool equalEpsilon(vec_t a, vec_t b) {
20
 bool equalEpsilon(vec_t a, vec_t b) {
20
     vec_t epsilon = FLT_EPSILON;
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
         return true;
23
         return true;
23
     return false;
24
     return false;
24
 }
25
 }

+ 8
- 4
src/utils/strings.cpp Ver arquivo

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

+ 1
- 1
src/utils/tga.cpp Ver arquivo

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

+ 2
- 4
src/utils/time.cpp Ver arquivo

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
+#include "global.h"
8
 #include "utils/time.h"
9
 #include "utils/time.h"
9
 
10
 
10
 #if defined(unix) || defined(__APPLE__) || defined (__linux__)
11
 #if defined(unix) || defined(__APPLE__) || defined (__linux__)
40
 }
41
 }
41
 
42
 
42
 #else
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
 #endif
47
 #endif
50
 
48
 

Carregando…
Cancelar
Salvar