Browse Source

Updated ImGui

Thomas Buck 9 years ago
parent
commit
44935e3e1d

+ 3
- 0
ChangeLog.md View File

2
 
2
 
3
 ## OpenRaider (0.1.4) xythobuz <xythobuz@xythobuz.de>
3
 ## OpenRaider (0.1.4) xythobuz <xythobuz@xythobuz.de>
4
 
4
 
5
+    [ 20150801 ]
6
+    * Updated to current Imgui version (now using indexed rendering)
7
+
5
     [ 20150429 ]
8
     [ 20150429 ]
6
     * Fixed the new BoundingBox rendering approach
9
     * Fixed the new BoundingBox rendering approach
7
     * Fixed portal rendering method, no longer checking portals behind player.
10
     * Fixed portal rendering method, no longer checking portals behind player.

+ 3
- 2
include/UI.h View File

17
 
17
 
18
 #include "system/Shader.h"
18
 #include "system/Shader.h"
19
 
19
 
20
-struct ImDrawList;
20
+struct ImDrawData;
21
 
21
 
22
 class UI {
22
 class UI {
23
   public:
23
   public:
38
     static void handleControllerAxis(float value, KeyboardButton axis);
38
     static void handleControllerAxis(float value, KeyboardButton axis);
39
     static void handleControllerButton(KeyboardButton button, bool released);
39
     static void handleControllerButton(KeyboardButton button, bool released);
40
 
40
 
41
-    static void renderImGui(ImDrawList** const draw_lists, int count);
41
+    static void renderImGui(ImDrawData* draw_data);
42
 
42
 
43
   private:
43
   private:
44
     static bool visible;
44
     static bool visible;
55
     static Shader imguiShader;
55
     static Shader imguiShader;
56
     static const char* imguiShaderVertex;
56
     static const char* imguiShaderVertex;
57
     static const char* imguiShaderFragment;
57
     static const char* imguiShaderFragment;
58
+    static unsigned int vboHandle, elementHandle;
58
 };
59
 };
59
 
60
 
60
 #endif
61
 #endif

+ 15
- 14
include/global.h View File

100
     abort();
100
     abort();
101
 }
101
 }
102
 
102
 
103
-#define orAssert(x) { \
103
+#define orAssert(x) do { \
104
     auto assertEvalTemp = x; \
104
     auto assertEvalTemp = x; \
105
     if (!assertEvalTemp) \
105
     if (!assertEvalTemp) \
106
         orAssertImplementation(#x, assertEvalTemp, true, __FILE__, __LINE__); \
106
         orAssertImplementation(#x, assertEvalTemp, true, __FILE__, __LINE__); \
107
-}
107
+} while (0)
108
 
108
 
109
-#define orAssertEqual(x, y) { \
109
+#define orAssertEqual(x, y) do { \
110
     auto assertEvalTemp = x; \
110
     auto assertEvalTemp = x; \
111
     auto assertEvalTemp2 = y; \
111
     auto assertEvalTemp2 = y; \
112
     if (assertEvalTemp != assertEvalTemp2) \
112
     if (assertEvalTemp != assertEvalTemp2) \
113
         orAssertImplementation(#x " == " #y, assertEvalTemp, assertEvalTemp2, \
113
         orAssertImplementation(#x " == " #y, assertEvalTemp, assertEvalTemp2, \
114
                                   __FILE__, __LINE__, "!="); \
114
                                   __FILE__, __LINE__, "!="); \
115
-}
115
+} while (0)
116
 
116
 
117
-#define orAssertNotEqual(x, y) { \
117
+#define orAssertNotEqual(x, y) do { \
118
     auto assertEvalTemp = x; \
118
     auto assertEvalTemp = x; \
119
     auto assertEvalTemp2 = y; \
119
     auto assertEvalTemp2 = y; \
120
     if (assertEvalTemp == assertEvalTemp2) \
120
     if (assertEvalTemp == assertEvalTemp2) \
