Browse Source

Imgui update, controller & camera movement improvements.

Thomas Buck 9 years ago
parent
commit
9dd7432bfd

+ 6
- 0
ChangeLog.md View File

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4
 
4
 
5
+    [ 20140211 ]
6
+    * Updated imgui to version 1.32
7
+    * Included some SDL game controller configurations
8
+    * Camera movement speed is now clamped when moving in multiple directions
9
+    * Slightly increased controller dead-zone, now 0.2
10
+
5
     [ 20140204 ]
11
     [ 20140204 ]
6
     * Return of textile, animated textile and sprite viewer, in TextureManager
12
     * Return of textile, animated textile and sprite viewer, in TextureManager
7
 
13
 

+ 1
- 1
include/Console.h View File

21
     static void setVisible(bool v) { visible = v; }
21
     static void setVisible(bool v) { visible = v; }
22
 
22
 
23
   private:
23
   private:
24
-    static void callback(ImGuiTextEditCallbackData* data);
24
+    static int callback(ImGuiTextEditCallbackData* data);
25
 
25
 
26
     const static int bufferLength = 256;
26
     const static int bufferLength = 256;
27
 
27
 

+ 1
- 1
include/Entity.h View File

12
   public:
12
   public:
13
     Entity(int i, int r, glm::vec3 po, glm::vec3 ro)
13
     Entity(int i, int r, glm::vec3 po, glm::vec3 ro)
14
         : id(i), room(r), pos(po), rot(ro), cache(-1), cacheType(-1),
14
         : id(i), room(r), pos(po), rot(ro), cache(-1), cacheType(-1),
15
-        sprite(0), animation(0), frame(0) { }
15
+          sprite(0), animation(0), frame(0) { }
16
     void display(glm::mat4 VP);
16
     void display(glm::mat4 VP);
17
 
17
 
18
     int getID() { return id; }
18
     int getID() { return id; }

+ 7
- 2
src/Camera.cpp View File

38
 const static float farDist = 75000.0f;
38
 const static float farDist = 75000.0f;
39
 const static float maxSpeed = 3072.0f;
39
 const static float maxSpeed = 3072.0f;
40
 const static float controllerViewFactor = glm::pi<float>();
40
 const static float controllerViewFactor = glm::pi<float>();
41
-const static float controllerDeadZone = 0.1f;
41
+const static float controllerDeadZone = 0.2f;
42
 
42
 
43
 const static glm::vec3 rightUnit(1.0f, 0.0f, 0.0f);
43
 const static glm::vec3 rightUnit(1.0f, 0.0f, 0.0f);
44
 const static glm::vec3 upUnit(0.0f, 1.0f, 0.0f);
44
 const static glm::vec3 upUnit(0.0f, 1.0f, 0.0f);
183
     glm::quat quatX = glm::angleAxis(rot.y, glm::vec3(1.0f, 0.0f, 0.0f));
183
     glm::quat quatX = glm::angleAxis(rot.y, glm::vec3(1.0f, 0.0f, 0.0f));
184
     glm::quat quaternion = quatY * quatX;
184
     glm::quat quaternion = quatY * quatX;
185
 
185
 
186
-    pos += quaternion * posSpeed * dT;
186
+    glm::vec3 clampedSpeed(posSpeed);
187
+    if (glm::length(clampedSpeed) > maxSpeed) {
188
+        clampedSpeed = glm::normalize(clampedSpeed) * maxSpeed;
189
+    }
190
+
191
+    pos += quaternion * clampedSpeed * dT;
187
 
192
 
188
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), pos);
193
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), pos);
189
     glm::mat4 rotate = glm::toMat4(quaternion);
194
     glm::mat4 rotate = glm::toMat4(quaternion);

+ 4
- 2
src/Console.cpp View File

21
 long Console::lastCommandIndex = -1;
21
 long Console::lastCommandIndex = -1;
22
 std::string Console::bufferedCommand;
22
 std::string Console::bufferedCommand;
23
 
23
 
24
-void Console::callback(ImGuiTextEditCallbackData* data) {
24
+int Console::callback(ImGuiTextEditCallbackData* data) {
25
     bool update = false;
25
     bool update = false;
26
     std::string completion;
26
     std::string completion;
27
 
27
 
66
 
66
 
67
         data->CursorPos = strlen(data->Buf);
67
         data->CursorPos = strlen(data->Buf);
68
     }
68
     }
69
+
70
+    return 0;
69
 }
71
 }
70
 
72
 
71
 void Console::display() {
73
 void Console::display() {
98
         if (ImGui::Button("Log to File")) { logToFile = true; }
100
         if (ImGui::Button("Log to File")) { logToFile = true; }
99
         ImGui::Separator();
101
         ImGui::Separator();
100
 
102
 
101
-        ImGui::BeginChild("ConsoleText", ImVec2(0, -ImGui::GetTextLineSpacing() * 2));
103
+        ImGui::BeginChild("ConsoleText", ImVec2(0, -ImGui::GetTextLineHeightWithSpacing() * 2));
102
         if (logToTTY)
104
         if (logToTTY)
103
             ImGui::LogToTTY();
105
             ImGui::LogToTTY();
104
         else if (logToClipboard)
106
         else if (logToClipboard)

+ 2
- 1
src/RoomData.cpp View File

86
 
86
 
87
 void RoomSprite::display(glm::mat4 VP) {
87
 void RoomSprite::display(glm::mat4 VP) {
88
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));
88
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));
89
-    glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), Camera::getRotation().x, glm::vec3(0.0f, 1.0f, 0.0f));
89
+    glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), Camera::getRotation().x, glm::vec3(0.0f, 1.0f,
90
+                                   0.0f));
90
     glm::mat4 model = translate * rotate;
