Browse Source

Debug info now displayed as imgui overlay

Thomas Buck 10 years ago
parent
commit
29ca435f21

+ 4
- 0
ChangeLog.md View File

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4
 
4
 
5
+    [ 20140108 ]
6
+    * FPS and Camera position now displayed in imgui Overlay
7
+    * Removed many unnecessary includes
8
+
5
     [ 20140107 ]
9
     [ 20140107 ]
6
     * Fixed problems with FontTTFs Glyph Baseline
10
     * Fixed problems with FontTTFs Glyph Baseline
7
     * No longer using wrong assert() when glm is included
11
     * No longer using wrong assert() when glm is included

+ 2
- 16
include/Game.h View File

16
 class Game {
16
 class Game {
17
   public:
17
   public:
18
     Game();
18
     Game();
19
-    ~Game();
20
 
19
 
21
     int initialize();
20
     int initialize();
21
+    void destroy();
22
 
22
 
23
-    bool isLoaded();
24
-
23
+    bool isLoaded() { return mLoaded; }
25
     int loadLevel(const char* level);
24
     int loadLevel(const char* level);
26
 
25
 
27
-    void destroy();
28
-
29
     void display();
26
     void display();
30
     void handleAction(ActionEvents action, bool isFinished);
27
     void handleAction(ActionEvents action, bool isFinished);
31
     void handleMouseMotion(int xrel, int yrel, int xabs, int yabs);
28
     void handleMouseMotion(int xrel, int yrel, int xabs, int yabs);
36
     void setLara(long lara);
33
     void setLara(long lara);
37
 
34
 
38
   private:
35
   private:
39
-    void processPakSounds();
40
-    void processTextures();
41
-    void processSprites();
42
-    void processMoveables();
43
-    void processMoveable(int index, int i, int object_id);
44
-    void processModels();
45
-    void processRooms();
46
-
47
-    std::string levelName;
48
     bool mLoaded;
36
     bool mLoaded;
49
-
50
     long mLara;
37
     long mLara;
51
-
52
     bool activeEvents[ActionEventCount];
38
     bool activeEvents[ActionEventCount];
53
 };
39
 };
54
 
40
 

+ 1
- 2
include/Log.h View File

8
 #ifndef _LOG_H_
8
 #ifndef _LOG_H_
9
 #define _LOG_H_
9
 #define _LOG_H_
10
 
10
 
11
+#include <iostream>
11
 #include <string>
12
 #include <string>
12
 #include <sstream>
13
 #include <sstream>
13
 #include <vector>
14
 #include <vector>
29
         printBuffer << t;
30
         printBuffer << t;
30
         if (printBuffer.str().back() == endl) {
31
         if (printBuffer.str().back() == endl) {
31
             mHistory.push_back(printBuffer.str().substr(0, printBuffer.str().length() - 1));
32
             mHistory.push_back(printBuffer.str().substr(0, printBuffer.str().length() - 1));
32
-#ifdef DEBUG
33
             std::cout << printBuffer.str().substr(0, printBuffer.str().length() - 1) << std::endl;
33
             std::cout << printBuffer.str().substr(0, printBuffer.str().length() - 1) << std::endl;
34
-#endif
35
             printBuffer.str("");
34
             printBuffer.str("");
36
         }
35
         }
37
         return (*this);
36
         return (*this);

+ 5
- 4
include/Render.h View File

25
 
25
 