121
         orAssertImplementation(#x " != " #y, assertEvalTemp, assertEvalTemp2, \
121
         orAssertImplementation(#x " != " #y, assertEvalTemp, assertEvalTemp2, \
122
                                   __FILE__, __LINE__, "=="); \
122
                                   __FILE__, __LINE__, "=="); \
123
-}
123
+} while (0)
124
 
124
 
125
-#define orAssertLessThan(x, y) { \
125
+#define orAssertLessThan(x, y) do { \
126
     auto assertEvalTemp = x; \
126
     auto assertEvalTemp = x; \
127
     auto assertEvalTemp2 = y; \
127
     auto assertEvalTemp2 = y; \
128
     if (assertEvalTemp >= assertEvalTemp2) \
128
     if (assertEvalTemp >= assertEvalTemp2) \
129
         orAssertImplementation(#x " < " #y, assertEvalTemp, assertEvalTemp2, \
129
         orAssertImplementation(#x " < " #y, assertEvalTemp, assertEvalTemp2, \
130
                                   __FILE__, __LINE__, ">="); \
130
                                   __FILE__, __LINE__, ">="); \
131
-}
131
+} while (0)
132
 
132
 
133
-#define orAssertLessThanEqual(x, y) { \
133
+#define orAssertLessThanEqual(x, y) do { \
134
     auto assertEvalTemp = x; \
134
     auto assertEvalTemp = x; \
135
     auto assertEvalTemp2 = y; \
135
     auto assertEvalTemp2 = y; \
136
     if (assertEvalTemp > assertEvalTemp2) \
136
     if (assertEvalTemp > assertEvalTemp2) \
137
         orAssertImplementation(#x " <= " #y, assertEvalTemp, assertEvalTemp2, \
137
         orAssertImplementation(#x " <= " #y, assertEvalTemp, assertEvalTemp2, \
138
                                   __FILE__, __LINE__, ">"); \
138
                                   __FILE__, __LINE__, ">"); \
139
-}
139
+} while (0)
140
 
140
 
141
-#define orAssertGreaterThan(x, y) { \
141
+#define orAssertGreaterThan(x, y) do { \
142
     auto assertEvalTemp = x; \
142
     auto assertEvalTemp = x; \
143
     auto assertEvalTemp2 = y; \
143
     auto assertEvalTemp2 = y; \
144
     if (assertEvalTemp <= assertEvalTemp2) \
144
     if (assertEvalTemp <= assertEvalTemp2) \
145
         orAssertImplementation(#x " > " #y, assertEvalTemp, assertEvalTemp2, \
145
         orAssertImplementation(#x " > " #y, assertEvalTemp, assertEvalTemp2, \
146
                                   __FILE__, __LINE__, "<="); \
146
                                   __FILE__, __LINE__, "<="); \
147
-}
147
+} while (0)
148
 
148
 
149
-#define orAssertGreaterThanEqual(x, y) { \
149
+#define orAssertGreaterThanEqual(x, y) do { \
150
     auto assertEvalTemp = x; \
150
     auto assertEvalTemp = x; \
151
     auto assertEvalTemp2 = y; \
151
     auto assertEvalTemp2 = y; \
152
     if (assertEvalTemp < assertEvalTemp2) \
152
     if (assertEvalTemp < assertEvalTemp2) \
153
         orAssertImplementation(#x " >= " #y, assertEvalTemp, assertEvalTemp2, \
153
         orAssertImplementation(#x " >= " #y, assertEvalTemp, assertEvalTemp2, \
154
                                   __FILE__, __LINE__, "<"); \
154
                                   __FILE__, __LINE__, "<"); \
155
-}
155
+} while (0)
156
 
156
 
157
 #else // NDEBUG
157
 #else // NDEBUG
158
 
158
 
170
 
170
 
171
 // Fall back to the default C assert
171
 // Fall back to the default C assert
172
 #include <cassert>
172
 #include <cassert>
173
+#define orAssert(x) assert(x)
173
 #define orAssertEqual(x, y) assert((x) == (y))