91
     glm::mat4 model = translate * rotate;
91
 
92
 
92
     getWorld().getSprite(sprite).display(VP * model);
93
     getWorld().getSprite(sprite).display(VP * model);

+ 26
- 26
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
+glm::vec2 TextureTile::getUV(unsigned int i) {
25
+    glm::vec2 uv(vertices.at(i).xPixel,
26
+                 vertices.at(i).yPixel);
27
+
28
+    /*! \fixme
29
+     * This is my somewhat hacky approach to fixing
30
+     * the bad texture-bleeding problems everywhere.
31
+     * That's better, but makes the seams between
32
+     * each sector much more visible!
33
+     */
34
+
35
+    if (vertices.at(i).xCoordinate == 1) {
36
+        uv.x += 0.375f;
37
+    }
38
+
39
+    if (vertices.at(i).yCoordinate == 1) {
40
+        uv.y += 0.375f;
41
+    }
42
+
43
+    return uv / 256.0f;
44
+}
45
+
46
+// ----------------------------------------------------------------------------
47
+
24
 std::vector<unsigned int> TextureManager::mTextureIdsGame;
48
 std::vector<unsigned int> TextureManager::mTextureIdsGame;
25
 std::vector<unsigned int> TextureManager::mTextureIdsSystem;
49
 std::vector<unsigned int> TextureManager::mTextureIdsSystem;
26
 std::vector<TextureTile*> TextureManager::tiles;
50
 std::vector<TextureTile*> TextureManager::tiles;
354
         }
378
         }
355
 
379
 
356
         auto bm = getBufferManager(index, game ? TextureStorage::GAME
380
         auto bm = getBufferManager(index, game ? TextureStorage::GAME
357
-                                                            : TextureStorage::SYSTEM);
381
+                                   : TextureStorage::SYSTEM);
358
         ImGui::Image(bm, ImVec2(ImGui::GetColumnWidth() * 2 / 3, ImGui::GetColumnWidth() * 2 / 3));
382
         ImGui::Image(bm, ImVec2(ImGui::GetColumnWidth() * 2 / 3, ImGui::GetColumnWidth() * 2 / 3));
359
     }
383
     }
360
 
384
 
446
             if (fr > 0) {
470
             if (fr > 0) {
447
                 fr--;
471
                 fr--;
448
             } else {
472
             } else {
449
-                fr = RunTime::getFPS() / 2;
473
+                fr = RunTime::getFPS() / 5;
450
                 tile = next;
474
                 tile = next;
451
             }
475
             }
452
         } else {
476
         } else {
515
     }
539
     }
516
 }
540
 }
517
 
541
 
518
-// ----------------------------------------------------------------------------
519
-
520
-glm::vec2 TextureTile::getUV(unsigned int i) {
521
-    glm::vec2 uv(vertices.at(i).xPixel,
522
-                 vertices.at(i).yPixel);
523
-
524
-    /*! \fixme
525
-     * This is my somewhat hacky approach to fixing
526
-     * the bad texture-bleeding problems everywhere.
527
-     * That's better, but makes the seams between
528
-     * each sector much more visible!
529
-     */
530
-
531
-    if (vertices.at(i).xCoordinate == 1) {
532
-        uv.x += 0.375f;
533
-    }
534
-
535
-    if (vertices.at(i).yCoordinate == 1) {
536
-        uv.y += 0.375f;
537
-    }
538
-
539
-    return uv / 256.0f;
540
-}
541
-

+ 1
- 1
src/UI.cpp View File

84
     int width, height;
84
     int width, height;
85
     io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
85
     io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
86
     fontTex = TextureManager::loadBufferSlot(pixels, width, height, ColorMode::RGBA, 32,
86
     fontTex = TextureManager::loadBufferSlot(pixels, width, height, ColorMode::RGBA, 32,
87
-                                             TextureStorage::SYSTEM, -1, false);
87
+              TextureStorage::SYSTEM, -1, false);
88
     auto bm = TextureManager::getBufferManager(fontTex, TextureStorage::SYSTEM);
88
     auto bm = TextureManager::getBufferManager(fontTex, TextureStorage::SYSTEM);
89
     io.Fonts->TexID = bm;
89
     io.Fonts->TexID = bm;
90
 
90
 

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


+ 78
- 42
src/deps/imgui/imgui.h View File

1
-// ImGui library v1.31 wip
2
-// See .cpp file for commentary.
1
+// ImGui library v1.32
2
+// See .cpp file for documentation.
3
 // See ImGui::ShowTestWindow() for sample code.
3
 // See ImGui::ShowTestWindow() for sample code.
4
 // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
4
 // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
5
 // Get latest version at https://github.com/ocornut/imgui
5
 // Get latest version at https://github.com/ocornut/imgui
44
 typedef int ImGuiSetCondition;      // enum ImGuiSetCondition_
44
 typedef int ImGuiSetCondition;      // enum ImGuiSetCondition_
