|
@@ -5,10 +5,9 @@
|
5
|
5
|
* \author xythobuz
|
6
|
6
|
*/
|
7
|
7
|
|
8
|
|
-#include <algorithm>
|
9
|
|
-
|
10
|
8
|
#include "global.h"
|
11
|
9
|
#include "Debug.h"
|
|
10
|
+#include "RunTime.h"
|
12
|
11
|
#include "TextureManager.h"
|
13
|
12
|
#include "Window.h"
|
14
|
13
|
|
|
@@ -24,14 +23,22 @@ Debug::Debug() {
|
24
|
23
|
}
|
25
|
24
|
|
26
|
25
|
Debug::~Debug() {
|
|
26
|
+ // TODO Segfaults...?
|
|
27
|
+ //ImGui::Shutdown();
|
|
28
|
+
|
27
|
29
|
UI::removeWindow(this);
|
28
|
30
|
}
|
29
|
31
|
|
30
|
32
|
int Debug::initialize() {
|
|
33
|
+ iniFilename = getRunTime().getBaseDir() + "/imgui.ini";
|
|
34
|
+ logFilename = getRunTime().getBaseDir() + "/imgui_log.txt";
|
|
35
|
+
|
31
|
36
|
ImGuiIO& io = ImGui::GetIO();
|
32
|
37
|
io.DisplaySize = ImVec2((float)getWindow().getWidth(), (float)getWindow().getHeight());
|
33
|
38
|
io.DeltaTime = 1.0f/60.0f;
|
34
|
|
- io.PixelCenterOffset = 0.0f;
|
|
39
|
+
|
|
40
|
+ io.IniFilename = iniFilename.c_str();
|
|
41
|
+ io.LogFilename = logFilename.c_str();
|
35
|
42
|
|
36
|
43
|
io.KeyMap[ImGuiKey_Tab] = tabKey;
|
37
|
44
|
io.KeyMap[ImGuiKey_LeftArrow] = leftKey;
|
|
@@ -75,6 +82,10 @@ void Debug::display() {
|
75
|
82
|
}
|
76
|
83
|
|
77
|
84
|
void Debug::eventsFinished() {
|
|
85
|
+ ImGuiIO& io = ImGui::GetIO();
|
|
86
|
+ io.DisplaySize = ImVec2((float)getWindow().getWidth(), (float)getWindow().getHeight());
|
|
87
|
+ io.DeltaTime = 1.0f / 60.0f; // TODO proper timing
|
|
88
|
+
|
78
|
89
|
ImGui::NewFrame();
|
79
|
90
|
}
|
80
|
91
|
|
|
@@ -125,19 +136,16 @@ void Debug::renderImGui(ImDrawList** const cmd_lists, int cmd_lists_count) {
|
125
|
136
|
|
126
|
137
|
getWindow().glEnter2D();
|
127
|
138
|
|
128
|
|
- glDisable(GL_CULL_FACE);
|
129
|
139
|
glDisable(GL_DEPTH_TEST);
|
130
|
140
|
glEnable(GL_SCISSOR_TEST);
|
131
|
|
- //glEnableClientState(GL_VERTEX_ARRAY);
|
|
141
|
+
|
|
142
|
+ glEnableClientState(GL_VERTEX_ARRAY);
|
132
|
143
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
133
|
144
|
glEnableClientState(GL_COLOR_ARRAY);
|
134
|
145
|
|
135
|
146
|
// Setup texture
|
136
|
147
|
getTextureManager().bindTextureId(fontTex);
|
137
|
148
|
|
138
|
|
- const float width = ImGui::GetIO().DisplaySize.x;
|
139
|
|
- const float height = ImGui::GetIO().DisplaySize.y;
|
140
|
|
-
|
141
|
149
|
// Render command lists
|
142
|
150
|
for (int n = 0; n < cmd_lists_count; n++) {
|
143
|
151
|
const ImDrawList* cmd_list = cmd_lists[n];
|
|
@@ -149,7 +157,7 @@ void Debug::renderImGui(ImDrawList** const cmd_lists, int cmd_lists_count) {
|
149
|
157
|
int vtx_offset = 0;
|
150
|
158
|
const ImDrawCmd* pcmd_end = cmd_list->commands.end();
|
151
|
159
|
for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++) {
|
152
|
|
- glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w),
|
|
160
|
+ glScissor((int)pcmd->clip_rect.x, (int)(ImGui::GetIO().DisplaySize.y - pcmd->clip_rect.w),
|
153
|
161
|
(int)(pcmd->clip_rect.z - pcmd->clip_rect.x),
|
154
|
162
|
(int)(pcmd->clip_rect.w - pcmd->clip_rect.y));
|
155
|
163
|
glDrawArrays(GL_TRIANGLES, vtx_offset, pcmd->vtx_count);
|
|
@@ -157,12 +165,12 @@ void Debug::renderImGui(ImDrawList** const cmd_lists, int cmd_lists_count) {
|
157
|
165
|
}
|
158
|
166
|
}
|
159
|
167
|
|
160
|
|
- glEnable(GL_CULL_FACE);
|
161
|
168
|
glEnable(GL_DEPTH_TEST);
|
162
|
169
|
glDisable(GL_SCISSOR_TEST);
|
163
|
|
- glDisableClientState(GL_COLOR_ARRAY);
|
|
170
|
+
|
|
171
|
+ glDisableClientState(GL_VERTEX_ARRAY);
|
164
|
172
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
165
|
|
- //glDisableClientState(GL_VERTEX_ARRAY);
|
|
173
|
+ glDisableClientState(GL_COLOR_ARRAY);
|
166
|
174
|
|
167
|
175
|
getWindow().glExit2D();
|
168
|
176
|
}
|