174
 #define orAssertEqual(x, y) assert((x) == (y))
174
 #define orAssertNotEqual(x, y) assert((x) != (y))
175
 #define orAssertNotEqual(x, y) assert((x) != (y))
175
 #define orAssertLessThan(x, y) assert((x) < (y))
176
 #define orAssertLessThan(x, y) assert((x) < (y))

+ 2
- 0
include/system/Shader.h View File

65
     int addUniform(const char* name);
65
     int addUniform(const char* name);
66
     unsigned int getUniform(int n);
66
     unsigned int getUniform(int n);
67
 
67
 
68
+    int getAttrib(const char* name);
69
+
68
     void loadUniform(int uni, glm::vec2 vec);
70
     void loadUniform(int uni, glm::vec2 vec);
69
     void loadUniform(int uni, glm::vec4 vec);
71
     void loadUniform(int uni, glm::vec4 vec);
70
     void loadUniform(int uni, glm::mat4 mat);
72
     void loadUniform(int uni, glm::mat4 mat);

+ 1
- 1
src/Console.cpp View File

135
             logToTTY = logToClipboard = logToFile = false;
135
             logToTTY = logToClipboard = logToFile = false;
136
         }
136
         }
137
         if (scrollToBottom) {
137
         if (scrollToBottom) {
138
-            ImGui::SetScrollPosHere();
138
+            ImGui::SetScrollHere();
139
             scrollToBottom = false;
139
             scrollToBottom = false;
140
         }
140
         }
141
         ImGui::EndChild();
141
         ImGui::EndChild();

+ 2
- 2
src/SoundManager.cpp View File

272
         ImGui::SliderInt("##soundslide", &index, 0, soundMap.size() - 1);
272
         ImGui::SliderInt("##soundslide", &index, 0, soundMap.size() - 1);
273
         ImGui::PopItemWidth();
273
         ImGui::PopItemWidth();
274
         ImGui::SameLine();
274
         ImGui::SameLine();
275
-        if (ImGui::Button("+##soundplus", ImVec2(0, 0), true)) {
275
+        if (ImGui::Button("+##soundplus", ImVec2(0, 0))) {
276
             if (index < (soundMap.size() - 1))
276
             if (index < (soundMap.size() - 1))
277
                 index++;
277
                 index++;
278
             else
278
             else
279
                 index = 0;
279
                 index = 0;
280
         }
280
         }
281
         ImGui::SameLine();
281
         ImGui::SameLine();