45
 typedef int ImGuiInputTextFlags;    // enum ImGuiInputTextFlags_
45
 typedef int ImGuiInputTextFlags;    // enum ImGuiInputTextFlags_
46
 struct ImGuiTextEditCallbackData;   // for advanced uses of InputText() 
46
 struct ImGuiTextEditCallbackData;   // for advanced uses of InputText() 
47
+typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
47
 
48
 
48
 struct ImVec2
49
 struct ImVec2
49
 {
50
 {
159
     IMGUI_API bool          Begin(const char* name = "Debug", bool* p_opened = NULL, ImVec2 size = ImVec2(0,0), float fill_alpha = -1.0f, ImGuiWindowFlags flags = 0);// return false when window is collapsed, so you can early out in your code. passing 'bool* p_opened' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
160
     IMGUI_API bool          Begin(const char* name = "Debug", bool* p_opened = NULL, ImVec2 size = ImVec2(0,0), float fill_alpha = -1.0f, ImGuiWindowFlags flags = 0);// return false when window is collapsed, so you can early out in your code. passing 'bool* p_opened' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
160
     IMGUI_API void          End();
161
     IMGUI_API void          End();
161
     IMGUI_API void          BeginChild(const char* str_id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);                         // size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). on each axis.
162
     IMGUI_API void          BeginChild(const char* str_id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);                         // size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). on each axis.
163
+    IMGUI_API void          BeginChild(ImGuiID id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);                                 // "
162
     IMGUI_API void          EndChild();
164
     IMGUI_API void          EndChild();
163
     IMGUI_API bool          GetWindowIsFocused();
165
     IMGUI_API bool          GetWindowIsFocused();
164
-    IMGUI_API ImVec2        GetContentRegionMax();                                              // window or current column boundaries
165
-    IMGUI_API ImVec2        GetWindowContentRegionMin();                                        // window boundaries
166
+    IMGUI_API ImVec2        GetContentRegionMax();                                              // window or current column boundaries, in windows coordinates
167
+    IMGUI_API ImVec2        GetWindowContentRegionMin();                                        // window boundaries, in windows coordinates
166
     IMGUI_API ImVec2        GetWindowContentRegionMax();
168
     IMGUI_API ImVec2        GetWindowContentRegionMax();
167
     IMGUI_API ImDrawList*   GetWindowDrawList();                                                // get rendering command-list if you want to append your own draw primitives.
169
     IMGUI_API ImDrawList*   GetWindowDrawList();                                                // get rendering command-list if you want to append your own draw primitives.
168
     IMGUI_API ImFont*       GetWindowFont();
170
     IMGUI_API ImFont*       GetWindowFont();
169
-    IMGUI_API float         GetWindowFontSize();
171
+    IMGUI_API float         GetWindowFontSize();                                                // size (also height in pixels) of current font with current scale applied
170
     IMGUI_API void          SetWindowFontScale(float scale);                                    // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows.
172
     IMGUI_API void          SetWindowFontScale(float scale);                                    // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows.
171
     IMGUI_API ImVec2        GetWindowPos();                                                     // you should rarely need/care about the window position, but it can be useful if you want to do your own drawing.
173
     IMGUI_API ImVec2        GetWindowPos();                                                     // you should rarely need/care about the window position, but it can be useful if you want to do your own drawing.
172
     IMGUI_API ImVec2        GetWindowSize();                                                    // get current window position.
174
     IMGUI_API ImVec2        GetWindowSize();                                                    // get current window position.
173
     IMGUI_API float         GetWindowWidth();
175
     IMGUI_API float         GetWindowWidth();
174
     IMGUI_API bool          GetWindowCollapsed();
176
     IMGUI_API bool          GetWindowCollapsed();
175
-    IMGUI_API void          SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0);        // set current window position - call within Begin()/End().
176
-    IMGUI_API void          SetWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0);      // set current window size. set to ImVec2(0,0) to force an auto-fit
177
-    IMGUI_API void          SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0);     // set current window collapsed state.
178
     IMGUI_API void          SetNextWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0);    // set next window position - call before Begin().
177
     IMGUI_API void          SetNextWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0);    // set next window position - call before Begin().
179
-    IMGUI_API void          SetNextWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0);  // set next window size. set to ImVec2(0,0) to force an auto-fit
178
+    IMGUI_API void          SetNextWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0);  // set next window size. set to ImVec2(0,0) to force an auto-fit.
180
     IMGUI_API void          SetNextWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0); // set next window collapsed state.
179
     IMGUI_API void          SetNextWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0); // set next window collapsed state.
180
+    IMGUI_API void          SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0);        // set current window position - call within Begin()/End(). may incur tearing.
181
+    IMGUI_API void          SetWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0);      // set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing.
182
+    IMGUI_API void          SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0);     // set current window collapsed state.
181
 
183
 
182
     IMGUI_API void          SetScrollPosHere();                                                 // adjust scrolling position to center into the current cursor position.
184
     IMGUI_API void          SetScrollPosHere();                                                 // adjust scrolling position to center into the current cursor position.
183
     IMGUI_API void          SetKeyboardFocusHere(int offset = 0);                               // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget.
185
     IMGUI_API void          SetKeyboardFocusHere(int offset = 0);                               // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget.
194
     IMGUI_API void          PopStyleVar(int count = 1);
196
     IMGUI_API void          PopStyleVar(int count = 1);
195
 
