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,6 +8,9 @@
8 8
     * Fix to allow imguifilesystem to compile using Visual Studio 2013.
9 9
     * Very simple implementation of solid-mode using white texture.
10 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 15
     [ 20150405 ]
13 16
     * No longer flipping axis in shaders, now turning camera upside-down.

+ 4
- 0
include/RunTime.h View File

@@ -42,6 +42,9 @@ class RunTime {
42 42
     static const std::vector<float>& getHistoryFPS() { return history; }
43 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 48
   private:
46 49
     static std::string baseDir;
47 50
     static std::string pakDir;
@@ -57,6 +60,7 @@ class RunTime {
57 60
     static unsigned long frameTimeSum, frameTimeSum2;
58 61
     static unsigned long fps;
59 62
     static std::vector<float> history;
63
+    static unsigned long glCallCount;
60 64
 };
61 65
 
62 66
 #endif

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

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

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

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

+ 0
- 1
src/Camera.cpp View File

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

+ 1
- 1
src/Mesh.cpp View File

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

+ 2
- 7
src/Render.cpp View File

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

+ 1
- 1
src/RoomData.cpp View File

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

+ 1
- 0
src/RunTime.cpp View File

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

+ 1
- 1
src/TextureManager.cpp View File

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

+ 6
- 1
src/UI.cpp View File

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

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

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

+ 8
- 0
src/main.cpp View File

@@ -36,6 +36,8 @@ static std::string configFileToUse;
36 36
 
37 37
 #ifdef DEBUG
38 38
 static void glErrorCallback(const glbinding::FunctionCall& call) {
39
+    RunTime::incrementCallCount();
40
+
39 41
     gl::GLenum error = gl::glGetError();
40 42
     if (error == gl::GL_NO_ERROR) {
41 43
         return;
@@ -66,6 +68,11 @@ static void glErrorCallback(const glbinding::FunctionCall& call) {
66 68
 
67 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 76
 #endif
70 77
 
71 78
 int main(int argc, char* argv[]) {
@@ -89,6 +96,7 @@ int main(int argc, char* argv[]) {
89 96
                                      | glbinding::CallbackMask::ParametersAndReturnValue,
90 97
                                      { "glGetError" });
91 98
     glbinding::setAfterCallback(glErrorCallback);
99
+    glbinding::setUnresolvedCallback(glUnresolvedCallback);
92 100
 #endif
93 101
 
94 102
     Log::get(LOG_INFO) << "Initializing " << VERSION << Log::endl;

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

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

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

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

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

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

Loading…
Cancel
Save