Browse Source

More debug output and support for windows compiling.

Thomas Buck 9 years ago
parent
commit
d26aedf803

+ 3
- 0
ChangeLog.md View File

8
     * Fix to allow imguifilesystem to compile using Visual Studio 2013.
8
     * Fix to allow imguifilesystem to compile using Visual Studio 2013.
9
     * Very simple implementation of solid-mode using white texture.
9
     * Very simple implementation of solid-mode using white texture.
10
     * New option to keep camera in a room.
10
     * New option to keep camera in a room.
11
+    * Counting number of OpenGL calls per frame.
12
+    * Now displaying meaningful error message when no OpenGL lib was found at run-time.
13
+    * No including gl.h instead of gl33.h where needed.
11
 
14
 
12
     [ 20150405 ]
15
     [ 20150405 ]
13
     * No longer flipping axis in shaders, now turning camera upside-down.
16
     * No longer flipping axis in shaders, now turning camera upside-down.

+ 4
- 0
include/RunTime.h View File

42
     static const std::vector<float>& getHistoryFPS() { return history; }
42
     static const std::vector<float>& getHistoryFPS() { return history; }
43
     static float getLastFrameTime() { return lastFrameTime / 1000.0f; }
43
     static float getLastFrameTime() { return lastFrameTime / 1000.0f; }
44
 
44
 
45
+    static void incrementCallCount() { glCallCount++; }
46
+    static unsigned long getCallCount() { auto c = glCallCount; glCallCount = 0; return c; }
47
+
45
   private:
48
   private:
46
     static std::string baseDir;
49
     static std::string baseDir;
47
     static std::string pakDir;
50
     static std::string pakDir;
57
     static unsigned long frameTimeSum, frameTimeSum2;
60
     static unsigned long frameTimeSum, frameTimeSum2;
58
     static unsigned long fps;
61
     static unsigned long fps;
59
     static std::vector<float> history;
62
     static std::vector<float> history;
63
+    static unsigned long glCallCount;
60
 };
64
 };
61
 
65
 
62
 #endif
66
 #endif

+ 1
- 1
include/system/Shader.h View File

13
 
13
 
14
 #include "TextureManager.h"
14
 #include "TextureManager.h"
15
 
15
 
16
-#include <glbinding/gl/gl33.h>
16
+#include <glbinding/gl/gl.h>
17
 
17
 