197
 
196
     // Parameters stacks (current window)
198
     // Parameters stacks (current window)
197
-    IMGUI_API void          PushItemWidth(float item_width);                                    // width of items for the common item+label case. default to ~2/3 of windows width.
199
+    IMGUI_API void          PushItemWidth(float item_width);                                    // width of items for the common item+label case, pixels. 0.0f = default to ~2/3 of windows width, >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -0.01f always align width to the right side)
198
     IMGUI_API void          PopItemWidth();
200
     IMGUI_API void          PopItemWidth();
199
-    IMGUI_API float         GetItemWidth();
201
+    IMGUI_API float         CalcItemWidth();                                                    // width of item given pushed settings and current cursor position
200
     IMGUI_API void          PushAllowKeyboardFocus(bool v);                                     // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets.
202
     IMGUI_API void          PushAllowKeyboardFocus(bool v);                                     // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets.
201
     IMGUI_API void          PopAllowKeyboardFocus();
203
     IMGUI_API void          PopAllowKeyboardFocus();
202
     IMGUI_API void          PushTextWrapPos(float wrap_pos_x = 0.0f);                           // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space.
204
     IMGUI_API void          PushTextWrapPos(float wrap_pos_x = 0.0f);                           // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space.
218
     IMGUI_API void          SetColumnOffset(int column_index, float offset);
220
     IMGUI_API void          SetColumnOffset(int column_index, float offset);
219
     IMGUI_API float         GetColumnWidth(int column_index = -1);
221
     IMGUI_API float         GetColumnWidth(int column_index = -1);
220
     IMGUI_API ImVec2        GetCursorPos();                                                     // cursor position is relative to window position
222
     IMGUI_API ImVec2        GetCursorPos();                                                     // cursor position is relative to window position
223
+    IMGUI_API float         GetCursorPosX();                                                    // "
224
+    IMGUI_API float         GetCursorPosY();                                                    // "
221
     IMGUI_API void          SetCursorPos(const ImVec2& pos);                                    // "
225
     IMGUI_API void          SetCursorPos(const ImVec2& pos);                                    // "
222
     IMGUI_API void          SetCursorPosX(float x);                                             // "
226
     IMGUI_API void          SetCursorPosX(float x);                                             // "
223
     IMGUI_API void          SetCursorPosY(float y);                                             // "
227
     IMGUI_API void          SetCursorPosY(float y);                                             // "
224
     IMGUI_API ImVec2        GetCursorScreenPos();                                               // cursor position in absolute screen coordinates (0..io.DisplaySize)
228
     IMGUI_API ImVec2        GetCursorScreenPos();                                               // cursor position in absolute screen coordinates (0..io.DisplaySize)
225
     IMGUI_API void          SetCursorScreenPos(const ImVec2& pos);                              // cursor position in absolute screen coordinates (0..io.DisplaySize)
229
     IMGUI_API void          SetCursorScreenPos(const ImVec2& pos);                              // cursor position in absolute screen coordinates (0..io.DisplaySize)
226
     IMGUI_API void          AlignFirstTextHeightToWidgets();                                    // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets.
230
     IMGUI_API void          AlignFirstTextHeightToWidgets();                                    // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets.
227
-    IMGUI_API float         GetTextLineSpacing();
228
-    IMGUI_API float         GetTextLineHeight();
231
+    IMGUI_API float         GetTextLineHeight();                                                // height of font == GetWindowFontSize()
232
+    IMGUI_API float         GetTextLineHeightWithSpacing();                                     // spacing (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y
229
 
233
 
230
     // ID scopes
234
     // ID scopes
231
     // If you are creating repeated widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them.
235
     // If you are creating repeated widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them.
253
     IMGUI_API bool          SmallButton(const char* label);
257
     IMGUI_API bool          SmallButton(const char* label);
254
     IMGUI_API bool          InvisibleButton(const char* str_id, const ImVec2& size);
258
     IMGUI_API bool          InvisibleButton(const char* str_id, const ImVec2& size);
255
     IMGUI_API void          Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
259
     IMGUI_API void          Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
256
-    IMGUI_API bool          ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0),  const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,1));    // <0 frame_padding uses default frame padding settings. 0 for no paddnig.
260
+    IMGUI_API bool          ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0),  const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,1), const ImVec4& tint_col = ImVec4(1,1,1,1));    // <0 frame_padding uses default frame padding settings. 0 for no paddnig.
257
     IMGUI_API bool          CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
261
     IMGUI_API bool          CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
258
     IMGUI_API bool          SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);     // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.
262
     IMGUI_API bool          SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);     // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.
259
     IMGUI_API bool          SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
263
     IMGUI_API bool          SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
272
     IMGUI_API bool          CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
276
     IMGUI_API bool          CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
273
     IMGUI_API bool          RadioButton(const char* label, bool active);
277
     IMGUI_API bool          RadioButton(const char* label, bool active);
274
     IMGUI_API bool          RadioButton(const char* label, int* v, int v_button);
278
     IMGUI_API bool          RadioButton(const char* label, int* v, int v_button);
275
-    IMGUI_API bool          InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, void (*callback)(ImGuiTextEditCallbackData*) = NULL, void* user_data = NULL);
279
+    IMGUI_API bool          InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);
276
     IMGUI_API bool          InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
280
     IMGUI_API bool          InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
