Просмотр исходного кода

Debug info now displayed as imgui overlay

Thomas Buck 10 лет назад
Родитель
Сommit
29ca435f21

+ 4
- 0
ChangeLog.md Просмотреть файл

@@ -2,6 +2,10 @@
2 2
 
3 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 9
     [ 20140107 ]
6 10
     * Fixed problems with FontTTFs Glyph Baseline
7 11
     * No longer using wrong assert() when glm is included

+ 2
- 16
include/Game.h Просмотреть файл

@@ -16,16 +16,13 @@
16 16
 class Game {
17 17
   public:
18 18
     Game();
19
-    ~Game();
20 19
 
21 20
     int initialize();
21
+    void destroy();
22 22
 
23
-    bool isLoaded();
24
-
23
+    bool isLoaded() { return mLoaded; }
25 24
     int loadLevel(const char* level);
26 25
 
27
-    void destroy();
28
-
29 26
     void display();
30 27
     void handleAction(ActionEvents action, bool isFinished);
31 28
     void handleMouseMotion(int xrel, int yrel, int xabs, int yabs);
@@ -36,19 +33,8 @@ class Game {
36 33
     void setLara(long lara);
37 34
 
38 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 36
     bool mLoaded;
49
-
50 37
     long mLara;
51
-
52 38
     bool activeEvents[ActionEventCount];
53 39
 };
54 40
 

+ 1
- 2
include/Log.h Просмотреть файл

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

+ 5
- 4
include/Render.h Просмотреть файл

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

+ 7
- 26
include/global.h Просмотреть файл

@@ -106,7 +106,7 @@ typedef enum {
106 106
 
107 107
 template<typename T, typename U>
108 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 110
     const unsigned int maxSize = 128;
111 111
     void* callstack[maxSize];
112 112
     int frames = backtrace(callstack, maxSize);
@@ -115,28 +115,7 @@ template<typename T, typename U>
115 115
     std::cout << std::endl << "assertion failed:" << std::endl;
116 116
     std::cout << "\t" << exp << std::endl;
117 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 119
     std::cout << "in " << file << ":" << line << std::endl << std::endl;
141 120
 
142 121
     for (int i = 0; i < frames; i++)
@@ -152,21 +131,23 @@ template<typename T, typename U>
152 131
 #define assert(x) { \
153 132
     auto assertEvalTemp = x; \
154 133
     if (!assertEvalTemp) \
155
-        assertEqualImplementation(#x, assertEvalTemp, true, __FILE__, __LINE__, false); \
134
+        assertEqualImplementation(#x, assertEvalTemp, true, __FILE__, __LINE__); \
156 135
 }
157 136
 
158 137
 #define assertEqual(x, y) { \
159 138
     auto assertEvalTemp = x; \
160 139
     auto assertEvalTemp2 = y; \
161 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 145
 #define assertNotEqual(x, y) { \
166 146
     auto assertEvalTemp = x; \
167 147
     auto assertEvalTemp2 = y; \
168 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 153
 #else // NODEBUG

+ 0
- 1
src/Console.cpp Просмотреть файл

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

+ 1
- 39
src/Game.cpp Просмотреть файл

@@ -5,28 +5,16 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
-#include <algorithm>
9
-#include <map>
10
-#include <sstream>
11
-#include <cstdlib>
12
-#include <cstring>
13
-
14 8
 #include "global.h"
15 9
 #include "Camera.h"
16 10
 #include "Game.h"
17 11
 #include "loader/Loader.h"
18 12
 #include "Log.h"
19 13
 #include "Render.h"
20
-#include "RunTime.h"
21 14
 #include "SoundManager.h"
22
-#include "StaticMesh.h"
23
-#include "system/Font.h"
24
-#include "system/Sound.h"
25
-#include "system/Window.h"
26 15
 #include "TextureManager.h"
27 16
 #include "UI.h"
28 17
 #include "World.h"
29
-#include "utils/strings.h"
30 18
 
31 19
 Game::Game() {
32 20
     mLoaded = false;
@@ -37,9 +25,6 @@ Game::Game() {
37 25
     }
38 26
 }
39 27
 
40
-Game::~Game() {
41
-}
42
-
43 28
 int Game::initialize() {
44 29
     // Enable Renderer
45 30
     Render::setMode(RenderMode::LoadScreen);
@@ -49,24 +34,6 @@ int Game::initialize() {
49 34
 
50 35
 void Game::display() {
51 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 39
 void Game::destroy() {
@@ -81,14 +48,9 @@ void Game::destroy() {
81 48
     getWorld().destroy();
82 49
 }
83 50
 
84
-bool Game::isLoaded() {
85
-    return mLoaded;
86
-}
87
-
88 51
 int Game::loadLevel(const char* level) {
89 52
     destroy();
90
-    levelName = level;
91
-    getLog() << "Loading " << levelName << Log::endl;
53
+    getLog() << "Loading " << level << Log::endl;
92 54
     auto loader = Loader::createLoader(level);
93 55
     if (loader) {
94 56
         int error = loader->load(level);

+ 0
- 1
src/Menu.cpp Просмотреть файл

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

+ 0
- 1
src/Mesh.cpp Просмотреть файл

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

+ 0
- 27
src/Render.cpp Просмотреть файл

@@ -6,18 +6,14 @@
6 6
  * \author xythobuz
7 7
  */
8 8
 
9
-#include <algorithm>
10 9
 #include <sstream>
11 10
 
12 11
 #include "global.h"
13 12
 #include "Camera.h"
14
-#include "Game.h"
15 13
 #include "Log.h"
16
-#include "UI.h"
17 14
 #include "World.h"
18 15
 #include "system/Shader.h"
19 16
 #include "system/Window.h"
20
-#include "utils/strings.h"
21 17
 #include "Render.h"
22 18
 
23 19
 #include <glm/gtc/matrix_transform.hpp>
@@ -29,25 +25,6 @@ RenderMode Render::mode = RenderMode::LoadScreen;
29 25
 std::vector<Room*> Render::roomList;
30 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 28
 void Render::display() {
52 29
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
53 30
 
@@ -85,10 +62,6 @@ void Render::display() {
85 62
     }
86 63
 }
87 64
 
88
-void Render::clearRoomList() {
89
-    roomList.clear();
90
-}
91
-
92 65
 void Render::buildRoomList(int room) {
93 66
     if (room < -1) {
94 67
         // Check if the camera currently is in a room...

+ 0
- 4
src/Room.cpp Просмотреть файл

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

+ 0
- 1
src/RoomData.cpp Просмотреть файл

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

+ 0
- 2
src/RunTime.cpp Просмотреть файл

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

+ 0
- 1
src/SoundManager.cpp Просмотреть файл

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

+ 0
- 1
src/Sprite.cpp Просмотреть файл

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

+ 0
- 5
src/TextureManager.cpp Просмотреть файл

@@ -6,11 +6,6 @@
6 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 9
 #include "stb/stb_image.h"
15 10
 
16 11
 #include "global.h"

+ 17
- 3
src/UI.cpp Просмотреть файл

@@ -5,9 +5,6 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
-#include <algorithm>
9
-#include <cstring>
10
-
11 8
 #include "imgui/imgui.h"
12 9
 #include "stb/stb_image.h"
13 10
 
@@ -202,6 +199,23 @@ void UI::eventsFinished() {
202 199
 }
203 200
 
204 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 219
     Console::display();
206 220
 
207 221
     if (!visible) {

+ 0
- 3
src/World.cpp Просмотреть файл

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

+ 0
- 1
src/system/Font.cpp Просмотреть файл

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

+ 0
- 2
src/system/FontTRLE.cpp Просмотреть файл

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

+ 0
- 2
src/system/SoundAL.cpp Просмотреть файл

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

+ 0
- 3
src/system/WindowGLFW.cpp Просмотреть файл

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

+ 4
- 7
src/system/WindowSDL.cpp Просмотреть файл

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

+ 0
- 2
src/utils/Folder.cpp Просмотреть файл

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

+ 0
- 2
src/utils/binary.cpp Просмотреть файл

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

+ 2
- 2
src/utils/filesystem.cpp Просмотреть файл

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

+ 20
- 20
src/utils/pcx.cpp Просмотреть файл

@@ -9,9 +9,9 @@
9 9
  */
10 10
 
11 11
 #include <fstream>
12
-#include <iostream>
13 12
 
14 13
 #include "global.h"
14
+#include "Log.h"
15 15
 #include "utils/pcx.h"
16 16
 
17 17
 int pcxCheck(const char* filename) {
@@ -25,38 +25,38 @@ int pcxCheck(const char* filename) {
25 25
 
26 26
     // Basic validation
27 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 29
         delete [] header;
30 30
         return -1;
31 31
     }
32 32
 
33 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 35
         delete [] header;
36 36
         return -2;
37 37
     }
38 38
 
39 39
     if ((header[1] != 0) && ((header[1] < 2) || (header[1] > 5))) {
40 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 42
         delete [] header;
43 43
         return -3;
44 44
     }
45 45
 
46 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 48
         delete [] header;
49 49
         return -4;
50 50
     }
51 51
 
52 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 54
         delete [] header;
55 55
         return -5;
56 56
     }
57 57
 
58 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 60
         delete [] header;
61 61
         return -6;
62 62
     }
@@ -83,38 +83,38 @@ int pcxLoad(const char* filename, unsigned char** image,
83 83
 
84 84
     // Basic validation
85 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 87
         delete [] header;
88 88
         return -1;
89 89
     }
90 90
 
91 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 93
         delete [] header;
94 94
         return -2;
95 95
     }
96 96
 
97 97
     if ((header[1] != 0) && ((header[1] < 2) || (header[1] > 5))) {
98 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 100
         delete [] header;
101 101
         return -3;
102 102
     }
103 103
 
104 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 106
         delete [] header;
107 107
         return -4;
108 108
     }
109 109
 
110 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 112
         delete [] header;
113 113
         return -5;
114 114
     }
115 115
 
116 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 118
         delete [] header;
119 119
         return -6;
120 120
     }
@@ -151,8 +151,8 @@ int pcxLoad(const char* filename, unsigned char** image,
151 151
         unsigned int n = 1; // Run-length-encoding assumes 1
152 152
         int c = file.get();
153 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 156
             delete [] buffer;
157 157
             return -7;
158 158
         }
@@ -163,8 +163,8 @@ int pcxLoad(const char* filename, unsigned char** image,
163 163
                 n = c & 0x3F;
164 164
                 c = file.get();
165 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 168
                     delete [] buffer;
169 169
                     return -8;
170 170
                 }
@@ -186,7 +186,7 @@ int pcxLoad(const char* filename, unsigned char** image,
186 186
             for (unsigned int i = 0; i < 768; i++) {
187 187
                 palette[i] = (unsigned char)file.get();
188 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 190
                     delete [] buffer;
191 191
                     delete [] palette;
192 192
                     return -9;
@@ -209,7 +209,7 @@ int pcxLoad(const char* filename, unsigned char** image,
209 209
                     green = palette[(buffer[(y * totalBytes) + x] * 3) + 1];
210 210
                     blue = palette[(buffer[(y * totalBytes) + x] * 3) + 2];
211 211
                 } else {
212
-                    std::cout << "Unsupported number of planes (" << nPlanes << ")" << std::endl;
212
+                    getLog() << "Unsupported number of planes (" << nPlanes << ")" << Log::endl;
213 213
                     delete [] buffer;
214 214
                     delete [] palette;
215 215
                     delete [] *image;
@@ -226,7 +226,7 @@ int pcxLoad(const char* filename, unsigned char** image,
226 226
                 } else if (nPlanes == 1) {
227 227
                     red = green = blue = buffer[(y * totalBytes) + x];
228 228
                 } else {
229
-                    std::cout << "Unsupported number of planes (" << nPlanes << ")" << std::endl;
229
+                    getLog() << "Unsupported number of planes (" << nPlanes << ")" << Log::endl;
230 230
                     delete [] buffer;
231 231
                     delete [] palette;
232 232
                     delete [] *image;

Загрузка…
Отмена
Сохранить