26
 class Render {
26
 class Render {
27
   public:
27
   public:
28
-    static RenderMode getMode();
29
-    static void setMode(RenderMode m);
28
+
29
+    static void clearRoomList() { roomList.clear(); }
30
 
30
 
31
     static void display();
31
     static void display();
32
     static void displayUI();
32
     static void displayUI();
33
 
33
 
34
-    static void clearRoomList();
35
-
36
     static void screenShot(const char* filenameBase);
34
     static void screenShot(const char* filenameBase);
37
 
35
 
38
     static void drawTexture(float x, float y, float w, float h, glm::vec4 color,
36
     static void drawTexture(float x, float y, float w, float h, glm::vec4 color,
39
                             unsigned int texture, TextureStorage s);
37
                             unsigned int texture, TextureStorage s);
40
 
38
 
39
+    static RenderMode getMode() { return mode; }
40
+    static void setMode(RenderMode m) { mode = m; }
41
+
41
     static void setDisplayViewFrustum(bool d) { displayViewFrustum = d; }
42
     static void setDisplayViewFrustum(bool d) { displayViewFrustum = d; }
42
     static bool getDisplayViewFrustum() { return displayViewFrustum; }
43
     static bool getDisplayViewFrustum() { return displayViewFrustum; }
43
 
44
 

+ 7
- 26
include/global.h View File

106
 
106
 
107
 template<typename T, typename U>
107
 template<typename T, typename U>
108
 [[noreturn]] void assertEqualImplementation(const char* exp, T a, U b, const char* file, int line,
108
 [[noreturn]] void assertEqualImplementation(const char* exp, T a, U b, const char* file, int line,
109
-        bool print) {
109
+                                            bool print = false, const char* str = nullptr) {
110
     const unsigned int maxSize = 128;
110
     const unsigned int maxSize = 128;
111
     void* callstack[maxSize];
111
     void* callstack[maxSize];
112
     int frames = backtrace(callstack, maxSize);
112
     int frames = backtrace(callstack, maxSize);
115
     std::cout << std::endl << "assertion failed:" << std::endl;
115
     std::cout << std::endl << "assertion failed:" << std::endl;
116
     std::cout << "\t" << exp << std::endl;
116
     std::cout << "\t" << exp << std::endl;
117
     if (print)
117
     if (print)
118
-        std::cout << "\t (" << a << " != " << b << ")" << std::endl;
119
-    std::cout << "in " << file << ":" << line << std::endl << std::endl;
120
-
121
-    for (int i = 0; i < frames; i++)
122
-        std::cout << strs[i] << std::endl;
123
-
124
-    delete [] strs;
125
-    abort();
126
-}
127
-
128
-template<typename T, typename U>
129
-[[noreturn]] void assertNotEqualImplementation(const char* exp, T a, U b, const char* file,
130
-        int line, bool print) {
131
-    const unsigned int maxSize = 128;
132
-    void* callstack[maxSize];
133
-    int frames = backtrace(callstack, maxSize);
134
-    char** strs = backtrace_symbols(callstack, frames);
135
-
136
-    std::cout << std::endl << "assertion failed:" << std::endl;
137
-    std::cout << "\t" << exp << std::endl;
138
-    if (print)
139
-        std::cout << "\t (" << a << " == " << b << ")" << std::endl;
118
+        std::cout << "\t (" << a << " " << str << " " << b << ")" << std::endl;
140
     std::cout << "in " << file << ":" << line << std::endl << std::endl;
119
     std::cout << "in " << file << ":" << line << std::endl << std::endl;
141
 
120
 
142
     for (int i = 0; i < frames; i++)
121
     for (int i = 0; i < frames; i++)
152
 #define assert(x) { \
131
 #define assert(x) { \
153
     auto assertEvalTemp = x; \
132
     auto assertEvalTemp = x; \
154
     if (!assertEvalTemp) \
133
     if (!assertEvalTemp) \
155
-        assertEqualImplementation(#x, assertEvalTemp, true, __FILE__, __LINE__, false); \
134
+        assertEqualImplementation(#x, assertEvalTemp, true, __FILE__, __LINE__); \
156
 }
135
 }
157
 
136
 
158
 #define assertEqual(x, y) { \
137
 #define assertEqual(x, y) { \
159
     auto assertEvalTemp = x; \
138
     auto assertEvalTemp = x; \
160
     auto assertEvalTemp2 = y; \
139
     auto assertEvalTemp2 = y; \
161
     if (assertEvalTemp != assertEvalTemp2) \
140
     if (assertEvalTemp != assertEvalTemp2) \
162
-        assertEqualImplementation(#x " == " #y, assertEvalTemp, assertEvalTemp2, __FILE__, __LINE__, true); \
141
+        assertEqualImplementation(#x " == " #y, assertEvalTemp, assertEvalTemp2, \
142
+                                  __FILE__, __LINE__, true, "!="); \
163
 }
143
 }
164
 
144
 
165
 #define assertNotEqual(x, y) { \
145
 #define assertNotEqual(x, y) { \
166
     auto assertEvalTemp = x; \
146
     auto assertEvalTemp = x; \
167
     auto assertEvalTemp2 = y; \
147
     auto assertEvalTemp2 = y; \
168
     if (assertEvalTemp == assertEvalTemp2) \
148
     if (assertEvalTemp == assertEvalTemp2) \
169
-        assertNotEqualImplementation(#x " != " #y, assertEvalTemp, assertEvalTemp2, __FILE__, __LINE__, true); \
149
+        assertEqualImplementation(#x " != " #y, assertEvalTemp, assertEvalTemp2, \
150
+                                  __FILE__, __LINE__, true, "=="); \
170
 }
151
 }
171
 
152
 
172
 #else // NODEBUG
153
 #else // NODEBUG

+ 0
- 1
src/Console.cpp View File

11
 
11
 
12
 #include "global.h"
12
 #include "global.h"
13
 #include "Log.h"
13
 #include "Log.h"
14
-#include "UI.h"
15
 #include "commands/Command.h"
14
 #include "commands/Command.h"
16
 #include "Console.h"
15
 #include "Console.h"
17
 
16
 

+ 1
- 39
src/Game.cpp View File

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
-#include <algorithm>
9
-#include <map>
10
-#include <sstream>
11
-#include <cstdlib>
12
-#include <cstring>
13
-
14
 #include "global.h"
8
 #include "global.h"
15
 #include "Camera.h"
9
 #include "Camera.h"
16
 #include "Game.h"
10
 #include "Game.h"
17
 #include "loader/Loader.h"
11
 #include "loader/Loader.h"
18
 #include "Log.h"
12
 #include "Log.h"
19
 #include "Render.h"
13
 #include "Render.h"
20
-#include "RunTime.h"
21
 #include "SoundManager.h"
14
 #include "SoundManager.h"
22
-#include "StaticMesh.h"
23
-#include "system/Font.h"
24
-#include "system/Sound.h"
25
-#include "system/Window.h"
26
 #include "TextureManager.h"
15
 #include "TextureManager.h"
27
 #include "UI.h"
16
 #include "UI.h"
28
 #include "World.h"
17
 #include "World.h"
29
-#include "utils/strings.h"
30
 
18
 
31
 Game::Game() {
19
 Game::Game() {
32
     mLoaded = false;
20
     mLoaded = false;
37
     }
25
     }
38
 }
26
 }
