Kaynağa Gözat

Updated ImGui

Thomas Buck 9 yıl önce
ebeveyn
işleme
44935e3e1d

+ 3
- 0
ChangeLog.md Dosyayı Görüntüle

@@ -2,6 +2,9 @@
2 2
 
3 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 8
     [ 20150429 ]
6 9
     * Fixed the new BoundingBox rendering approach
7 10
     * Fixed portal rendering method, no longer checking portals behind player.

+ 3
- 2
include/UI.h Dosyayı Görüntüle

@@ -17,7 +17,7 @@
17 17
 
18 18
 #include "system/Shader.h"
19 19
 
20
-struct ImDrawList;
20
+struct ImDrawData;
21 21
 
22 22
 class UI {
23 23
   public:
@@ -38,7 +38,7 @@ class UI {
38 38
     static void handleControllerAxis(float value, KeyboardButton axis);
39 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 43
   private:
44 44
     static bool visible;
@@ -55,6 +55,7 @@ class UI {
55 55
     static Shader imguiShader;
56 56
     static const char* imguiShaderVertex;
57 57
     static const char* imguiShaderFragment;
58
+    static unsigned int vboHandle, elementHandle;
58 59
 };
59 60
 
60 61
 #endif

+ 15
- 14
include/global.h Dosyayı Görüntüle

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

+ 2
- 0
include/system/Shader.h Dosyayı Görüntüle

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

+ 1
- 1
src/Console.cpp Dosyayı Görüntüle

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

+ 2
- 2
src/SoundManager.cpp Dosyayı Görüntüle

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

+ 8
- 8
src/TextureManager.cpp Dosyayı Görüntüle

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

+ 56
- 49
src/UI.cpp Dosyayı Görüntüle

@@ -26,12 +26,16 @@
26 26
 #include <glbinding/gl/gl.h>
27 27
 #include <glm/gtc/matrix_transform.hpp>
28 28
 
29
+#define OFFSETOF(TYPE, ELEMENT) (&(static_cast<TYPE *>(nullptr)->ELEMENT))
30
+
29 31
 Shader UI::imguiShader;
30 32
 bool UI::visible = false;
31 33
 unsigned int UI::fontTex;
32 34
 std::string UI::iniFilename;
33 35
 std::string UI::logFilename;
34 36
 bool UI::metaKeyIsActive = false;
37
+unsigned int UI::vboHandle = 0;
38
+unsigned int UI::elementHandle = 0;
35 39
 
36 40
 std::list<std::tuple<KeyboardButton, bool>> UI::keyboardEvents;
37 41
 std::list<std::tuple<unsigned int, unsigned int, KeyboardButton, bool>> UI::clickEvents;
@@ -43,6 +47,8 @@ void UI::setSize(glm::i32vec2 s) {
43 47
     io.DisplaySize = ImVec2(s.x, s.y);
44 48
 }
45 49
 
50
+static int attribPos, attribUV, attribCol;
51
+
46 52
 int UI::initialize() {
47 53
     if (imguiShader.compile(imguiShaderVertex, imguiShaderFragment) < 0)
48 54
         return -1;
@@ -51,6 +57,10 @@ int UI::initialize() {
51 57
     if (imguiShader.addUniform("textureSampler") < 0)
52 58
         return -3;
53 59
 
60
+    attribPos = imguiShader.getAttrib("vertexPosition_screen");
61
+    attribUV = imguiShader.getAttrib("vertexUV");
62
+    attribCol = imguiShader.getAttrib("vertexColor");
63
+
54 64
     iniFilename = RunTime::getBaseDir() + "/imgui.ini";
55 65
     logFilename = RunTime::getBaseDir() + "/imgui_log.txt";
56 66
 
@@ -94,7 +104,11 @@ int UI::initialize() {
94 104
     auto bm = TextureManager::getBufferManager(fontTex, TextureStorage::SYSTEM);
95 105
     io.Fonts->TexID = bm;
96 106
 
107
+    gl::glGenBuffers(1, &vboHandle);
108
+    gl::glGenBuffers(1, &elementHandle);
109
+
97 110
     // Set up OpenRaider style
111
+    /*
98 112
     ImGuiStyle& style = ImGui::GetStyle();
99 113
     style.Colors[ImGuiCol_Text]                 = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
100 114
     style.Colors[ImGuiCol_WindowBg]             = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
@@ -142,6 +156,7 @@ int UI::initialize() {
142 156
     style.TouchExtraPadding                     = ImVec2(0, 0);
143 157
     style.IndentSpacing                         = 3;
144 158
     style.ScrollbarWidth                        = 10;
159
+    */
145 160
 
146 161
     return 0;
147 162
 }
@@ -375,6 +390,9 @@ void UI::display() {
375 390
 
376 391
 void UI::shutdown() {
377 392
     ImGui::Shutdown();
393
+
394
+    gl::glDeleteBuffers(1, &vboHandle);
395
+    gl::glDeleteBuffers(1, &elementHandle);
378 396
 }
379 397
 
380 398
 void UI::handleKeyboard(KeyboardButton key, bool pressed) {
@@ -482,70 +500,59 @@ void UI::handleControllerButton(KeyboardButton button, bool released) {
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 505
         return;
488 506
 
489
-    static ShaderBuffer vert, uv, col;
490
-
491 507
     gl::glEnable(gl::GL_SCISSOR_TEST);
492 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 520
     imguiShader.use();
495 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 557
     Shader::set2DState(false);
551 558
     gl::glDisable(gl::GL_SCISSOR_TEST);

+ 4
- 6
src/deps/imgui/imconfig.h Dosyayı Görüntüle

@@ -6,14 +6,9 @@
6 6
 
7 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 9
 //---- Define assertion handler. Defaults to calling assert().
15 10
 #include "global.h"
16
-#define IM_ASSERT(_EXPR)  orAssert(_EXPR)
11
+#define IM_ASSERT(_EXPR) orAssert(_EXPR)
17 12
 
18 13
 //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
19 14
 //#define IMGUI_API __declspec( dllexport )
@@ -32,6 +27,9 @@
32 27
 //---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty)
33 28
 //#define IMGUI_DISABLE_TEST_WINDOWS
34 29
 
30
+//---- Don't define obsolete functions names
31
+//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
32
+
35 33
 //---- Implement STB libraries in a namespace to avoid conflicts
36 34
 //#define IMGUI_STB_NAMESPACE     ImStb
37 35
 

+ 4344
- 2418
src/deps/imgui/imgui.cpp
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 449
- 251
src/deps/imgui/imgui.h
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 7
- 0
src/deps/imgui/stb_textedit.h Dosyayı Görüntüle

@@ -1,3 +1,6 @@
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 4
 // stb_textedit.h - v1.4  - public domain - Sean Barrett
2 5
 // Development of this library was sponsored by RAD Game Tools
3 6
 //
@@ -957,6 +960,8 @@ retry:
957 960
          stb_textedit_move_to_first(state);
958 961
          stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
959 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 965
          state->has_preferred_x = 0;
961 966
          break;
962 967
       }
@@ -977,6 +982,8 @@ retry:
977 982
          stb_textedit_prep_selection_at_cursor(state);
978 983
          stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
979 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 987
          state->has_preferred_x = 0;
981 988
          break;
982 989
       }

+ 710
- 147
src/deps/imgui/stb_truetype.h
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 8
- 0
src/system/Shader.cpp Dosyayı Görüntüle

@@ -103,6 +103,13 @@ Shader::~Shader() {
103 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 113
 int Shader::addUniform(const char* name) {
107 114
     orAssert(programID >= 0);
108 115
     int r = gl::glGetUniformLocation(programID, name);
@@ -261,6 +268,7 @@ int Shader::initialize() {
261 268
     gl::glDepthFunc(gl::GL_LESS);
262 269
 
263 270
     gl::glEnable(gl::GL_BLEND);
271
+    gl::glBlendEquation(gl::GL_FUNC_ADD);
264 272
     gl::glBlendFunc(gl::GL_SRC_ALPHA, gl::GL_ONE_MINUS_SRC_ALPHA);
265 273
 
266 274
     gl::glPointSize(5.0f);

Loading…
İptal
Kaydet