277
     IMGUI_API bool          InputFloat2(const char* label, float v[2], int decimal_precision = -1);
281
     IMGUI_API bool          InputFloat2(const char* label, float v[2], int decimal_precision = -1);
278
     IMGUI_API bool          InputFloat3(const char* label, float v[3], int decimal_precision = -1);
282
     IMGUI_API bool          InputFloat3(const char* label, float v[3], int decimal_precision = -1);
279
     IMGUI_API bool          InputFloat4(const char* label, float v[4], int decimal_precision = -1);
283
     IMGUI_API bool          InputFloat4(const char* label, float v[4], int decimal_precision = -1);
280
     IMGUI_API bool          InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0);
284
     IMGUI_API bool          InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0);
281
-    IMGUI_API bool          Combo(const char* label, int* current_item, const char** items, int items_count, int popup_height_items = 7);
282
-    IMGUI_API bool          Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_height_items = 7);      // separate items with \0, end item-list with \0\0
283
-    IMGUI_API bool          Combo(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_height_items = 7);
285
+    IMGUI_API bool          Combo(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
286
+    IMGUI_API bool          Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items = -1);      // separate items with \0, end item-list with \0\0
287
+    IMGUI_API bool          Combo(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
284
     IMGUI_API bool          ColorButton(const ImVec4& col, bool small_height = false, bool outline_border = true);
288
     IMGUI_API bool          ColorButton(const ImVec4& col, bool small_height = false, bool outline_border = true);
285
     IMGUI_API bool          ColorEdit3(const char* label, float col[3]);
289
     IMGUI_API bool          ColorEdit3(const char* label, float col[3]);
286
     IMGUI_API bool          ColorEdit4(const char* label, float col[4], bool show_alpha = true);
290
     IMGUI_API bool          ColorEdit4(const char* label, float col[4], bool show_alpha = true);
295
     IMGUI_API void          TreePop();
299
     IMGUI_API void          TreePop();
296
     IMGUI_API void          OpenNextNode(bool open);                                            // force open/close the next TreeNode or CollapsingHeader
300
     IMGUI_API void          OpenNextNode(bool open);                                            // force open/close the next TreeNode or CollapsingHeader
297
 
301
 
302
+    // Selectable / Lists
303
+    IMGUI_API bool          Selectable(const char* label, bool selected, const ImVec2& size = ImVec2(0,0));
304
+    IMGUI_API bool          Selectable(const char* label, bool* p_selected, const ImVec2& size = ImVec2(0,0));
305
+    IMGUI_API bool          ListBox(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
306
+    IMGUI_API bool          ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
307
+    IMGUI_API bool          ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); // use if you want to reimplement ListBox() will custom data or interactions. make sure to call ListBoxFooter() afterwards.
308
+    IMGUI_API bool          ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // "
309
+    IMGUI_API void          ListBoxFooter();                                                    // terminate the scrolling region
310
+
298
     // Value() Helpers: output single value in "name: value" format. Tip: freely declare your own within the ImGui namespace!
311
     // Value() Helpers: output single value in "name: value" format. Tip: freely declare your own within the ImGui namespace!
299
     IMGUI_API void          Value(const char* prefix, bool b);
312
     IMGUI_API void          Value(const char* prefix, bool b);
300
     IMGUI_API void          Value(const char* prefix, int v);
313
     IMGUI_API void          Value(const char* prefix, int v);
329
     IMGUI_API int           GetFrameCount();
342
     IMGUI_API int           GetFrameCount();
330
     IMGUI_API const char*   GetStyleColName(ImGuiCol idx);
343
     IMGUI_API const char*   GetStyleColName(ImGuiCol idx);
331
     IMGUI_API ImVec2        CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
344
     IMGUI_API ImVec2        CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
345
+    IMGUI_API void          CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end);    // helper to manually clip large list of items. see comments in implementation.
346
+
347
+    IMGUI_API void          BeginChildFrame(ImGuiID id, const ImVec2& size);                    // helper to create a child window / scrolling region that looks like a normal widget frame.
348
+    IMGUI_API void          EndChildFrame();
332
 
349
 
333
     IMGUI_API ImU32         ColorConvertFloat4ToU32(const ImVec4& in);
350
     IMGUI_API ImU32         ColorConvertFloat4ToU32(const ImVec4& in);
334
     IMGUI_API void          ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
351
     IMGUI_API void          ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
335
     IMGUI_API void          ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
352
     IMGUI_API void          ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
336
 
353
 
354
+    // Internal state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself
355
+    IMGUI_API void*         GetInternalState();
356
+    IMGUI_API size_t        GetInternalStateSize();
357
+    IMGUI_API void          SetInternalState(void* state, bool construct = false);
358
+
337
     // Obsolete (will be removed)
359
     // Obsolete (will be removed)
338
     IMGUI_API void          GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
360
     IMGUI_API void          GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
339
 
361
 
366
     // Default: 0
388
     // Default: 0
367
     ImGuiInputTextFlags_CharsDecimal        = 1 << 0,   // Allow 0123456789.+-*/
389
     ImGuiInputTextFlags_CharsDecimal        = 1 << 0,   // Allow 0123456789.+-*/
368
     ImGuiInputTextFlags_CharsHexadecimal    = 1 << 1,   // Allow 0123456789ABCDEFabcdef
390
     ImGuiInputTextFlags_CharsHexadecimal    = 1 << 1,   // Allow 0123456789ABCDEFabcdef