18
 class ShaderBuffer {
18
 class ShaderBuffer {
19
   public:
19
   public:

+ 1
- 2
include/system/WindowGLFW.h View File

55
     static bool mousegrab;
55
     static bool mousegrab;
56
     static bool textinput;
56
     static bool textinput;
57
     static GLFWwindow* window;
57
     static GLFWwindow* window;
58
-    static int lastMouseX;
59
-    static int lastMouseY;
58
+    static int lastMouseX, lastMouseY;
60
     static bool modShift;
59
     static bool modShift;
61
     static bool modControl;
60
     static bool modControl;
62
     static bool modAlt;
61
     static bool modAlt;

+ 0
- 1
src/Camera.cpp View File

18
 #include "system/Window.h"
18
 #include "system/Window.h"
19
 #include "Camera.h"
19
 #include "Camera.h"
20
 
20
 
21
-#include <glbinding/gl/gl33.h>
22
 #include <glm/gtc/epsilon.hpp>
21
 #include <glm/gtc/epsilon.hpp>
23
 #include <glm/gtc/matrix_transform.hpp>
22
 #include <glm/gtc/matrix_transform.hpp>
24
 #include <glm/gtc/quaternion.hpp>
23
 #include <glm/gtc/quaternion.hpp>

+ 1
- 1
src/Mesh.cpp View File

9
 #include "TextureManager.h"
9
 #include "TextureManager.h"
10
 #include "Mesh.h"
10
 #include "Mesh.h"
11
 
11
 
12
-#include <glbinding/gl/gl33.h>
12
+#include <glbinding/gl/gl.h>
13
 
13
 
14
 Mesh::Mesh(const std::vector<glm::vec3>& vert,
14
 Mesh::Mesh(const std::vector<glm::vec3>& vert,
15
            const std::vector<IndexedRectangle>& rect,
15
            const std::vector<IndexedRectangle>& rect,

+ 2
- 7
src/Render.cpp View File

20
 #include "Render.h"
20
 #include "Render.h"
21
 
21
 
22
 #include <glm/gtc/matrix_transform.hpp>
22
 #include <glm/gtc/matrix_transform.hpp>
23
-#include <glbinding/gl/gl33.h>
23
+#include <glbinding/gl/gl.h>
24
 
24
 
25
 #include "imgui/imgui.h"
25
 #include "imgui/imgui.h"
26
 #include "stb/stb_image_write.h"
26
 #include "stb/stb_image_write.h"
58
     glm::mat4 VP = projection * view;
58
     glm::mat4 VP = projection * view;
59
 
59
 
60
     if (updated || displayVisibilityCheck) {
60
     if (updated || displayVisibilityCheck) {
61
-        int r = Camera::getRoom();
62
         clearRoomList();
61
         clearRoomList();
63
-        if (r < 0) {
64
-            buildRoomList(VP);
65
-        } else {
66
-            buildRoomList(VP, r);
67
-        }
62
+        buildRoomList(VP);
68
     }
63
     }
69
 
64
 
70
     for (int r = roomList.size() - 1; r >= 0; r--) {
65
     for (int r = roomList.size() - 1; r >= 0; r--) {

+ 1
- 1
src/RoomData.cpp View File

13
 
13
 
14
 #include "imgui/imgui.h"
14
 #include "imgui/imgui.h"
15
 
15
 
16
-#include <glbinding/gl/gl33.h>
16
+#include <glbinding/gl/gl.h>
17
 #include <glm/gtc/matrix_transform.hpp>
17
 #include <glm/gtc/matrix_transform.hpp>
18
 
18
 
19
 void BoundingBox::display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot) {
19
 void BoundingBox::display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot) {

+ 1
- 0
src/RunTime.cpp View File

29
 unsigned long RunTime::frameTimeSum2 = 0;
29
 unsigned long RunTime::frameTimeSum2 = 0;
30
 unsigned long RunTime::fps = 0;
30
 unsigned long RunTime::fps = 0;
31
 std::vector<float> RunTime::history;
31
 std::vector<float> RunTime::history;
32
+unsigned long RunTime::glCallCount = 0;
32
 
33
 
33
 void RunTime::initialize() {
34
 void RunTime::initialize() {
34
     baseDir = expandHomeDirectory("~/.OpenRaider");
35
     baseDir = expandHomeDirectory("~/.OpenRaider");

+ 1
- 1
src/TextureManager.cpp View File

21
 #include "utils/strings.h"
21
 #include "utils/strings.h"
22
 #include "TextureManager.h"
22
 #include "TextureManager.h"
23
 
23
 
24
-#include <glbinding/gl/gl33.h>
24
+#include <glbinding/gl/gl.h>
25
 
25
 
26
 glm::vec2 TextureTile::getUV(unsigned int i) {
26
 glm::vec2 TextureTile::getUV(unsigned int i) {
27
     glm::vec2 uv(vertices.at(i).xPixel,
27
     glm::vec2 uv(vertices.at(i).xPixel,

+ 6
- 1
src/UI.cpp View File

23
 #include "utils/time.h"
23
 #include "utils/time.h"
24
 #include "UI.h"
24
 #include "UI.h"
25
 
25
 
26
-#include <glbinding/gl/gl33.h>
26
+#include <glbinding/gl/gl.h>
27
 #include <glm/gtc/matrix_transform.hpp>
27
 #include <glm/gtc/matrix_transform.hpp>
28
 
28
 
29
 Shader UI::imguiShader;
29
 Shader UI::imguiShader;
225
                          ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize
225
                          ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize
226
                          | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings
226
                          | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings
227
                          | ImGuiWindowFlags_AlwaysAutoResize)) {
227
                          | ImGuiWindowFlags_AlwaysAutoResize)) {
228
+#ifdef DEBUG
229
+            ImGui::Text("%d FPS  %lu CPF", RunTime::getFPS(), RunTime::getCallCount());
230
+#else
228
             ImGui::Text("%d FPS", RunTime::getFPS());
231
             ImGui::Text("%d FPS", RunTime::getFPS());
232
+#endif
233
+
229
             ImGui::Text("X: %.1f (%.2f)", Camera::getPosition().x, Camera::getRotation().x);
234
             ImGui::Text("X: %.1f (%.2f)", Camera::getPosition().x, Camera::getRotation().x);
230
             ImGui::Text("Y: %.2f (%.2f)", Camera::getPosition().y, Camera::getRotation().y);
235
             ImGui::Text("Y: %.2f (%.2f)", Camera::getPosition().y, Camera::getRotation().y);
231
             ImGui::Text("Z: %.2f (%d)", Camera::getPosition().z, Camera::getRoom());
236
             ImGui::Text("Z: %.2f (%d)", Camera::getPosition().z, Camera::getRoom());

+ 3
- 0
src/loader/Loader.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
+#include "Log.h"
9
 #include "loader/Loader.h"
10
 #include "loader/Loader.h"
10
 #include "loader/LoaderTR1.h"
11
 #include "loader/LoaderTR1.h"
11
 #include "loader/LoaderTR2.h"
12
 #include "loader/LoaderTR2.h"
33
             return TR_4;
34
             return TR_4;
34
     }
35
     }
35
 
36
 
37
+    Log::get(LOG_ERROR) << "Unknown TR level version: \"" << start << "\"" << Log::endl;
38
+
36
     return TR_UNKNOWN;
39
     return TR_UNKNOWN;
37
 }
40
 }
38
 
41
 

+ 8
- 0
src/main.cpp View File

36
 
36
 
37
 #ifdef DEBUG
37
 #ifdef DEBUG
38
 static void glErrorCallback(const glbinding::FunctionCall& call) {
38
 static void glErrorCallback(const glbinding::FunctionCall& call) {
39
+    RunTime::incrementCallCount();
40
+
39
     gl::GLenum error = gl::glGetError();
41
     gl::GLenum error = gl::glGetError();
40
     if (error == gl::GL_NO_ERROR) {
42
     if (error == gl::GL_NO_ERROR) {
41
         return;
43
         return;
66
 
68
 
67
     log << Log::endl;
69
     log << Log::endl;
68
 }
70
 }
71
+
72
+static void glUnresolvedCallback(const glbinding::AbstractFunction& func) {
73
+    Log::get(LOG_ERROR) << "Unresolved OpenGL call: \"" << func.name() << "\"!" << Log::endl;
74
+    orAssert(func.isResolved());
75
+}
69
 #endif
76
 #endif
70
 
77
 
71
 int main(int argc, char* argv[]) {
78
 int main(int argc, char* argv[]) {
89
                                      | glbinding::CallbackMask::ParametersAndReturnValue,
96
                                      | glbinding::CallbackMask::ParametersAndReturnValue,
90
                                      { "glGetError" });
97
                                      { "glGetError" });
91
     glbinding::setAfterCallback(glErrorCallback);
98
     glbinding::setAfterCallback(glErrorCallback);
99
+    glbinding::setUnresolvedCallback(glUnresolvedCallback);
92
 #endif
100
 #endif
93
 
101
 
94
     Log::get(LOG_INFO) << "Initializing " << VERSION << Log::endl;
102
     Log::get(LOG_INFO) << "Initializing " << VERSION << Log::endl;

+ 1
- 1
src/system/Shader.cpp View File

13
 #include "system/Window.h"
13
 #include "system/Window.h"
14
 #include "system/Shader.h"
14
 #include "system/Shader.h"
15
 
15
 
16
-#include <glbinding/gl/gl33.h>
16
+#include <glbinding/gl/gl.h>
17
 
17
 
18
 ShaderBuffer::~ShaderBuffer() {
18
 ShaderBuffer::~ShaderBuffer() {
19
     if (created)
19
     if (created)

+ 1
- 1
src/system/Window.cpp View File

18
 #error "No windowing library selected!"
18
 #error "No windowing library selected!"
19
 #endif
19
 #endif
20
 
20
 
21
-#include <glbinding/gl/gl33.h>
21
+#include <glbinding/gl/gl.h>
22
 
22
 
23
 int Window::initialize() {
23
 int Window::initialize() {
24
     int res;
24
     int res;

+ 1
- 1
src/system/WindowGLFW.cpp View File

18
 #include "system/Window.h"
18
 #include "system/Window.h"
19
 #include "system/WindowGLFW.h"
19
 #include "system/WindowGLFW.h"
20
 
20
 
21
-#include <glbinding/gl/gl33.h>
21
+#include <glbinding/gl/gl.h>
22
 
22
 
23
 glm::i32vec2 WindowGLFW::size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
23
 glm::i32vec2 WindowGLFW::size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
24
 bool WindowGLFW::fullscreen = false;
24
 bool WindowGLFW::fullscreen = false;

Loading…
Cancel
Save