282
-        if (ImGui::Button("-##soundminus", ImVec2(0, 0), true)) {
282
+        if (ImGui::Button("-##soundminus", ImVec2(0, 0))) {
283
             if (index > 0)
283
             if (index > 0)
284
                 index--;
284
                 index--;
285
             else
285
             else

+ 8
- 8
src/TextureManager.cpp View File

410
         ImGui::SliderInt("##texslide", &index, 0, TextureManager::numTextures(
410
         ImGui::SliderInt("##texslide", &index, 0, TextureManager::numTextures(
411
                              game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1);
411
                              game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1);
412
         ImGui::SameLine();
412
         ImGui::SameLine();
413
-        if (ImGui::Button("+##texplus", ImVec2(0, 0), true)) {
413
+        if (ImGui::Button("+##texplus", ImVec2(0, 0))) {
414
             if (index < (numTextures(
414
             if (index < (numTextures(
415
                              game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1))
415
                              game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1))
416
                 index++;
416
                 index++;
418
                 index = 0;
418
                 index = 0;
419
         }
419
         }
420
         ImGui::SameLine();
420
         ImGui::SameLine();
421
-        if (ImGui::Button("-##texminus", ImVec2(0, 0), true)) {
421
+        if (ImGui::Button("-##texminus", ImVec2(0, 0))) {
422
             if (index > 0)
422
             if (index > 0)
423
                 index--;
423
                 index--;
424
             else
424
             else
453
             ImGui::SliderInt("##tileslide", &index, 0, numTiles() - 1);
453
             ImGui::SliderInt("##tileslide", &index, 0, numTiles() - 1);
454
             ImGui::PopItemWidth();
454
             ImGui::PopItemWidth();
455
             ImGui::SameLine();
455
             ImGui::SameLine();
456
-            if (ImGui::Button("+##tileplus", ImVec2(0, 0), true)) {
456
+            if (ImGui::Button("+##tileplus", ImVec2(0, 0))) {
457
                 if (index < (numTiles() - 1))
457
                 if (index < (numTiles() - 1))
458
                     index++;
458
                     index++;
459
                 else
459
                 else
460
                     index = 0;
460
                     index = 0;
461
             }
461
             }
462
             ImGui::SameLine();
462
             ImGui::SameLine();
463
-            if (ImGui::Button("-##tileminus", ImVec2(0, 0), true)) {
463
+            if (ImGui::Button("-##tileminus", ImVec2(0, 0))) {
464
                 if (index > 0)
464
                 if (index > 0)
465
                     index--;
465
                     index--;
466
                 else
466
                 else
491
                 tile = getFirstTileAnimation(index);
491
                 tile = getFirstTileAnimation(index);
492
             }
492
             }
493
             ImGui::SameLine();
493
             ImGui::SameLine();
494
-            if (ImGui::Button("+##animplus", ImVec2(0, 0), true)) {
494
+            if (ImGui::Button("+##animplus", ImVec2(0, 0))) {
495
                 if (index < (numAnimatedTiles() - 1))
495
                 if (index < (numAnimatedTiles() - 1))
496
                     index++;
496
                     index++;
497
                 else
497
                 else
499
                 tile = getFirstTileAnimation(index);
499
                 tile = getFirstTileAnimation(index);
500
             }
500
             }
501
             ImGui::SameLine();
501
             ImGui::SameLine();
502
-            if (ImGui::Button("-##animminus", ImVec2(0, 0), true)) {
502
+            if (ImGui::Button("-##animminus", ImVec2(0, 0))) {
503
                 if (index > 0)
503
                 if (index > 0)
504
                     index--;
504
                     index--;
505
                 else
505
                 else
552
                 sprite = 0;
552
                 sprite = 0;
553
             }
553
             }
554
             ImGui::SameLine();
554
             ImGui::SameLine();
555
-            if (ImGui::Button("+##spriteplus", ImVec2(0, 0), true)) {
555
+            if (ImGui::Button("+##spriteplus", ImVec2(0, 0))) {
556
                 if (index < (World::sizeSpriteSequence() - 1))
556
                 if (index < (World::sizeSpriteSequence() - 1))
557
                     index++;
557
                     index++;
558
                 else
558
                 else
560
                 sprite = 0;
560
                 sprite = 0;
561
             }
561
             }
562
             ImGui::SameLine();
562
             ImGui::SameLine();
563
-            if (ImGui::Button("-##spriteminus", ImVec2(0, 0), true)) {
563
+            if (ImGui::Button("-##spriteminus", ImVec2(0, 0))) {
564
                 if (index > 0)
564
                 if (index > 0)
565
                     index--;
565
                     index--;
566
                 else
566
                 else

+ 56
- 49
src/UI.cpp View File

26
 #include <glbinding/gl/gl.h>
26
 #include <glbinding/gl/gl.h>
27
 #include <glm/gtc/matrix_transform.hpp>
27
 #include <glm/gtc/matrix_transform.hpp>
28
 
28
 
29
+#define OFFSETOF(TYPE, ELEMENT) (&(static_cast<TYPE *>(nullptr)->ELEMENT))
30
+
29
 Shader UI::imguiShader;
31
 Shader UI::imguiShader;
30
 bool UI::visible = false;
32
 bool UI::visible = false;
31
 unsigned int UI::fontTex;
33
 unsigned int UI::fontTex;
32
 std::string UI::iniFilename;
34
 std::string UI::iniFilename;
33
 std::string UI::logFilename;
35
 std::string UI::logFilename;
34
 bool UI::metaKeyIsActive = false;
36
 bool UI::metaKeyIsActive = false;
37
+unsigned int UI::vboHandle = 0;
38
+unsigned int UI::elementHandle = 0;
35
 
39
 
36
 std::list<std::tuple<KeyboardButton, bool>> UI::keyboardEvents;
40
 std::list<std::tuple<KeyboardButton, bool>> UI::keyboardEvents;
37
 std::list<std::tuple<unsigned int, unsigned int, KeyboardButton, bool>> UI::clickEvents;
41
 std::list<std::tuple<unsigned int, unsigned int, KeyboardButton, bool>> UI::clickEvents;
43
     io.DisplaySize = ImVec2(s.x, s.y);
47
     io.DisplaySize = ImVec2(s.x, s.y);
44
 }
48
 }
45
 
49
 
50
+static int attribPos, attribUV, attribCol;
51
+
46
 int UI::initialize() {
52
 int UI::initialize() {
47
     if (imguiShader.compile(imguiShaderVertex, imguiShaderFragment) < 0)
53
     if (imguiShader.compile(imguiShaderVertex, imguiShaderFragment) < 0)
48
         return -1;
54
         return -1;
51
     if (imguiShader.addUniform("textureSampler") < 0)
57
     if (imguiShader.addUniform("textureSampler") < 0)
52
         return -3;
58
         return -3;
53
 
59
 
60
+    attribPos = imguiShader.getAttrib("vertexPosition_screen");
61
+    attribUV = imguiShader.getAttrib("vertexUV");
62
+    attribCol = imguiShader.getAttrib("vertexColor");
63
+
54
     iniFilename = RunTime::getBaseDir() + "/imgui.ini";
64
     iniFilename = RunTime::getBaseDir() + "/imgui.ini";
55
     logFilename = RunTime::getBaseDir() + "/imgui_log.txt";
65
     logFilename = RunTime::getBaseDir() + "/imgui_log.txt";
56
 
66
 
94
     auto bm = TextureManager::getBufferManager(fontTex, TextureStorage::SYSTEM);
104
     auto bm = TextureManager::getBufferManager(fontTex, TextureStorage::SYSTEM);
95
     io.Fonts->TexID = bm;
105
     io.Fonts->TexID = bm;
96
 
106
 
107
+    gl::glGenBuffers(1, &vboHandle);
108
+    gl::glGenBuffers(1, &elementHandle);
109
+
97
     // Set up OpenRaider style
110
     // Set up OpenRaider style
111
+    /*
98
     ImGuiStyle& style = ImGui::GetStyle();
112
     ImGuiStyle& style = ImGui::GetStyle();
99
     style.Colors[ImGuiCol_Text]                 = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
113
     style.Colors[ImGuiCol_Text]                 = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
100
     style.Colors[ImGuiCol_WindowBg]             = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
114
     style.Colors[ImGuiCol_WindowBg]             = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
142
     style.TouchExtraPadding                     = ImVec2(0, 0);
156
     style.TouchExtraPadding                     = ImVec2(0, 0);
143
     style.IndentSpacing                         = 3;
157
     style.IndentSpacing                         = 3;
144
     style.ScrollbarWidth                        = 10;
158
     style.ScrollbarWidth                        = 10;
159
+    */
145
 
160
 
146
     return 0;
161
     return 0;
147
 }
162
 }
375
 
390
 
376
 void UI::shutdown() {
391
 void UI::shutdown() {
377
     ImGui::Shutdown();
392
     ImGui::Shutdown();
393
+
394
+    gl::glDeleteBuffers(1, &vboHandle);
395
+    gl::glDeleteBuffers(1, &elementHandle);
378
 }
396
 }
379
 
397
 
380
 void UI::handleKeyboard(KeyboardButton key, bool pressed) {
398
 void UI::handleKeyboard(KeyboardButton key, bool pressed) {
482
     }
500
     }
483
 }
501
 }
484
 
502
 
485
-void UI::renderImGui(ImDrawList** const cmd_lists, int cmd_lists_count) {
486
-    if (cmd_lists_count == 0)
503
+void UI::renderImGui(ImDrawData* draw_data) {
504
+    if (draw_data->CmdListsCount == 0)
487
         return;
505
         return;
488
 
506
 
489
-    static ShaderBuffer vert, uv, col;
490
-
491
     gl::glEnable(gl::GL_SCISSOR_TEST);
507
     gl::glEnable(gl::GL_SCISSOR_TEST);
492
     Shader::set2DState(true);
508
     Shader::set2DState(true);
493
 
509
 
510
+    gl::glEnableVertexAttribArray(attribPos);
511
+    gl::glEnableVertexAttribArray(attribUV);
512
+    gl::glEnableVertexAttribArray(attribCol);
513
+
514
+    gl::glBindBuffer(gl::GL_ARRAY_BUFFER, vboHandle);
515
+
516
+    gl::glVertexAttribPointer(attribPos, 2, gl::GL_FLOAT, gl::GL_FALSE, sizeof(ImDrawVert), OFFSETOF(ImDrawVert, pos));
517
+    gl::glVertexAttribPointer(attribUV, 2, gl::GL_FLOAT, gl::GL_FALSE, sizeof(ImDrawVert), OFFSETOF(ImDrawVert, uv));
518
+    gl::glVertexAttribPointer(attribCol, 4, gl::GL_UNSIGNED_BYTE, gl::GL_TRUE, sizeof(ImDrawVert), OFFSETOF(ImDrawVert, col));
519
+
494
     imguiShader.use();
520
     imguiShader.use();
495
     imguiShader.loadUniform(0, Window::getSize());
521
     imguiShader.loadUniform(0, Window::getSize());
496
-    vert.bindBuffer(0, 2);
497
-    uv.bindBuffer(1, 2);
498
-    col.bindBuffer(2, 4);
499
-
500
-    /*! \fixme Don't copy data
501
-     * The GL calls and the shaders can probably be slightly altered
502
-     * to avoid copying all the vertices, uvs and colors again here.
503
-     */
504
-
505
-    for (int i = 0; i < cmd_lists_count; i++) {
506
-        auto& commands = cmd_lists[i]->commands;
507
-        auto& buffer = cmd_lists[i]->vtx_buffer;
508
-
509
-        int offset = 0;
510
-        for (int n = 0; n < commands.size(); n++) {
511
-            std::vector<glm::vec2> vertices;
512
-            std::vector<glm::vec2> uvs;
513
-            std::vector<glm::vec4> colors;
514
-
515
-            for (int v = 0; v < commands[n].vtx_count; v++) {
516
-                vertices.push_back(glm::vec2(buffer[offset + v].pos.x, buffer[offset + v].pos.y));
517
-                uvs.push_back(glm::vec2(buffer[offset + v].uv.x, buffer[offset + v].uv.y));
518
-
519
-                float r, g, b, a;
520
-                a = ((buffer[offset + v].col & 0xFF000000) >> 24) / 255.0f;
521
-                b = ((buffer[offset + v].col & 0x00FF0000) >> 16) / 255.0f;
522
-                g = ((buffer[offset + v].col & 0x0000FF00) >> 8) / 255.0f;
523
-                r = (buffer[offset + v].col & 0x000000FF) / 255.0f;
524
-                colors.push_back(glm::vec4(r, g, b, a));
525
-            }
526
 
522
 
527
-            offset += commands[n].vtx_count;
523
+    for (int i = 0; i < draw_data->CmdListsCount; i++) {
524
+        const ImDrawList* cmd_list = draw_data->CmdLists[i];
525
+        const ImDrawIdx* idx_buffer_offset = 0;
528
 
526
 
529
-            vert.bufferData(vertices);
530
-            uv.bufferData(uvs);
531
-            col.bufferData(colors);
527
+        gl::glBindBuffer(gl::GL_ARRAY_BUFFER, vboHandle);
528
+        gl::glBufferData(gl::GL_ARRAY_BUFFER, cmd_list->VtxBuffer.size() * sizeof(ImDrawVert), &cmd_list->VtxBuffer.front(), gl::GL_STREAM_DRAW);
532
 
529
 
533
-            auto bm = static_cast<BufferManager*>(commands[n].texture_id);
534
-            orAssert(bm != nullptr);
535
-            imguiShader.loadUniform(1, bm->getTextureID(), bm->getTextureStorage());
530
+        gl::glBindBuffer(gl::GL_ELEMENT_ARRAY_BUFFER, elementHandle);
531
+        gl::glBufferData(gl::GL_ELEMENT_ARRAY_BUFFER, cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx), &cmd_list->IdxBuffer.front(), gl::GL_STREAM_DRAW);
536
 
532
 
537
-            gl::glScissor(commands[n].clip_rect.x,
538
-                      Window::getSize().y - commands[n].clip_rect.w,
539
-                      commands[n].clip_rect.z - commands[n].clip_rect.x,
540
-                      commands[n].clip_rect.w - commands[n].clip_rect.y);
533
+        for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != cmd_list->CmdBuffer.end(); pcmd++) {
534
+            if (pcmd->UserCallback) {
535
+                pcmd->UserCallback(cmd_list, pcmd);
536
+                Log::get(LOG_INFO) << "renderImGui: did not draw (Callback)" << Log::endl;
537
+            } else {
538
+                auto bm = static_cast<BufferManager*>(pcmd->TextureId);
539
+                orAssert(bm != nullptr);
540
+                imguiShader.loadUniform(1, bm->getTextureID(), bm->getTextureStorage());
541
+
542
+                gl::glScissor(pcmd->ClipRect.x,
543
+                              Window::getSize().y - pcmd->ClipRect.w,
544
+                              pcmd->ClipRect.z - pcmd->ClipRect.x,
545
+                              pcmd->ClipRect.w - pcmd->ClipRect.y);
541
 
546
 
542
-            gl::glDrawArrays(gl::GL_TRIANGLES, 0, vertices.size());
547
+                gl::glDrawElements(gl::GL_TRIANGLES, pcmd->ElemCount, gl::GL_UNSIGNED_SHORT, idx_buffer_offset);
548
+            }
549
+            idx_buffer_offset += pcmd->ElemCount;
543
         }
550
         }
544
     }
551
     }
545
 
552
 
546
-    vert.unbind(0);
547
-    uv.unbind(1);
548
-    col.unbind(2);
553
+    gl::glDisableVertexAttribArray(attribPos);
554
+    gl::glDisableVertexAttribArray(attribUV);
555
+    gl::glDisableVertexAttribArray(attribCol);
549
 
556
 
550
     Shader::set2DState(false);
557
     Shader::set2DState(false);
551
     gl::glDisable(gl::GL_SCISSOR_TEST);
558
     gl::glDisable(gl::GL_SCISSOR_TEST);

+ 4
- 6
src/deps/imgui/imconfig.h View File

6
 
6
 
7
 #pragma once
7
 #pragma once
8
 
8
 
9
-//---- Define your own ImVector<> type if you don't want to use the provided implementation defined in imgui.h
10
-//#include <vector>
11
-//#define ImVector  std::vector
12
-//#define ImVector  MyVector
13
-
14
 //---- Define assertion handler. Defaults to calling assert().
9
 //---- Define assertion handler. Defaults to calling assert().
15
 #include "global.h"
10
 #include "global.h"
16
-#define IM_ASSERT(_EXPR)  orAssert(_EXPR)
11
+#define IM_ASSERT(_EXPR) orAssert(_EXPR)
17
 
12
 
18
 //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
13
 //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
19
 //#define IMGUI_API __declspec( dllexport )
14
 //#define IMGUI_API __declspec( dllexport )
32
 //---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty)
27
 //---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty)
33
 //#define IMGUI_DISABLE_TEST_WINDOWS
28
 //#define IMGUI_DISABLE_TEST_WINDOWS
34
 
29
 
30
+//---- Don't define obsolete functions names
31
+//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
32
+
35
 //---- Implement STB libraries in a namespace to avoid conflicts
33
 //---- Implement STB libraries in a namespace to avoid conflicts
36
 //#define IMGUI_STB_NAMESPACE     ImStb
34
 //#define IMGUI_STB_NAMESPACE     ImStb
37
 
35
 

+ 4344
- 2418
src/deps/imgui/imgui.cpp
File diff suppressed because it is too large
View File


+ 449
- 251
src/deps/imgui/imgui.h
File diff suppressed because it is too large
View File


+ 7
- 0
src/deps/imgui/stb_textedit.h View File

1
+// [ImGui] this is a slightly modified version of stb_truetype.h 1.4
2
+// [ImGui] we made a fix for using the END key on multi-line text edit, see https://github.com/ocornut/imgui/issues/275
3
+
1
 // stb_textedit.h - v1.4  - public domain - Sean Barrett
4
 // stb_textedit.h - v1.4  - public domain - Sean Barrett
2
 // Development of this library was sponsored by RAD Game Tools
5
 // Development of this library was sponsored by RAD Game Tools
3
 //
6
 //
957
          stb_textedit_move_to_first(state);
960
          stb_textedit_move_to_first(state);
958
          stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
961
          stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
959
          state->cursor = find.first_char + find.length;
962
          state->cursor = find.first_char + find.length;
963
+         if (find.length > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) == STB_TEXTEDIT_NEWLINE)
964
+            state->cursor--;
960
          state->has_preferred_x = 0;
965
          state->has_preferred_x = 0;
961
          break;
966
          break;
962
       }
967
       }
977
          stb_textedit_prep_selection_at_cursor(state);
982
          stb_textedit_prep_selection_at_cursor(state);
978
          stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
983
          stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
979
          state->cursor = state->select_end = find.first_char + find.length;
984
          state->cursor = state->select_end = find.first_char + find.length;
985
+         if (find.length > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) == STB_TEXTEDIT_NEWLINE)
986
+            state->cursor = state->select_end = state->cursor - 1;
980
          state->has_preferred_x = 0;
987
          state->has_preferred_x = 0;
981
          break;
988
          break;
982
       }
989
       }