369
-    ImGuiInputTextFlags_AutoSelectAll       = 1 << 2,   // Select entire text when first taking focus
370
-    ImGuiInputTextFlags_EnterReturnsTrue    = 1 << 3,   // Return 'true' when Enter is pressed (as opposed to when the value was modified)
371
-    ImGuiInputTextFlags_CallbackCompletion  = 1 << 4,   // Call user function on pressing TAB (for completion handling)
372
-    ImGuiInputTextFlags_CallbackHistory     = 1 << 5,   // Call user function on pressing Up/Down arrows (for history handling)
373
-    ImGuiInputTextFlags_CallbackAlways      = 1 << 6    // Call user function every time
391
+    ImGuiInputTextFlags_CharsUppercase      = 1 << 2,   // Turn a..z into A..Z
392
+    ImGuiInputTextFlags_CharsNoBlank        = 1 << 3,   // Filter out spaces, tabs
393
+    ImGuiInputTextFlags_AutoSelectAll       = 1 << 4,   // Select entire text when first taking focus
394
+    ImGuiInputTextFlags_EnterReturnsTrue    = 1 << 5,   // Return 'true' when Enter is pressed (as opposed to when the value was modified)
395
+    ImGuiInputTextFlags_CallbackCompletion  = 1 << 6,   // Call user function on pressing TAB (for completion handling)
396
+    ImGuiInputTextFlags_CallbackHistory     = 1 << 7,   // Call user function on pressing Up/Down arrows (for history handling)
397
+    ImGuiInputTextFlags_CallbackAlways      = 1 << 8,   // Call user function every time
398
+    ImGuiInputTextFlags_CallbackCharFilter  = 1 << 9    // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
374
     //ImGuiInputTextFlags_AlignCenter       = 1 << 6,
399
     //ImGuiInputTextFlags_AlignCenter       = 1 << 6,
375
 };
400
 };
376
 
401
 