39
 
27
 
40
-Game::~Game() {
41
-}
42
-
43
 int Game::initialize() {
28
 int Game::initialize() {
44
     // Enable Renderer
29
     // Enable Renderer
45
     Render::setMode(RenderMode::LoadScreen);
30
     Render::setMode(RenderMode::LoadScreen);
49
 
34
 
50
 void Game::display() {
35
 void Game::display() {
51
     Render::display();
36
     Render::display();
52
-
53
-    if (RunTime::getShowFPS()) {
54
-        std::ostringstream s;
55
-        s << RunTime::getFPS() << "FPS";
56
-        Font::drawText(10, Window::getSize().y - 25, 0.6f, BLUE, s.str());
57
-
58
-        s.str("");
59
-        s << "X: " << Camera::getPosition().x << " (" << Camera::getRotation().x << ")";
60
-        Font::drawText(10, Window::getSize().y - 70, 0.6f, BLUE, s.str());
61
-
62
-        s.str("");
63
-        s << "Y: " << Camera::getPosition().y << " (" << Camera::getRotation().y << ")";
64
-        Font::drawText(10, Window::getSize().y - 55, 0.6f, BLUE, s.str());
65
-
66
-        s.str("");
67
-        s << "Z: " << Camera::getPosition().z;
68
-        Font::drawText(10, Window::getSize().y - 40, 0.6f, BLUE, s.str());
69
-    }
70
 }
37
 }
71
 
38
 
72
 void Game::destroy() {
39
 void Game::destroy() {
81
     getWorld().destroy();
48
     getWorld().destroy();
82
 }
49
 }
83
 
50
 
84
-bool Game::isLoaded() {
85
-    return mLoaded;
86
-}
87
-
88
 int Game::loadLevel(const char* level) {
51
 int Game::loadLevel(const char* level) {
89
     destroy();
52
     destroy();
90
-    levelName = level;
91
-    getLog() << "Loading " << levelName << Log::endl;
53
+    getLog() << "Loading " << level << Log::endl;
92
     auto loader = Loader::createLoader(level);
54
     auto loader = Loader::createLoader(level);
93
     if (loader) {
55
     if (loader) {
94
         int error = loader->load(level);
56
         int error = loader->load(level);

+ 0
- 1
src/Menu.cpp View File

8
 #include "global.h"
8
 #include "global.h"
9
 #include "Log.h"
9
 #include "Log.h"
10
 #include "Menu.h"
10
 #include "Menu.h"
11
-#include "MenuFolder.h"
12
 #include "system/Font.h"
11
 #include "system/Font.h"
13
 #include "system/Window.h"
12
 #include "system/Window.h"
14
 
13
 

+ 0
- 1
src/Mesh.cpp View File

7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
 #include "TextureManager.h"
9
 #include "TextureManager.h"
10
-#include "system/Shader.h"
11
 #include "Mesh.h"
10
 #include "Mesh.h"
12
 
11
 
13
 Mesh::Mesh(const std::vector<glm::vec3>& vert,
12
 Mesh::Mesh(const std::vector<glm::vec3>& vert,

+ 0
- 27
src/Render.cpp View File

6
  * \author xythobuz
6
  * \author xythobuz
7
  */
7
  */
8
 
8
 
9
-#include <algorithm>
10
 #include <sstream>
9
 #include <sstream>
11
 
10
 
12
 #include "global.h"
11
 #include "global.h"
13
 #include "Camera.h"
12
 #include "Camera.h"
14
-#include "Game.h"
15
 #include "Log.h"
13
 #include "Log.h"
16
-#include "UI.h"
17
 #include "World.h"
14
 #include "World.h"
18
 #include "system/Shader.h"
15
 #include "system/Shader.h"
19
 #include "system/Window.h"
16
 #include "system/Window.h"
20
-#include "utils/strings.h"
21
 #include "Render.h"
17
 #include "Render.h"
22
 
18
 
23
 #include <glm/gtc/matrix_transform.hpp>
19
 #include <glm/gtc/matrix_transform.hpp>
29
 std::vector<Room*> Render::roomList;
25
 std::vector<Room*> Render::roomList;
30
 bool Render::displayViewFrustum = false;
26
 bool Render::displayViewFrustum = false;
31
 
27
 
32
-RenderMode Render::getMode() {
33
-    return mode;
34
-}
35
-
36
-void Render::setMode(RenderMode m) {
37
-    mode = m;
38
-    switch (mode) {
39
-        case RenderMode::Solid:
40
-        case RenderMode::Wireframe:
41
-            //glClearColor(PURPLE[0] / 256.0f, PURPLE[1] / 256.0f,
42
-            //             PURPLE[2] / 256.0f, PURPLE[3] / 256.0f);
43
-            break;
44
-        default:
45
-            //glClearColor(BLACK[0] / 256.0f, BLACK[1] / 256.0f,
46
-            //             BLACK[2] / 256.0f, BLACK[3] / 256.0f);
47
-            break;
48
-    }
49
-}
50
-
51
 void Render::display() {
28
 void Render::display() {
52
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
29
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
53
 
30
 
85
     }
62
     }
86
 }
63
 }
87
 
64
 
88
-void Render::clearRoomList() {
89
-    roomList.clear();
90
-}
91
-
92
 void Render::buildRoomList(int room) {
65
 void Render::buildRoomList(int room) {
93
     if (room < -1) {
66
     if (room < -1) {
94
         // Check if the camera currently is in a room...
67
         // Check if the camera currently is in a room...

+ 0
- 4
src/Room.cpp View File

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
-#include <algorithm>
9
-
10
 #include "global.h"
8
 #include "global.h"
11
-#include "Game.h"
12
 #include "Log.h"
9
 #include "Log.h"
13
 #include "Render.h"
10
 #include "Render.h"
14
 #include "Room.h"
11
 #include "Room.h"
15
-#include "TextureManager.h"
16
 
12
 
17
 #include <glm/gtc/matrix_transform.hpp>
13
 #include <glm/gtc/matrix_transform.hpp>
18
 #include <glm/gtx/intersect.hpp>
14
 #include <glm/gtx/intersect.hpp>

+ 0
- 1
src/RoomData.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
-#include "SkeletalModel.h"
10
 #include "World.h"
9
 #include "World.h"
11
 #include "system/Shader.h"
10
 #include "system/Shader.h"
12
 #include "RoomData.h"
11
 #include "RoomData.h"

+ 0
- 2
src/RunTime.cpp View File

8
 #include "imgui/imgui.h"
8
 #include "imgui/imgui.h"
9
 
9
 
10
 #include "global.h"
10
 #include "global.h"
11
-#include "Camera.h"
12
-#include "UI.h"
13
 #include "system/Sound.h"
11
 #include "system/Sound.h"
14
 #include "system/Window.h"
12
 #include "system/Window.h"
15
 #include "utils/strings.h"
13
 #include "utils/strings.h"

+ 0
- 1
src/SoundManager.cpp View File

8
 #include "imgui/imgui.h"
8
 #include "imgui/imgui.h"
9
 
9
 
10
 #include "global.h"
10
 #include "global.h"
11
-#include "UI.h"
12
 #include "system/Sound.h"
11
 #include "system/Sound.h"
13
 #include "SoundManager.h"
12
 #include "SoundManager.h"
14
 
13
 

+ 0
- 1
src/Sprite.cpp View File

7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
 #include "Camera.h"
9
 #include "Camera.h"
10
-#include "Game.h"
11
 #include "Render.h"
10
 #include "Render.h"
12
 #include "TextureManager.h"
11
 #include "TextureManager.h"
13
 #include "Sprite.h"
12
 #include "Sprite.h"

+ 0
- 5
src/TextureManager.cpp View File

6
  * \author xythobuz
6
  * \author xythobuz
7
  */
7
  */
8
 
8
 
9
-#include <string.h>
10
-#include <stdlib.h>
11
-#include <stdio.h>
12
-#include <stdarg.h>
13
-
14
 #include "stb/stb_image.h"
9
 #include "stb/stb_image.h"
15
 
10
 
16
 #include "global.h"
11
 #include "global.h"

+ 17
- 3
src/UI.cpp View File

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
-#include <algorithm>
9
-#include <cstring>
10
-
11
 #include "imgui/imgui.h"
8
 #include "imgui/imgui.h"
12
 #include "stb/stb_image.h"
9
 #include "stb/stb_image.h"
13
 
10
 
202
 }
199
 }
203
 
200
 
204
 void UI::display() {
201
 void UI::display() {
202
+    if (RunTime::getShowFPS()) {
203
+        if (ImGui::Begin("Debug Overlay", nullptr, ImVec2(0,0), 0.3f,
204
+                         ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize
205
+                         | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings
206
+                         | ImGuiWindowFlags_AlwaysAutoResize)) {
207
+            ImGui::Text("%d FPS", RunTime::getFPS());
208
+            ImGui::Text("X: %.1f (%.2f)", Camera::getPosition().x, Camera::getRotation().x);
209
+            ImGui::Text("Y: %.2f (%.2f)", Camera::getPosition().y, Camera::getRotation().y);
210
+            ImGui::Text("Z: %.2f", Camera::getPosition().z);
211
+
212
+            auto window = ImGui::GetWindowSize();
213
+            auto screen = Window::getSize();
214
+            ImGui::SetWindowPos(ImVec2(10, screen.y - window.y - 10));
215
+        }
216
+        ImGui::End();
217
+    }
218
+
205
     Console::display();
219
     Console::display();
206
 
220
 
207
     if (!visible) {
221
     if (!visible) {

+ 0
- 3
src/World.cpp View File

5
  * \author Mongoose
5
  * \author Mongoose
6
  */
6
  */
7
 
7
 
8
-#include <cstdio>
9
-#include <math.h>
10
-
11
 #include "global.h"
8
 #include "global.h"
12
 #include "World.h"
9
 #include "World.h"
13
 
10
 

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

8
 #include "global.h"
8
 #include "global.h"
9
 #include "Log.h"
9
 #include "Log.h"
10
 #include "utils/strings.h"
10
 #include "utils/strings.h"
11
-#include "system/Window.h"
12
 #include "system/FontImGui.h"
11
 #include "system/FontImGui.h"
13
 #include "system/FontTRLE.h"
12
 #include "system/FontTRLE.h"
14
 #include "system/FontTTF.h"
13
 #include "system/FontTTF.h"

+ 0
- 2
src/system/FontTRLE.cpp View File

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
-#include <algorithm>
9
 #include <fstream>
8
 #include <fstream>
10
 #include <sstream>
9
 #include <sstream>
11
-#include <stdexcept>
12
 
10
 
13
 #include "global.h"
11
 #include "global.h"
14
 #include "TextureManager.h"
12
 #include "TextureManager.h"

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

10
 #include <OpenAL/al.h>
10
 #include <OpenAL/al.h>
11
 #else
11
 #else
12
 #include <AL/al.h>
12
 #include <AL/al.h>
13
-#include <fcntl.h>
14
-#include <unistd.h>
15
 #endif
13
 #endif
16
 
14
 
17
 #include <AL/alut.h>
15
 #include <AL/alut.h>

+ 0
- 3
src/system/WindowGLFW.cpp View File

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
-#include <cstring>
9
-
10
 #include "global.h"
8
 #include "global.h"
11
 #include "Log.h"
9
 #include "Log.h"
12
 #include "RunTime.h"
10
 #include "RunTime.h"
13
 #include "UI.h"
11
 #include "UI.h"
14
 #include "system/Window.h"
12
 #include "system/Window.h"
15
-#include "utils/strings.h"
16
 #include "system/WindowGLFW.h"
13
 #include "system/WindowGLFW.h"
17
 
14
 
18
 glm::i32vec2 WindowGLFW::size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
15
 glm::i32vec2 WindowGLFW::size(DEFAULT_WIDTH, DEFAULT_HEIGHT);

+ 4
- 7
src/system/WindowSDL.cpp View File

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
-#include <iostream>
9
-
10
 #include "global.h"
8
 #include "global.h"
11
 #include "Log.h"
9
 #include "Log.h"
12
 #include "RunTime.h"
10
 #include "RunTime.h"
13
 #include "UI.h"
11
 #include "UI.h"
14
 #include "system/Window.h"
12
 #include "system/Window.h"
15
-#include "utils/strings.h"
16
 #include "system/WindowSDL.h"
13
 #include "system/WindowSDL.h"
17
 
14
 
18
 #define SUBSYSTEMS_USED (SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER)
15
 #define SUBSYSTEMS_USED (SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER)
27
 
24
 
28
 int WindowSDL::initialize() {
25
 int WindowSDL::initialize() {
29
     if (SDL_Init(SUBSYSTEMS_USED) != 0) {
26
     if (SDL_Init(SUBSYSTEMS_USED) != 0) {
30
-        std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
27
+        getLog() << "SDL_Init Error: " << SDL_GetError() << Log::endl;
31
         return -1;
28
         return -1;
32
     }
29
     }
33
 
30
 
47
         || (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) != 0)
44
         || (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) != 0)
48
         || (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3) != 0)
45
         || (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3) != 0)
49
         || (SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE))) {
46
         || (SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE))) {
50
-        std::cout << "SDL_GL_SetAttribute Error: " << SDL_GetError() << std::endl;
47
+        getLog() << "SDL_GL_SetAttribute Error: " << SDL_GetError() << Log::endl;
51
         return -2;
48
         return -2;
52
     }
49
     }
53
 
50
 
54
     window = SDL_CreateWindow(VERSION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
51
     window = SDL_CreateWindow(VERSION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
55
                               size.x, size.y, flags);
52
                               size.x, size.y, flags);
56
     if (!window) {
53
     if (!window) {
57
-        std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
54
+        getLog() << "SDL_CreateWindow Error: " << SDL_GetError() << Log::endl;
58
         return -3;
55
         return -3;
59
     }
56
     }
60
 
57
 
61
     context = SDL_GL_CreateContext(window);
58
     context = SDL_GL_CreateContext(window);
62
     if (!context) {
59
     if (!context) {
63
-        std::cout << "SDL_GL_CreateContext Error: " << SDL_GetError() << std::endl;
60
+        getLog() << "SDL_GL_CreateContext Error: " << SDL_GetError() << Log::endl;
64
         return -4;
61
         return -4;
65
     }
62
     }
66
 
63
 

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

7
 
7
 
8
 #include <algorithm>
8
 #include <algorithm>
9
 #include <iostream>
9
 #include <iostream>
10
-#include <sstream>
11
-#include <cstring>
12
 
10
 
13
 #include "global.h"
11
 #include "global.h"
14
 #include <Log.h>
12
 #include <Log.h>

+ 0
- 2
src/utils/binary.cpp View File

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
-#include <sstream>
9
-
10
 #include "global.h"
8
 #include "global.h"
11
 #include "utils/binary.h"
9
 #include "utils/binary.h"
12
 
10
 

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

31
 #else
31
 #else
32
 
32
 
33
     assert(false);
33
     assert(false);
34
-    return std::string();
34
+    return "";
35
 
35
 
36
 #endif
36
 #endif
37
 }
37
 }
56
 #else
56
 #else
57
 
57
 
58
     assert(false);
58
     assert(false);
59
-    return std::string();
59
+    return "";
60
 
60
 
61
 #endif
61
 #endif
62
 }
62
 }

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

9
  */
9
  */
10
 
10
 
11
 #include <fstream>
11
 #include <fstream>
12
-#include <iostream>
13
 
12
 
14
 #include "global.h"
13
 #include "global.h"
14
+#include "Log.h"
15
 #include "utils/pcx.h"
15
 #include "utils/pcx.h"
16
 
16
 
17
 int pcxCheck(const char* filename) {
17
 int pcxCheck(const char* filename) {
25
 
25
 
26
     // Basic validation
26
     // Basic validation
27
     if (!file.read((char*)(&header[0]), 128)) {
27
     if (!file.read((char*)(&header[0]), 128)) {
28
-        std::cout << "File not big enough for valid PCX header!" << std::endl;
28
+        getLog() << "File not big enough for valid PCX header!" << Log::endl;
29
         delete [] header;
29
         delete [] header;
30
         return -1;
30
         return -1;
31
     }
31
     }
32
 
32
 
33
     if (header[0] != 0x0A) {
33
     if (header[0] != 0x0A) {
34
-        std::cout << "Magic number at file start is wrong (" << header[0] << " != 0x0A)" << std::endl;
34
+        getLog() << "Magic number at file start is wrong (" << header[0] << " != 0x0A)" << Log::endl;
35
         delete [] header;
35
         delete [] header;
36
         return -2;
36
         return -2;
37
     }
37
     }
38
 
38
 
39
     if ((header[1] != 0) && ((header[1] < 2) || (header[1] > 5))) {
39
     if ((header[1] != 0) && ((header[1] < 2) || (header[1] > 5))) {
40
         // Valid: 0, 2, 3, 4, 5
40
         // Valid: 0, 2, 3, 4, 5
41
-        std::cout << "Unknown PCX file format version (" << header[1] << ")" << std::endl;
41
+        getLog() << "Unknown PCX file format version (" << header[1] << ")" << Log::endl;
42
         delete [] header;
42
         delete [] header;
43
         return -3;
43
         return -3;
44
     }
44
     }
45
 
45
 
46
     if ((header[2] != 0) && (header[2] != 1)) {
46
     if ((header[2] != 0) && (header[2] != 1)) {
47
-        std::cout << "Unknown PCX file encoding (" << header[2] << ")" << std::endl;
47
+        getLog() << "Unknown PCX file encoding (" << header[2] << ")" << Log::endl;
48
         delete [] header;
48
         delete [] header;
49
         return -4;
49
         return -4;
50
     }
50
     }
51
 
51
 
52
     if (header[3] != 8) {
52
     if (header[3] != 8) {
53
-        std::cout << "Only supporting 8bit (" << header[3] << "bit)" << std::endl;
53
+        getLog() << "Only supporting 8bit (" << header[3] << "bit)" << Log::endl;
54
         delete [] header;
54
         delete [] header;
55
         return -5;
55
         return -5;
56
     }
56
     }
57
 
57
 
58
     if (header[64] != 0) {
58
     if (header[64] != 0) {
59
-        std::cout << "Reserved field is  used (" << header[64] << " != 0)" << std::endl;
59
+        getLog() << "Reserved field is  used (" << header[64] << " != 0)" << Log::endl;
60
         delete [] header;
60
         delete [] header;
61
         return -6;
61
         return -6;
62
     }
62
     }
83
 
83
 
84
     // Basic validation
84
     // Basic validation
85
     if (!file.read((char*)(&header[0]), 128)) {
85
     if (!file.read((char*)(&header[0]), 128)) {
86
-        std::cout << "File not big enough for valid PCX header!" << std::endl;
86
+        getLog() << "File not big enough for valid PCX header!" << Log::endl;
87
         delete [] header;
87
         delete [] header;
88
         return -1;
88
         return -1;
89
     }
89
     }
90
 
90
 
91
     if (header[0] != 0x0A) {
91
     if (header[0] != 0x0A) {
92
-        std::cout << "Magic number at file start is wrong (" << header[0] << " != 0x0A)" << std::endl;
92
+        getLog() << "Magic number at file start is wrong (" << header[0] << " != 0x0A)" << Log::endl;
93
         delete [] header;
93
         delete [] header;
94
         return -2;
94
         return -2;
95
     }
95
     }
96
 
96
 
97
     if ((header[1] != 0) && ((header[1] < 2) || (header[1] > 5))) {
97
     if ((header[1] != 0) && ((header[1] < 2) || (header[1] > 5))) {
98
         // Valid: 0, 2, 3, 4, 5
98
         // Valid: 0, 2, 3, 4, 5
99
-        std::cout << "Unknown PCX file format version (" << header[1] << ")" << std::endl;
99
+        getLog() << "Unknown PCX file format version (" << header[1] << ")" << Log::endl;
100
         delete [] header;
100
         delete [] header;
101
         return -3;
101
         return -3;
102
     }
102
     }
103
 
103
 
104
     if ((header[2] != 0) && (header[2] != 1)) {
104
     if ((header[2] != 0) && (header[2] != 1)) {
105
-        std::cout << "Unknown PCX file encoding (" << header[2] << ")" << std::endl;
105
+        getLog() << "Unknown PCX file encoding (" << header[2] << ")" << Log::endl;
106
         delete [] header;
106
         delete [] header;
107
         return -4;
107
         return -4;
108
     }
108
     }
109
 
109
 
110
     if (header[3] != 8) {
110
     if (header[3] != 8) {
111
-        std::cout << "Only supporting 8bit (" << header[3] << "bit)" << std::endl;
111
+        getLog() << "Only supporting 8bit (" << header[3] << "bit)" << Log::endl;
112
         delete [] header;
112
         delete [] header;
113
         return -5;
113
         return -5;
114
     }
114
     }
115
 
115
 
116
     if (header[64] != 0) {
116
     if (header[64] != 0) {
117
-        std::cout << "Reserved field is  used (" << header[64] << " != 0)" << std::endl;
117
+        getLog() << "Reserved field is  used (" << header[64] << " != 0)" << Log::endl;
118
         delete [] header;
118
         delete [] header;
119
         return -6;
119
         return -6;
120
     }
120
     }
151
         unsigned int n = 1; // Run-length-encoding assumes 1
151
         unsigned int n = 1; // Run-length-encoding assumes 1
152
         int c = file.get();
152
         int c = file.get();
153
         if (!file) {
153
         if (!file) {
154
-            std::cout << "Could not read data (" << i
155
-                      << (file.eof() ? " EOF" : "") << ")" << std::endl;
154
+            getLog() << "Could not read data (" << i
155
+                      << (file.eof() ? " EOF" : "") << ")" << Log::endl;
156
             delete [] buffer;
156
             delete [] buffer;
157
             return -7;
157
             return -7;
158
         }
158
         }
163
                 n = c & 0x3F;
163
                 n = c & 0x3F;
164
                 c = file.get();
164
                 c = file.get();
165
                 if (!file) {
165
                 if (!file) {
166
-                    std::cout << "Could not read data rle (" << i
167
-                              << (file.eof() ? " EOF" : "") << ")" << std::endl;
166
+                    getLog() << "Could not read data rle (" << i
167
+                              << (file.eof() ? " EOF" : "") << ")" << Log::endl;
168
                     delete [] buffer;
168
                     delete [] buffer;
169
                     return -8;
169
                     return -8;
170
                 }
170
                 }
186
             for (unsigned int i = 0; i < 768; i++) {
186
             for (unsigned int i = 0; i < 768; i++) {
187
                 palette[i] = (unsigned char)file.get();
187
                 palette[i] = (unsigned char)file.get();
188
                 if (!file) {
188
                 if (!file) {
189
-                    std::cout << "Could not read 256 color palette (" << i << ")" << std::endl;
189
+                    getLog() << "Could not read 256 color palette (" << i << ")" << Log::endl;
190
                     delete [] buffer;
190
                     delete [] buffer;
191
                     delete [] palette;
191
                     delete [] palette;
192
                     return -9;
192
                     return -9;
209
                     green = palette[(buffer[(y * totalBytes) + x] * 3) + 1];
209
                     green = palette[(buffer[(y * totalBytes) + x] * 3) + 1];
210
                     blue = palette[(buffer[(y * totalBytes) + x] * 3) + 2];
210
                     blue = palette[(buffer[(y * totalBytes) + x] * 3) + 2];
211
                 } else {
211
                 } else {
212
-                    std::cout << "Unsupported number of planes (" << nPlanes << ")" << std::endl;
212
+                    getLog() << "Unsupported number of planes (" << nPlanes << ")" << Log::endl;
213
                     delete [] buffer;
213
                     delete [] buffer;
214
                     delete [] palette;
214
                     delete [] palette;
215
                     delete [] *image;
215
                     delete [] *image;
226
                 } else if (nPlanes == 1) {
226
                 } else if (nPlanes == 1) {
227
                     red = green = blue = buffer[(y * totalBytes) + x];
227
                     red = green = blue = buffer[(y * totalBytes) + x];
228
                 } else {
228
                 } else {
229
-                    std::cout << "Unsupported number of planes (" << nPlanes << ")" << std::endl;
229
+                    getLog() << "Unsupported number of planes (" << nPlanes << ")" << Log::endl;
230
                     delete [] buffer;
230
                     delete [] buffer;
231
                     delete [] palette;
231
                     delete [] palette;
232
                     delete [] *image;
232
                     delete [] *image;

Loading…
Cancel
Save