+ 710
- 147
src/deps/imgui/stb_truetype.h
File diff suppressed because it is too large
View File


+ 8
- 0
src/system/Shader.cpp View File

103
         gl::glDeleteProgram(programID);
103
         gl::glDeleteProgram(programID);
104
 }
104
 }
105
 
105
 
106
+int Shader::getAttrib(const char* name) {
107
+    orAssert(programID >= 0);
108
+    orAssert(name != nullptr);
109
+    orAssert(name[0] != '\0');
110
+    return gl::glGetAttribLocation(programID, name);
111
+}
112
+
106
 int Shader::addUniform(const char* name) {
113
 int Shader::addUniform(const char* name) {
107
     orAssert(programID >= 0);
114
     orAssert(programID >= 0);
108
     int r = gl::glGetUniformLocation(programID, name);
115
     int r = gl::glGetUniformLocation(programID, name);
261
     gl::glDepthFunc(gl::GL_LESS);
268
     gl::glDepthFunc(gl::GL_LESS);
262
 
269
 
263
     gl::glEnable(gl::GL_BLEND);
270
     gl::glEnable(gl::GL_BLEND);
271
+    gl::glBlendEquation(gl::GL_FUNC_ADD);
264
     gl::glBlendFunc(gl::GL_SRC_ALPHA, gl::GL_ONE_MINUS_SRC_ALPHA);
272
     gl::glBlendFunc(gl::GL_SRC_ALPHA, gl::GL_ONE_MINUS_SRC_ALPHA);
265
 
273
 
266
     gl::glPointSize(5.0f);
274
     gl::glPointSize(5.0f);

Loading…
Cancel
Save