402
 {
427
 {
403
     ImGuiCol_Text,
428
     ImGuiCol_Text,
404
     ImGuiCol_WindowBg,
429
     ImGuiCol_WindowBg,
430
+    ImGuiCol_ChildWindowBg,
405
     ImGuiCol_Border,
431
     ImGuiCol_Border,
406
     ImGuiCol_BorderShadow,
432
     ImGuiCol_BorderShadow,
407
     ImGuiCol_FrameBg,               // Background of checkbox, radio button, plot, slider, text input
433
     ImGuiCol_FrameBg,               // Background of checkbox, radio button, plot, slider, text input
445
 // NB: the enum only refers to fields of ImGuiStyle() which makes sense to be pushed/poped in UI code. Feel free to add others.
471
 // NB: the enum only refers to fields of ImGuiStyle() which makes sense to be pushed/poped in UI code. Feel free to add others.
446
 enum ImGuiStyleVar_
472
 enum ImGuiStyleVar_
447
 {
473
 {
448
-    ImGuiStyleVar_Alpha,             // float
449
-    ImGuiStyleVar_WindowPadding,     // ImVec2
450
-    ImGuiStyleVar_WindowRounding,    // float
451
-    ImGuiStyleVar_FramePadding,      // ImVec2
452
-    ImGuiStyleVar_FrameRounding,     // float
453
-    ImGuiStyleVar_ItemSpacing,       // ImVec2
454
-    ImGuiStyleVar_ItemInnerSpacing,  // ImVec2
455
-    ImGuiStyleVar_TreeNodeSpacing    // float
474
+    ImGuiStyleVar_Alpha,               // float
475
+    ImGuiStyleVar_WindowPadding,       // ImVec2
476
+    ImGuiStyleVar_WindowRounding,      // float
477
+    ImGuiStyleVar_ChildWindowRounding, // float
478
+    ImGuiStyleVar_FramePadding,        // ImVec2
479
+    ImGuiStyleVar_FrameRounding,       // float
480
+    ImGuiStyleVar_ItemSpacing,         // ImVec2
481
+    ImGuiStyleVar_ItemInnerSpacing,    // ImVec2
482
+    ImGuiStyleVar_TreeNodeSpacing      // float
456
 };
483
 };
457
 
484
 
458
 // Enumeration for ColorEditMode()
485
 // Enumeration for ColorEditMode()
480
     ImVec2      WindowPadding;              // Padding within a window
507
     ImVec2      WindowPadding;              // Padding within a window
481
     ImVec2      WindowMinSize;              // Minimum window size
508
     ImVec2      WindowMinSize;              // Minimum window size
482
     float       WindowRounding;             // Radius of window corners rounding. Set to 0.0f to have rectangular windows
509
     float       WindowRounding;             // Radius of window corners rounding. Set to 0.0f to have rectangular windows
510
+    float       ChildWindowRounding;        // Radius of child window corners rounding. Set to 0.0f to have rectangular windows
483
     ImVec2      FramePadding;               // Padding within a framed rectangle (used by most widgets)
511
     ImVec2      FramePadding;               // Padding within a framed rectangle (used by most widgets)
484
     float       FrameRounding;              // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
512
     float       FrameRounding;              // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
485
     ImVec2      ItemSpacing;                // Horizontal and vertical spacing between widgets/lines
513
     ImVec2      ItemSpacing;                // Horizontal and vertical spacing between widgets/lines
561
 
589
 
562
     bool        WantCaptureMouse;           // Mouse is hovering a window or widget is active (= ImGui will use your mouse input)
590
     bool        WantCaptureMouse;           // Mouse is hovering a window or widget is active (= ImGui will use your mouse input)
563
     bool        WantCaptureKeyboard;        // Widget is active (= ImGui will use your keyboard input)
591
     bool        WantCaptureKeyboard;        // Widget is active (= ImGui will use your keyboard input)
592
+    float       Framerate;                  // Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames
564
 
593
 
565
     //------------------------------------------------------------------
594
     //------------------------------------------------------------------
566
     // [Internal] ImGui will maintain those fields for you
595
     // [Internal] ImGui will maintain those fields for you
692
 // Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used.
721
 // Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used.
693
 struct ImGuiTextEditCallbackData
722
 struct ImGuiTextEditCallbackData
694
 {
723
 {
695
-    ImGuiKey            EventKey;       // Key pressed (Up/Down/TAB)        // Read-only    
696
-    char*               Buf;            // Current text                     // Read-write (pointed data only)
697
-    size_t              BufSize;        //                                  // Read-only
698
-    bool                BufDirty;       // Set if you modify Buf directly   // Write
699
-    ImGuiInputTextFlags Flags;          // What user passed to InputText()  // Read-only
700
-    int                 CursorPos;      //                                  // Read-write
701
-    int                 SelectionStart; //                                  // Read-write (== to SelectionEnd when no selection)
702
-    int                 SelectionEnd;   //                                  // Read-write
703
-    void*               UserData;       // What user passed to InputText()
724
+    ImGuiInputTextFlags EventFlag;      // One of ImGuiInputTextFlags_Callback* // Read-only
725
+    ImGuiInputTextFlags Flags;          // What user passed to InputText()      // Read-only
726
+    void*               UserData;       // What user passed to InputText()      // Read-only
727
+
728
+    // CharFilter event:
729
+    ImWchar             EventChar;      // Character input                      // Read-write (replace character or set to zero)
730
+
731
+    // Completion,History,Always events:
732
+    ImGuiKey            EventKey;       // Key pressed (Up/Down/TAB)            // Read-only
733
+    char*               Buf;            // Current text                         // Read-write (pointed data only)
734
+    size_t              BufSize;        //                                      // Read-only
735
+    bool                BufDirty;       // Set if you modify Buf directly       // Write
736
+    int                 CursorPos;      //                                      // Read-write
737
+    int                 SelectionStart; //                                      // Read-write (== to SelectionEnd when no selection)
738
+    int                 SelectionEnd;   //                                      // Read-write
704
 
739
 
705
     // NB: calling those function loses selection.
740
     // NB: calling those function loses selection.
706
     void DeleteChars(int pos, int bytes_count);
741
     void DeleteChars(int pos, int bytes_count);
796
     IMGUI_API void  AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
831
     IMGUI_API void  AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
797
     IMGUI_API void  AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
832
     IMGUI_API void  AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
798
     IMGUI_API void  AddArc(const ImVec2& center, float rad, ImU32 col, int a_min, int a_max, bool tris = false, const ImVec2& third_point_offset = ImVec2(0,0));
833
     IMGUI_API void  AddArc(const ImVec2& center, float rad, ImU32 col, int a_min, int a_max, bool tris = false, const ImVec2& third_point_offset = ImVec2(0,0));
799
-    IMGUI_API void  AddText(ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f);
834
+    IMGUI_API void  AddText(ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec2* cpu_clip_max = NULL);
800
     IMGUI_API void  AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col = 0xFFFFFFFF);
835
     IMGUI_API void  AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col = 0xFFFFFFFF);
801
 
836
 
802
     // Advanced
837
     // Advanced
886
     };
921
     };
887
     ImFontAtlas*        ContainerAtlas;     // What we has been loaded into
922
     ImFontAtlas*        ContainerAtlas;     // What we has been loaded into
888
     ImVector<Glyph>     Glyphs;
923
     ImVector<Glyph>     Glyphs;
924
+    ImVector<float>     IndexXAdvance;      // Glyphs->XAdvance directly indexable (for CalcTextSize functions which are often bottleneck in large UI)
889
     ImVector<int>       IndexLookup;        // Index glyphs by Unicode code-point
925
     ImVector<int>       IndexLookup;        // Index glyphs by Unicode code-point
890
     const Glyph*        FallbackGlyph;      // == FindGlyph(FontFallbackChar)
926
     const Glyph*        FallbackGlyph;      // == FindGlyph(FontFallbackChar)
891
 
927
 
901
     // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
937
     // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
902
     IMGUI_API ImVec2                CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
938
     IMGUI_API ImVec2                CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
903
     IMGUI_API ImVec2                CalcTextSizeW(float size, float max_width, const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL) const;                 // wchar
939
     IMGUI_API ImVec2                CalcTextSizeW(float size, float max_width, const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL) const;                 // wchar
904
-    IMGUI_API void                  RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices, float wrap_width = 0.0f) const;
940
+    IMGUI_API void                  RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices, float wrap_width = 0.0f, const ImVec2* cpu_clip_max = NULL) const;
905
     IMGUI_API const char*           CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
941
     IMGUI_API const char*           CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
906
 };
942
 };
907
 
943
 

+ 2
- 2
src/system/FontImGui.cpp View File

18
     ImGuiIO& io = ImGui::GetIO();
18
     ImGuiIO& io = ImGui::GetIO();
19
     ImFont* font = io.Fonts->Fonts.at(0);
19
     ImFont* font = io.Fonts->Fonts.at(0);
20
     ImVec2 size = font->CalcTextSizeA(scale * SCALE_CALC, FLT_MAX, io.DisplaySize.y, s.c_str(),
20
     ImVec2 size = font->CalcTextSizeA(scale * SCALE_CALC, FLT_MAX, io.DisplaySize.y, s.c_str(),
21
-                                                    s.c_str() + s.length());
21
+                                      s.c_str() + s.length());
22
     return size.x;
22
     return size.x;
23
 }
23
 }
24
 
24
 
42
     ImGuiIO& io = ImGui::GetIO();
42
     ImGuiIO& io = ImGui::GetIO();
43
     ImFont* font = io.Fonts->Fonts.at(0);
43
     ImFont* font = io.Fonts->Fonts.at(0);
44
     ImVec2 size = font->CalcTextSizeA(scale * SCALE_CALC, FLT_MAX, maxWidth, s.c_str(),
44
     ImVec2 size = font->CalcTextSizeA(scale * SCALE_CALC, FLT_MAX, maxWidth, s.c_str(),
45
-                                                    s.c_str() + s.length());
45
+                                      s.c_str() + s.length());
46
     return size.y;
46
     return size.y;
47
 }
47
 }
48
 
48
 

+ 6
- 3
src/system/Shader.cpp View File

240
                     unsigned int texture, TextureStorage store, unsigned int mode,
240
                     unsigned int texture, TextureStorage store, unsigned int mode,
241
                     Shader& shader) {
241
                     Shader& shader) {
242
     assert(vertices.getSize() == uvs.getSize());
242
     assert(vertices.getSize() == uvs.getSize());
243
-    if (mode == GL_TRIANGLES)
243
+    if (mode == GL_TRIANGLES) {
244
         assert((vertices.getSize() % 3) == 0)
244
         assert((vertices.getSize() % 3) == 0)
245
+    }
245
 
246
 
246
     shader.use();
247
     shader.use();
247
     shader.loadUniform(0, Window::getSize());
248
     shader.loadUniform(0, Window::getSize());
293
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, glm::mat4 MVP,
294
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, glm::mat4 MVP,
294
                     unsigned int mode, Shader& shader) {
295
                     unsigned int mode, Shader& shader) {
295
     assert(vertices.getSize() == colors.getSize());
296
     assert(vertices.getSize() == colors.getSize());
296
-    if (mode == GL_TRIANGLES)
297
+    if (mode == GL_TRIANGLES) {
297
         assert((vertices.getSize() % 3) == 0)
298
         assert((vertices.getSize() % 3) == 0)
299
+    }
298
 
300
 
299
     shader.use();
301
     shader.use();
300
     shader.loadUniform(0, MVP);
302
     shader.loadUniform(0, MVP);
308
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, ShaderBuffer& indices,
310
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, ShaderBuffer& indices,
309
                     glm::mat4 MVP, unsigned int mode, Shader& shader) {
311
                     glm::mat4 MVP, unsigned int mode, Shader& shader) {
310
     assert(vertices.getSize() == colors.getSize());
312
     assert(vertices.getSize() == colors.getSize());
311
-    if (mode == GL_TRIANGLES)
313
+    if (mode == GL_TRIANGLES) {
312
         assert((indices.getSize() % 3) == 0)
314
         assert((indices.getSize() % 3) == 0)
315
+    }
313
 
316
 
314
     shader.use();
317
     shader.use();
315
     shader.loadUniform(0, MVP);
318
     shader.loadUniform(0, MVP);

+ 15
- 0
src/system/WindowSDL.cpp View File

74
         return 0;
74
         return 0;
75
     }
75
     }
76
 
76
 
77
+    SDL_GameControllerAddMapping("341a0000000000000208000000000000,"
78
+                                 "USB GAMEPAD 8116,"
79
+                                 "a:b0,x:b2,start:b7,back:b6,leftstick:b8,rightstick:b9,"
80
+                                 "leftshoulder:b4,rightshoulder:b5,"
81
+                                 "dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,"
82
+                                 "leftx:a0,lefty:a1,rightx:a3,righty:a2,"
83
+                                 "lefttrigger:,b:b1,y:b3,lefttrigger:a4,righttrigger:a4");
84
+
85
+    SDL_GameControllerAddMapping("10080000000000000100000000000000,"
86
+                                 "Twin USB Joystick,"
87
+                                 "a:b4,b:b2,y:b0,x:b6,start:b18,back:b16,leftstick:b20,"
88
+                                 "rightstick:b22,leftshoulder:b12,rightshoulder:b14,dpup:h0.1,"
89
+                                 "dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a2,rightx:a6,"
90
+                                 "righty:a4,lefttrigger:b8,righttrigger:b10");
91
+
77
     for (int i = 0; i < SDL_NumJoysticks(); i++) {
92
     for (int i = 0; i < SDL_NumJoysticks(); i++) {
78
         if (SDL_IsGameController(i)) {
93
         if (SDL_IsGameController(i)) {
79
             controller = SDL_GameControllerOpen(i);
94
             controller = SDL_GameControllerOpen(i);

Loading…
Cancel
Save