Thomas Buck 9 gadus atpakaļ
vecāks
revīzija
e3b087062f

+ 4
- 0
ChangeLog.md Parādīt failu

@@ -2,6 +2,10 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140203 ]
6
+    * Updated imgui to newest version, supporting Images
7
+    * Imgui Image texture viewer (still buggy)
8
+
5 9
     [ 20140124 ]
6 10
     * Started working on Entity system.
7 11
 

+ 16
- 3
include/TextureManager.h Parādīt failu

@@ -51,9 +51,17 @@ enum class TextureStorage {
51 51
     SYSTEM
52 52
 };
53 53
 
54
-/*!
55
- * \brief Texture registry
56
- */
54
+class BufferManager {
55
+  public:
56
+    BufferManager(int t, TextureStorage s) : texture(t), storage(s) { }
57
+    int getTextureID() { return texture; }
58
+    TextureStorage getTextureStorage() { return storage; }
59
+
60
+  private:
61
+    int texture;
62
+    TextureStorage storage;
63
+};
64
+
57 65
 class TextureManager {
58 66
   public:
59 67
     static int initialize();
@@ -100,6 +108,8 @@ class TextureManager {
100 108
     static int getFirstTileAnimation(int index);
101 109
     static int getNextTileAnimation(int tile);
102 110
 
111
+    static BufferManager* getBufferManager(int tex, TextureStorage store);
112
+
103 113
   private:
104 114
     static std::vector<unsigned int>& getIds(TextureStorage s);
105 115
     static std::vector<int>& getUnits(TextureStorage s);
@@ -116,6 +126,9 @@ class TextureManager {
116 126
     static std::vector<int> gameUnits;
117 127
     static std::vector<int> systemUnits;
118 128
     static unsigned int nextFreeTextureUnit;
129
+
130
+    static std::vector<BufferManager> gameBuffers;
131
+    static std::vector<BufferManager> systemBuffers;
119 132
 };
120 133
 
121 134
 #endif

+ 25
- 0
src/TextureManager.cpp Parādīt failu

@@ -25,6 +25,8 @@ std::vector<std::vector<int>> TextureManager::animations;
25 25
 std::vector<int> TextureManager::gameUnits;
26 26
 std::vector<int> TextureManager::systemUnits;
27 27
 unsigned int TextureManager::nextFreeTextureUnit = 0;
28
+std::vector<BufferManager> TextureManager::gameBuffers;
29
+std::vector<BufferManager> TextureManager::systemBuffers;
28 30
 
29 31
 int TextureManager::initialize() {
30 32
     assert(mTextureIdsGame.size() == 0);
@@ -75,6 +77,8 @@ void TextureManager::shutdown() {
75 77
     }
76 78
 
77 79
     clear();
80
+
81
+    systemBuffers.clear();
78 82
 }
79 83
 
80 84
 void TextureManager::clear() {
@@ -94,6 +98,8 @@ void TextureManager::clear() {
94 98
     gameUnits.clear();
95 99
     systemUnits.clear();
96 100
     nextFreeTextureUnit = 0;
101
+
102
+    gameBuffers.clear();
97 103
 }
98 104
 
99 105
 int TextureManager::loadBufferSlot(unsigned char* image,
@@ -161,6 +167,9 @@ int TextureManager::loadBufferSlot(unsigned char* image,
161 167
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
162 168
     }
163 169
 
170
+    Log::get(LOG_DEBUG) << "New Texture: " << slot << " - "
171
+        << ((s == TextureStorage::GAME) ? "Game" : "System") << Log::endl;
172
+
164 173
     return slot;
165 174
 }
166 175
 
@@ -177,6 +186,11 @@ void TextureManager::bindTextureId(unsigned int n, TextureStorage s, unsigned in
177 186
 }
178 187
 
179 188
 int TextureManager::bindTexture(unsigned int n, TextureStorage s) {
189
+    if (n >= getIds(s).size()) {
190
+        Log::get(LOG_DEBUG) << "Bound Unknown Texture " << n << " in "
191
+            << ((s == TextureStorage::GAME) ? "Game" : "System") << Log::endl;
192
+    }
193
+
180 194
     assert(n < getIds(s).size());
181 195
 
182 196
     if ((n < getUnits(s).size()) && (getUnits(s).at(n) >= 0)) {
@@ -237,6 +251,17 @@ int TextureManager::getNextTileAnimation(int tile) {
237 251
     return -1;
238 252
 }
239 253
 
254
+BufferManager* TextureManager::getBufferManager(int tex, TextureStorage store) {
255
+    auto& v = (store == TextureStorage::GAME) ? gameBuffers : systemBuffers;
256
+    while (v.size() <= tex) {
257
+        v.emplace_back(v.size(), store);
258
+
259
+        Log::get(LOG_DEBUG) << "New BufferManager: " << v.size() - 1 << " - "
260
+            << ((store == TextureStorage::GAME) ? "Game" : "System") << Log::endl;
261
+    }
262
+    return &(v.at(tex));
263
+}
264
+
240 265
 int TextureManager::loadImage(std::string filename, TextureStorage s, int slot) {
241 266
     if (stringEndsWith(filename, ".pcx")) {
242 267
         return loadPCX(filename, s, slot);

+ 30
- 30
src/UI.cpp Parādīt failu

@@ -89,6 +89,7 @@ int UI::initialize() {
89 89
     io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
90 90
     fontTex = TextureManager::loadBufferSlot(pixels, width, height, ColorMode::RGBA, 32,
91 91
                                              TextureStorage::SYSTEM, -1, false);
92
+    io.Fonts->TexID = TextureManager::getBufferManager(fontTex, TextureStorage::SYSTEM);
92 93
 
93 94
     // Set up OpenRaider style
94 95
     ImGuiStyle& style = ImGui::GetStyle();
@@ -272,20 +273,12 @@ void UI::display() {
272 273
     if (ImGui::Begin("Engine", &visible, ImVec2(400, 400))) {
273 274
         Render::displayUI();
274 275
         RunTime::display();
275
-        SoundManager::display();
276 276
 
277
-        /*
278
-        static bool visibleTex = false;
279
-        static bool visibleTile = false;
280
-        static bool visibleAnim = false;
281
-        static bool visibleSprite = false;
282 277
         if (ImGui::CollapsingHeader("Texture Viewer")) {
283 278
             static bool game = Game::isLoaded();
284 279
             static int index = 0;
285
-            ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
286
-            ImGui::SliderInt("##texslide", &index, 0, TextureManager::.numTextures(
280
+            ImGui::SliderInt("##texslide", &index, 0, TextureManager::numTextures(
287 281
                                  game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1);
288
-            ImGui::PopItemWidth();
289 282
             ImGui::SameLine();
290 283
             if (ImGui::Button("+##texplus", ImVec2(0, 0), true)) {
291 284
                 if (index < (TextureManager::numTextures(
@@ -302,33 +295,37 @@ void UI::display() {
302 295
                     index = TextureManager::numTextures(
303 296
                                 game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1;
304 297
             }
305
-            ImGui::SameLine();
306
-            if ((TextureManager::numTextures() > 0)) {
298
+
299
+            if ((TextureManager::numTextures(TextureStorage::GAME) > 0)) {
300
+                ImGui::SameLine();
307 301
                 ImGui::Checkbox("Game##texgame", &game);
308 302
             } else {
309 303
                 game = false;
310 304
             }
311
-            ImGui::SameLine();
312
-            if (ImGui::Button("Show##texshow")) {
313
-                visibleTex = true;
314
-                visibleTile = false;
315
-                visibleAnim = false;
316
-                visibleSprite = false;
317
-            }
318
-            ImGui::SameLine();
319
-            if (ImGui::Button("Clear##texclear")) {
320
-                getRender().debugDisplayTexture();
321
-                visibleTex = false;
322
-            }
323
-            if (visibleTex) {
324
-                getRender().debugDisplayTexture(index,
325
-                                                game ? TextureStorage::GAME : TextureStorage::SYSTEM,
326
-                                                ImGui::GetWindowPos().x - ImGui::GetWindowWidth(),
327
-                                                ImGui::GetWindowPos().y,
328
-                                                ImGui::GetWindowWidth(), ImGui::GetWindowWidth());
305
+
306
+            if (index >= TextureManager::numTextures(game ? TextureStorage::GAME : TextureStorage::SYSTEM)) {
307
+                index = TextureManager::numTextures(game ? TextureStorage::GAME : TextureStorage::SYSTEM) - 1;
308
+                if (index < 0) {
309
+                    game = false;
310
+                    index = 0;
311
+                }
329 312
             }
313
+
314
+            ImGui::Image(TextureManager::getBufferManager(index,
315
+                                                          game ? TextureStorage::GAME
316
+                                                            : TextureStorage::SYSTEM),
317
+                         ImVec2(ImGui::GetColumnWidth() * 2 / 3, ImGui::GetColumnWidth() * 2 / 3));
330 318
         }
331 319
 
320
+        SoundManager::display();
321
+
322
+        /*
323
+        static bool visibleTex = false;
324
+        static bool visibleTile = false;
325
+        static bool visibleAnim = false;
326
+        static bool visibleSprite = false;
327
+
328
+
332 329
         if (ImGui::CollapsingHeader("Textile Viewer")) {
333 330
             if (TextureManager::numTiles() > 0) {
334 331
                 static int index = 0;
@@ -596,7 +593,6 @@ void UI::renderImGui(ImDrawList** const cmd_lists, int cmd_lists_count) {
596 593
 
597 594
     imguiShader.use();
598 595
     imguiShader.loadUniform(0, Window::getSize());
599
-    imguiShader.loadUniform(1, fontTex, TextureStorage::SYSTEM);
600 596
     vert.bindBuffer(0, 2);
601 597
     uv.bindBuffer(1, 2);
602 598
     col.bindBuffer(2, 4);
@@ -634,6 +630,10 @@ void UI::renderImGui(ImDrawList** const cmd_lists, int cmd_lists_count) {
634 630
             uv.bufferData(uvs);
635 631
             col.bufferData(colors);
636 632
 
633
+            auto bm = static_cast<BufferManager*>(commands[n].texture_id);
634
+            assert(bm != nullptr);
635
+            imguiShader.loadUniform(1, bm->getTextureID(), bm->getTextureStorage());
636
+
637 637
             glScissor(commands[n].clip_rect.x,
638 638
                       Window::getSize().y - commands[n].clip_rect.w,
639 639
                       commands[n].clip_rect.z - commands[n].clip_rect.x,

+ 567
- 247
src/deps/imgui/imgui.cpp
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 116
- 50
src/deps/imgui/imgui.h Parādīt failu

@@ -1,4 +1,4 @@
1
-// ImGui library v1.30 wip
1
+// ImGui library v1.31 wip
2 2
 // See .cpp file for commentary.
3 3
 // See ImGui::ShowTestWindow() for sample code.
4 4
 // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
@@ -6,6 +6,7 @@
6 6
 
7 7
 #pragma once
8 8
 
9
+struct ImDrawCmd;
9 10
 struct ImDrawList;
10 11
 struct ImFont;
11 12
 struct ImFontAtlas;
@@ -68,10 +69,9 @@ struct ImVec4
68 69
 
69 70
 namespace ImGui
70 71
 {
71
-    // Proxy functions to access the MemAllocFn/MemFreeFn/MemReallocFn pointers in ImGui::GetIO(). The only reason they exist here is to allow ImVector<> to compile inline.
72
+    // Proxy functions to access the MemAllocFn/MemFreeFn pointers in ImGui::GetIO(). The only reason they exist here is to allow ImVector<> to compile inline.
72 73
     IMGUI_API void*       MemAlloc(size_t sz);
73 74
     IMGUI_API void        MemFree(void* ptr);
74
-    IMGUI_API void*       MemRealloc(void* ptr, size_t sz);
75 75
 }
76 76
 
77 77
 // std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug). 
@@ -114,8 +114,16 @@ public:
114 114
     inline const value_type&    back() const                    { IM_ASSERT(Size > 0); return Data[Size-1]; }
115 115
     inline void                 swap(ImVector<T>& rhs)          { const size_t rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const size_t rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
116 116
 
117
-    inline void                 reserve(size_t new_capacity)    { Data = (value_type*)ImGui::MemRealloc(Data, new_capacity * sizeof(value_type)); Capacity = new_capacity; }
118 117
     inline void                 resize(size_t new_size)         { if (new_size > Capacity) reserve(new_size); Size = new_size; }
118
+    inline void                 reserve(size_t new_capacity)    
119
+    { 
120
+        if (new_capacity <= Capacity) return;
121
+        T* new_data = (value_type*)ImGui::MemAlloc(new_capacity * sizeof(value_type));
122
+        memcpy(new_data, Data, Size * sizeof(value_type));
123
+        ImGui::MemFree(Data);
124
+        Data = new_data;
125
+        Capacity = new_capacity; 
126
+    }
119 127
 
120 128
     inline void                 push_back(const value_type& v)  { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; }
121 129
     inline void                 pop_back()                      { IM_ASSERT(Size > 0); Size--; }
@@ -243,7 +251,9 @@ namespace ImGui
243 251
     IMGUI_API void          BulletTextV(const char* fmt, va_list args);
244 252
     IMGUI_API bool          Button(const char* label, const ImVec2& size = ImVec2(0,0), bool repeat_when_held = false);
245 253
     IMGUI_API bool          SmallButton(const char* label);
246
-    IMGUI_API void          Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), ImU32 tint_col = 0xFFFFFFFF, ImU32 border_col = 0x00000000);
254
+    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));
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.
247 257
     IMGUI_API bool          CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
248 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.
249 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);
@@ -302,8 +312,8 @@ namespace ImGui
302 312
     IMGUI_API void          LogText(const char* fmt, ...);                                      // pass text data straight to log (without being displayed)
303 313
 
304 314
     // Utilities
305
-    IMGUI_API bool          IsItemHovered();                                                    // was the last item active area hovered by mouse?
306
-    IMGUI_API bool          IsItemFocused();                                                    // was the last item focused for keyboard input?
315
+    IMGUI_API bool          IsItemHovered();                                                    // was the last item hovered by mouse?
316
+    IMGUI_API bool          IsItemActive();                                                     // was the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false)
307 317
     IMGUI_API ImVec2        GetItemBoxMin();                                                    // get bounding box of last item
308 318
     IMGUI_API ImVec2        GetItemBoxMax();                                                    // get bounding box of last item
309 319
     IMGUI_API bool          IsClipped(const ImVec2& item_size);                                 // to perform coarse clipping on user's side (as an optimization)
@@ -320,25 +330,34 @@ namespace ImGui
320 330
     IMGUI_API const char*   GetStyleColName(ImGuiCol idx);
321 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);
322 332
 
333
+    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);
335
+    IMGUI_API void          ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
336
+
337
+    // 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);
339
+
323 340
 } // namespace ImGui
324 341
 
325 342
 // Flags for ImGui::Begin()
326 343
 enum ImGuiWindowFlags_
327 344
 {
328 345
     // Default: 0
329
-    ImGuiWindowFlags_ShowBorders            = 1 << 0,
330
-    ImGuiWindowFlags_NoTitleBar             = 1 << 1,
331
-    ImGuiWindowFlags_NoResize               = 1 << 2,
332
-    ImGuiWindowFlags_NoMove                 = 1 << 3,
333
-    ImGuiWindowFlags_NoScrollbar            = 1 << 4,
334
-    ImGuiWindowFlags_NoScrollWithMouse      = 1 << 5,
335
-    ImGuiWindowFlags_AlwaysAutoResize       = 1 << 6,
336
-    ImGuiWindowFlags_NoSavedSettings        = 1 << 7,   // Never load/save settings in .ini file
337
-    ImGuiWindowFlags_ChildWindow            = 1 << 8,   // For internal use by BeginChild()
338
-    ImGuiWindowFlags_ChildWindowAutoFitX    = 1 << 9,   // For internal use by BeginChild()
339
-    ImGuiWindowFlags_ChildWindowAutoFitY    = 1 << 10,  // For internal use by BeginChild()
340
-    ImGuiWindowFlags_ComboBox               = 1 << 11,  // For internal use by ComboBox()
341
-    ImGuiWindowFlags_Tooltip                = 1 << 12   // For internal use by Render() when using Tooltip
346
+    ImGuiWindowFlags_NoTitleBar             = 1 << 0,   // Disable title-bar
347
+    ImGuiWindowFlags_NoResize               = 1 << 1,   // Disable user resizing with the lower-right grip
348
+    ImGuiWindowFlags_NoMove                 = 1 << 2,   // Disable user moving the window
349
+    ImGuiWindowFlags_NoScrollbar            = 1 << 3,   // Disable scroll bar (window can still scroll with mouse or programatically)
350
+    ImGuiWindowFlags_NoScrollWithMouse      = 1 << 4,   // Disable user scrolling with mouse wheel
351
+    ImGuiWindowFlags_NoCollapse             = 1 << 5,   // Disable user collapsing window by double-clicking on it
352
+    ImGuiWindowFlags_AlwaysAutoResize       = 1 << 6,   // Resize every window to its content every frame
353
+    ImGuiWindowFlags_ShowBorders            = 1 << 7,   // Show borders around windows and items
354
+    ImGuiWindowFlags_NoSavedSettings        = 1 << 8,   // Never load/save settings in .ini file
355
+    // [Internal]
356
+    ImGuiWindowFlags_ChildWindow            = 1 << 9,   // For internal use by BeginChild()
357
+    ImGuiWindowFlags_ChildWindowAutoFitX    = 1 << 10,  // For internal use by BeginChild()
358
+    ImGuiWindowFlags_ChildWindowAutoFitY    = 1 << 11,  // For internal use by BeginChild()
359
+    ImGuiWindowFlags_ComboBox               = 1 << 12,  // For internal use by ComboBox()
360
+    ImGuiWindowFlags_Tooltip                = 1 << 13   // For internal use by BeginTooltip()
342 361
 };
343 362
 
344 363
 // Flags for ImGui::InputText()
@@ -497,6 +516,8 @@ struct ImGuiIO
497 516
     ImFontAtlas*  Fonts;                    // <auto>               // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
498 517
     float         FontGlobalScale;          // = 1.0f               // Global scale all fonts
499 518
     bool          FontAllowUserScaling;     // = false              // Allow user scaling text of individual window with CTRL+Wheel.
519
+    ImVec2        DisplayVisibleMin;        // <unset> (0.0f,0.0f)  // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area.
520
+    ImVec2        DisplayVisibleMax;        // <unset> (0.0f,0.0f)  // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
500 521
 
501 522
     //------------------------------------------------------------------
502 523
     // User Functions
@@ -511,9 +532,8 @@ struct ImGuiIO
511 532
     const char* (*GetClipboardTextFn)();
512 533
     void        (*SetClipboardTextFn)(const char* text);
513 534
 
514
-    // Optional: override memory allocations (default to posix malloc/realloc/free)
535
+    // Optional: override memory allocations (default to posix malloc/free). MemFreeFn() may be called with a NULL pointer.
515 536
     void*       (*MemAllocFn)(size_t sz);
516
-    void*       (*MemReallocFn)(void* ptr, size_t sz);
517 537
     void        (*MemFreeFn)(void* ptr);
518 538
 
519 539
     // Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese inputs in Windows)
@@ -525,7 +545,8 @@ struct ImGuiIO
525 545
 
526 546
     ImVec2      MousePos;                   // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
527 547
     bool        MouseDown[5];               // Mouse buttons. ImGui itself only uses button 0 (left button) but you can use others as storage for convenience.
528
-    float       MouseWheel;                 // Mouse wheel: 1 unit scrolls about 5 lines text.  
548
+    float       MouseWheel;                 // Mouse wheel: 1 unit scrolls about 5 lines text. 
549
+    bool        MouseDrawCursor;            // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
529 550
     bool        KeyCtrl;                    // Keyboard modifier pressed: Control
530 551
     bool        KeyShift;                   // Keyboard modifier pressed: Shift
531 552
     bool        KeysDown[512];              // Keyboard keys that are pressed (in whatever order user naturally has access to keyboard data)
@@ -637,26 +658,34 @@ struct ImGuiStorage
637 658
     struct Pair 
638 659
     { 
639 660
         ImGuiID key; 
640
-        union { int val_i; float val_f; };        
661
+        union { int val_i; float val_f; void* val_p; };        
641 662
         Pair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; } 
642 663
         Pair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; } 
664
+        Pair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; } 
643 665
     };
644 666
     ImVector<Pair>    Data;
645 667
 
646 668
     // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
647 669
     // - Set***() functions find pair, insertion on demand if missing.
648
-    // - Get***Ptr() functions find pair, insertion on demand if missing, return pointer. Useful if you intend to do Get+Set. 
649
-    //   A typical use case where this is very convenient:
650
-    //      float* pvar = ImGui::GetIntPtr(key); ImGui::SliderInt("var", pvar, 0, 100); some_var += *pvar;
651 670
     // - Sorted insertion is costly but should amortize. A typical frame shouldn't need to insert any new pair.
652 671
     IMGUI_API void    Clear();
653 672
     IMGUI_API int     GetInt(ImGuiID key, int default_val = 0) const;
654 673
     IMGUI_API void    SetInt(ImGuiID key, int val);
655
-    IMGUI_API int*    GetIntPtr(ImGuiID key, int default_val = 0);
656 674
     IMGUI_API float   GetFloat(ImGuiID key, float default_val = 0.0f) const;
657 675
     IMGUI_API void    SetFloat(ImGuiID key, float val);
658
-    IMGUI_API float*  GetFloatPtr(ImGuiID key, float default_val = 0);
659
-    IMGUI_API void    SetAllInt(int val);    // Use on your own storage if you know only integer are being stored.
676
+    IMGUI_API void*   GetVoidPtr(ImGuiID key) const; // default_val is NULL
677
+    IMGUI_API void    SetVoidPtr(ImGuiID key, void* val);
678
+
679
+    // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set. 
680
+    // - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
681
+    // - A typical use case where this is convenient:
682
+    //      float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
683
+    // - You can also use this to quickly create temporary editable values during a session of using Edit&Continue, without restarting your application.
684
+    IMGUI_API int*    GetIntRef(ImGuiID key, int default_val = 0);
685
+    IMGUI_API float*  GetFloatRef(ImGuiID key, float default_val = 0);
686
+
687
+    // Use on your own storage if you know only integer are being stored (open/close all tree nodes)
688
+    IMGUI_API void    SetAllInt(int val);
660 689
 };
661 690
 
662 691
 // Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used.
@@ -677,20 +706,50 @@ struct ImGuiTextEditCallbackData
677 706
     void InsertChars(int pos, const char* text, const char* text_end = NULL);
678 707
 };
679 708
 
709
+// ImColor() is just a helper that implicity converts to either ImU32 (packed 4x1 byte) or ImVec4 (4x1 float)
710
+// None of the ImGui API are using ImColor directly but you can use it as a convenience to pass colors in either formats.
711
+struct ImColor
712
+{
713
+    ImVec4              Value;
714
+
715
+    ImColor(int r, int g, int b, int a = 255)                       { Value.x = (float)r / 255.0f; Value.y = (float)g / 255.0f; Value.z = (float)b / 255.0f; Value.w = (float)a / 255.0f; }
716
+    ImColor(float r, float g, float b, float a = 1.0f)              { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
717
+    ImColor(const ImVec4& col)                                      { Value = col; }
718
+
719
+    operator ImU32() const                                          { return ImGui::ColorConvertFloat4ToU32(Value); }
720
+    operator ImVec4() const                                         { return Value; }
721
+
722
+    static ImColor HSV(float h, float s, float v, float a = 1.0f)   { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); }
723
+};
724
+
680 725
 //-----------------------------------------------------------------------------
681 726
 // Draw List
682
-// Hold a series of drawing commands. The user provides a renderer for ImDrawList
727
+// Hold a series of drawing commands. The user provides a renderer for ImDrawList.
683 728
 //-----------------------------------------------------------------------------
684 729
 
730
+// Draw callbacks for advanced uses.
731
+// NB- You most likely DO NOT need to care about draw callbacks just to create your own widget or customized UI rendering (you can poke into the draw list for that)
732
+// Draw callback are useful for example if you want to render a complex 3D scene inside a UI element.
733
+// The expected behavior from your rendering loop is:
734
+//   if (cmd.user_callback != NULL)
735
+//       cmd.user_callback(parent_list, cmd);
736
+//   else
737
+//       RenderTriangles()
738
+// It is up to you to decide if your rendering loop or the callback should be responsible for backup/restoring rendering state.
739
+typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd);
740
+
741
+// Typically, 1 command = 1 gpu draw call
685 742
 struct ImDrawCmd
686 743
 {
687
-    unsigned int    vtx_count;
688
-    ImVec4          clip_rect;
689
-    ImTextureID     texture_id;     // Copy of user-provided 'TexID' from ImFont or passed to Image*() functions. Ignore if not using images or multiple fonts.
744
+    unsigned int    vtx_count;                  // Number of vertices (multiple of 3) to be drawn as triangles. The vertices are stored in the callee ImDrawList's vtx_buffer[] array.
745
+    ImVec4          clip_rect;                  // Clipping rectangle (x1, y1, x2, y2)
746
+    ImTextureID     texture_id;                 // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
747
+    ImDrawCallback  user_callback;              // If != NULL, call the function instead of rendering the vertices. vtx_count will be 0. clip_rect and texture_id will be set normally.
748
+    void*           user_callback_data;         // The draw callback code can access this.
690 749
 };
691 750
 
751
+// Vertex layout
692 752
 #ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
693
-// Default vertex layout
694 753
 struct ImDrawVert
695 754
 {
696 755
     ImVec2  pos;
@@ -705,35 +764,28 @@ IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT;
705 764
 #endif
706 765
 
707 766
 // Draw command list
708
-// This is the low-level list of polygon that ImGui:: functions are creating. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering.
709
-// At the moment, each ImGui window contains its own ImDrawList but they could potentially be merged.
767
+// This is the low-level list of polygons that ImGui functions are filling. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering.
768
+// At the moment, each ImGui window contains its own ImDrawList but they could potentially be merged in the future.
710 769
 // If you want to add custom rendering within a window, you can use ImGui::GetWindowDrawList() to access the current draw list and add your own primitives.
711 770
 // You can interleave normal ImGui:: calls and adding primitives to the current draw list.
712 771
 // Note that this only gives you access to rendering polygons. If your intent is to create custom widgets and the publicly exposed functions/data aren't sufficient, you can add code in imgui_user.inl
713 772
 struct ImDrawList
714 773
 {
715 774
     // This is what you have to render
716
-    ImVector<ImDrawCmd>     commands;           // commands
717
-    ImVector<ImDrawVert>    vtx_buffer;         // each command consume ImDrawCmd::vtx_count of those
775
+    ImVector<ImDrawCmd>     commands;           // Commands. Typically 1 command = 1 gpu draw call.
776
+    ImVector<ImDrawVert>    vtx_buffer;         // Vertex buffer. Each command consume ImDrawCmd::vtx_count of those
718 777
 
719 778
     // [Internal to ImGui]
720
-    ImVector<ImVec4>        clip_rect_stack;    // [internal]
721
-    ImVector<ImTextureID>   texture_id_stack;   // [internal] 
722
-    ImDrawVert*             vtx_write;          // [internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much)
779
+    ImVector<ImVec4>        clip_rect_stack;    // [Internal]
780
+    ImVector<ImTextureID>   texture_id_stack;   // [Internal] 
781
+    ImDrawVert*             vtx_write;          // [Internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much)
723 782
 
724 783
     ImDrawList() { Clear(); }
725
-
726 784
     IMGUI_API void  Clear();
727
-    IMGUI_API void  SetClipRect(const ImVec4& clip_rect);
728 785
     IMGUI_API void  PushClipRect(const ImVec4& clip_rect);
729 786
     IMGUI_API void  PopClipRect();
730
-    IMGUI_API void  SetTextureID(const ImTextureID& texture_id);
731 787
     IMGUI_API void  PushTextureID(const ImTextureID& texture_id);
732 788
     IMGUI_API void  PopTextureID();
733
-    IMGUI_API void  ReserveVertices(unsigned int vtx_count);
734
-    IMGUI_API void  AddVtx(const ImVec2& pos, ImU32 col);
735
-    IMGUI_API void  AddVtxUV(const ImVec2& pos, ImU32 col, const ImVec2& uv);
736
-    IMGUI_API void  AddVtxLine(const ImVec2& a, const ImVec2& b, ImU32 col);
737 789
 
738 790
     // Primitives   
739 791
     IMGUI_API void  AddLine(const ImVec2& a, const ImVec2& b, ImU32 col);
@@ -744,7 +796,19 @@ struct ImDrawList
744 796
     IMGUI_API void  AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
745 797
     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));
746 798
     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);
747
-    IMGUI_API void  AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col);
799
+    IMGUI_API void  AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col = 0xFFFFFFFF);
800
+
801
+    // Advanced
802
+    IMGUI_API void  AddCallback(ImDrawCallback callback, void* callback_data);   // Your rendering function must check for 'user_callback' in ImDrawCmd and call the function instead of rendering triangles.
803
+    IMGUI_API void  AddDrawCmd();               // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
804
+
805
+    // Internal helpers
806
+    IMGUI_API void  ReserveVertices(unsigned int vtx_count);
807
+    IMGUI_API void  AddVtx(const ImVec2& pos, ImU32 col);
808
+    IMGUI_API void  AddVtxUV(const ImVec2& pos, ImU32 col, const ImVec2& uv);
809
+    IMGUI_API void  AddVtxLine(const ImVec2& a, const ImVec2& b, ImU32 col);
810
+    IMGUI_API void  UpdateClipRect();
811
+    IMGUI_API void  UpdateTextureID();
748 812
 };
749 813
 
750 814
 // Load and rasterize multiple TTF fonts into a same texture.
@@ -769,6 +833,7 @@ struct ImFontAtlas
769 833
     // User is in charge of copying the pixels into graphics memory, then call SetTextureUserID()
770 834
     // After loading the texture into your graphic system, store your texture handle in 'TexID' (ignore if you aren't using multiple fonts nor images)
771 835
     // RGBA32 format is provided for convenience and high compatibility, but note that all RGB pixels are white, so 75% of the memory is wasted.
836
+    // Pitch = Width * BytesPerPixels
772 837
     IMGUI_API void              GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL);  // 1 byte per-pixel
773 838
     IMGUI_API void              GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL);  // 4 bytes-per-pixel
774 839
     IMGUI_API void              SetTexID(void* id)  { TexID = id; }
@@ -795,6 +860,7 @@ struct ImFontAtlas
795 860
     ImVector<ImFontAtlasData*>  InputData;          // Internal data
796 861
     IMGUI_API bool              Build();            // Build pixels data. This is automatically for you by the GetTexData*** functions.
797 862
     IMGUI_API void              ClearInputData();   // Clear the input TTF data.
863
+    IMGUI_API void              RenderCustomTexData();
798 864
 };
799 865
 
800 866
 // TTF font loading and rendering

+ 5
- 35
src/deps/imgui/stb_textedit.h Parādīt failu

@@ -1,4 +1,4 @@
1
-// stb_textedit.h - v1.5  - public domain - Sean Barrett
1
+// stb_textedit.h - v1.4  - public domain - Sean Barrett
2 2
 // Development of this library was sponsored by RAD Game Tools
3 3
 //
4 4
 // This C header file implements the guts of a multi-line text-editing
@@ -30,7 +30,6 @@
30 30
 //
31 31
 // VERSION HISTORY
32 32
 //
33
-//   1.5  (2014-09-10) add support for secondary keys for OS X
34 33
 //   1.4  (2014-08-17) fix signed/unsigned warnings
35 34
 //   1.3  (2014-06-19) fix mouse clicking to round to nearest char boundary
36 35
 //   1.2  (2014-05-27) fix some RAD types that had crept into the new code
@@ -44,7 +43,6 @@
44 43
 //
45 44
 //   Ulf Winklemann: move-by-word in 1.1
46 45
 //   Scott Graham: mouse selection bugfix in 1.3
47
-//   Fabian Giesen: secondary key inputs in 1.5
48 46
 //
49 47
 // USAGE
50 48
 //
@@ -144,10 +142,6 @@
144 142
 //                                 required for WORDLEFT/WORDRIGHT
145 143
 //    STB_TEXTEDIT_K_WORDLEFT    keyboard input to move cursor left one word // e.g. ctrl-LEFT
146 144
 //    STB_TEXTEDIT_K_WORDRIGHT   keyboard input to move cursor right one word // e.g. ctrl-RIGHT
147
-//    STB_TEXTEDIT_K_LINESTART2  secondary keyboard input to move cursor to start of line
148
-//    STB_TEXTEDIT_K_LINEEND2    secondary keyboard input to move cursor to end of line
149
-//    STB_TEXTEDIT_K_TEXTSTART2  secondary keyboard input to move cursor to start of text
150
-//    STB_TEXTEDIT_K_TEXTEND2    secondary keyboard input to move cursor to end of text
151 145
 //
152 146
 // Todo:
153 147
 //    STB_TEXTEDIT_K_PGUP        keyboard input to move cursor up a page
@@ -923,35 +917,23 @@ retry:
923 917
          state->has_preferred_x = 0;
924 918
          break;
925 919
          
926
-#ifdef STB_TEXTEDIT_K_TEXTSTART2
927
-      case STB_TEXTEDIT_K_TEXTSTART2:
928
-#endif
929 920
       case STB_TEXTEDIT_K_TEXTSTART:
930 921
          state->cursor = state->select_start = state->select_end = 0;
931 922
          state->has_preferred_x = 0;
932 923
          break;
933 924
 
934
-#ifdef STB_TEXTEDIT_K_TEXTEND2
935
-      case STB_TEXTEDIT_K_TEXTEND2:
936
-#endif
937 925
       case STB_TEXTEDIT_K_TEXTEND:
938 926
          state->cursor = STB_TEXTEDIT_STRINGLEN(str);
939 927
          state->select_start = state->select_end = 0;
940 928
          state->has_preferred_x = 0;
941 929
          break;
942 930
         
943
-#ifdef STB_TEXTEDIT_K_TEXTSTART2
944
-      case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT:
945
-#endif
946 931
       case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT:
947 932
          stb_textedit_prep_selection_at_cursor(state);
948 933
          state->cursor = state->select_end = 0;
949 934
          state->has_preferred_x = 0;
950 935
          break;
951 936
 
952
-#ifdef STB_TEXTEDIT_K_TEXTEND2
953
-      case STB_TEXTEDIT_K_TEXTEND2 | STB_TEXTEDIT_K_SHIFT:
954
-#endif
955 937
       case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT:
956 938
          stb_textedit_prep_selection_at_cursor(state);
957 939
          state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str);
@@ -959,9 +941,6 @@ retry:
959 941
          break;
960 942
 
961 943
 
962
-#ifdef STB_TEXTEDIT_K_LINESTART2
963
-      case STB_TEXTEDIT_K_LINESTART2:
964
-#endif
965 944
       case STB_TEXTEDIT_K_LINESTART: {
966 945
          StbFindState find;
967 946
          stb_textedit_clamp(str, state);
@@ -972,9 +951,6 @@ retry:
972 951
          break;
973 952
       }
974 953
 
975
-#ifdef STB_TEXTEDIT_K_LINEEND2
976
-      case STB_TEXTEDIT_K_LINEEND2:
977
-#endif
978 954
       case STB_TEXTEDIT_K_LINEEND: {
979 955
          StbFindState find;
980 956
          stb_textedit_clamp(str, state);
@@ -985,9 +961,6 @@ retry:
985 961
          break;
986 962
       }
987 963
 
988
-#ifdef STB_TEXTEDIT_K_LINESTART2
989
-      case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT:
990
-#endif
991 964
       case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: {
992 965
          StbFindState find;
993 966
          stb_textedit_clamp(str, state);
@@ -998,9 +971,6 @@ retry:
998 971
          break;
999 972
       }
1000 973
 
1001
-#ifdef STB_TEXTEDIT_K_LINEEND2
1002
-      case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT:
1003
-#endif
1004 974
       case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: {
1005 975
          StbFindState find;
1006 976
          stb_textedit_clamp(str, state);
@@ -1038,13 +1008,13 @@ static void stb_textedit_discard_undo(StbUndoState *state)
1038 1008
          int n = state->undo_rec[0].insert_length, i;
1039 1009
          // delete n characters from all other records
1040 1010
          state->undo_char_point = state->undo_char_point - (short) n;  // vsnet05
1041
-         memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE)));
1011
+         memmove(state->undo_char, state->undo_char + n, (size_t) ((size_t)state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE)));
1042 1012
          for (i=0; i < state->undo_point; ++i)
1043 1013
             if (state->undo_rec[i].char_storage >= 0)
1044 1014
                state->undo_rec[i].char_storage = state->undo_rec[i].char_storage - (short) n; // vsnet05 // @OPTIMIZE: get rid of char_storage and infer it
1045 1015
       }
1046 1016
       --state->undo_point;
1047
-      memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0])));
1017
+      memmove(state->undo_rec, state->undo_rec+1, (size_t) ((size_t)state->undo_point*sizeof(state->undo_rec[0])));
1048 1018
    }
1049 1019
 }
1050 1020
 
@@ -1062,13 +1032,13 @@ static void stb_textedit_discard_redo(StbUndoState *state)
1062 1032
          int n = state->undo_rec[k].insert_length, i;
1063 1033
          // delete n characters from all other records
1064 1034
          state->redo_char_point = state->redo_char_point + (short) n; // vsnet05
1065
-         memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
1035
+         memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
1066 1036
          for (i=state->redo_point; i < k; ++i)
1067 1037
             if (state->undo_rec[i].char_storage >= 0)
1068 1038
                state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05
1069 1039
       }
1070 1040
       ++state->redo_point;
1071
-      memmove(state->undo_rec + state->redo_point-1, state->undo_rec + state->redo_point, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0])));
1041
+      memmove(state->undo_rec + state->redo_point-1, state->undo_rec + state->redo_point, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0])));
1072 1042
    }
1073 1043
 }
1074 1044
 

+ 104
- 95
src/deps/imgui/stb_truetype.h Parādīt failu

@@ -379,6 +379,12 @@ int main(int arg, char **argv)
379 379
    typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1];
380 380
    typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1];
381 381
 
382
+   #ifdef STBTT_STATIC
383
+   #define STBTT_DEF static
384
+   #else
385
+   #define STBTT_DEF extern
386
+   #endif
387
+
382 388
    // #define your own STBTT_sort() to override this to avoid qsort
383 389
    #ifndef STBTT_sort
384 390
    #include <stdlib.h>
@@ -448,7 +454,7 @@ typedef struct
448 454
    float xoff,yoff,xadvance;
449 455
 } stbtt_bakedchar;
450 456
 
451
-extern int stbtt_BakeFontBitmap(const unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
457
+STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
452 458
                                 float pixel_height,                     // height of font in pixels
453 459
                                 unsigned char *pixels, int pw, int ph,  // bitmap to be filled in
454 460
                                 int first_char, int num_chars,          // characters to bake
@@ -464,7 +470,7 @@ typedef struct
464 470
    float x1,y1,s1,t1; // bottom-right
465 471
 } stbtt_aligned_quad;
466 472
 
467
-extern void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph,  // same data as above
473
+STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph,  // same data as above
468 474
                                int char_index,             // character to display
469 475
                                float *xpos, float *ypos,   // pointers to current position in screen pixel space
470 476
                                stbtt_aligned_quad *q,      // output: quad to draw
@@ -497,8 +503,11 @@ typedef struct
497 503
 
498 504
 typedef struct stbtt_pack_context stbtt_pack_context;
499 505
 typedef struct stbtt_fontinfo stbtt_fontinfo;
506
+#ifndef STB_RECT_PACK_VERSION
507
+typedef struct stbrp_rect stbrp_rect;
508
+#endif
500 509
 
501
-extern int  stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context);
510
+STBTT_DEF int  stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context);
502 511
 // Initializes a packing context stored in the passed-in stbtt_pack_context.
503 512
 // Future calls using this context will pack characters into the bitmap passed
504 513
 // in here: a 1-channel bitmap that is weight x height. stride_in_bytes is
@@ -509,12 +518,12 @@ extern int  stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int
509 518
 //
510 519
 // Returns 0 on failure, 1 on success.
511 520
 
512
-extern void stbtt_PackEnd  (stbtt_pack_context *spc);
521
+STBTT_DEF void stbtt_PackEnd  (stbtt_pack_context *spc);
513 522
 // Cleans up the packing context and frees all memory.
514 523
 
515 524
 #define STBTT_POINT_SIZE(x)   (-(x))
516 525
 
517
-extern int  stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
526
+STBTT_DEF int  stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
518 527
                                 int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range);
519 528
 // Creates character bitmaps from the font_index'th font found in fontdata (use
520 529
 // font_index=0 if you don't know what that is). It creates num_chars_in_range
@@ -537,19 +546,19 @@ typedef struct
537 546
    stbtt_packedchar *chardata_for_range; // output
538 547
 } stbtt_pack_range;
539 548
 
540
-extern int  stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges);
549
+STBTT_DEF int  stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges);
541 550
 // Creates character bitmaps from multiple ranges of characters stored in
542 551
 // ranges. This will usually create a better-packed bitmap than multiple
543 552
 // calls to stbtt_PackFontRange.
544 553
 
545
-extern int  stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
546
-extern int  stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
554
+STBTT_DEF int  stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
555
+STBTT_DEF int  stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
547 556
 // Those functions are called by stbtt_PackFontRanges(). If you want to
548 557
 // pack multiple fonts or custom data into a same texture, you may copy
549 558
 // the contents of stbtt_PackFontRanges() and create a custom version 
550 559
 // using those functions.
551 560
 
552
-extern void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample);
561
+STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample);
553 562
 // Oversampling a font increases the quality by allowing higher-quality subpixel
554 563
 // positioning, and is especially valuable at smaller text sizes.
555 564
 //
@@ -561,7 +570,7 @@ extern void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_ov
561 570
 // oversampled textures with bilinear filtering. Look at the readme in
562 571
 // stb/tests/oversample for information about oversampled fonts
563 572
 
564
-extern void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph,  // same data as above
573
+STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph,  // same data as above
565 574
                                int char_index,             // character to display
566 575
                                float *xpos, float *ypos,   // pointers to current position in screen pixel space
567 576
                                stbtt_aligned_quad *q,      // output: quad to draw
@@ -587,7 +596,7 @@ struct stbtt_pack_context {
587 596
 //
588 597
 //
589 598
 
590
-extern int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index);
599
+STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index);
591 600
 // Each .ttf/.ttc file may have more than one font. Each font has a sequential
592 601
 // index number starting from 0. Call this function to get the font offset for
593 602
 // a given index; it returns -1 if the index is out of range. A regular .ttf
@@ -611,7 +620,7 @@ typedef struct stbtt_fontinfo
611 620
    int indexToLocFormat;              // format needed to map from glyph index to glyph
612 621
 } stbtt_fontinfo;
613 622
 
614
-extern int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset);
623
+STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset);
615 624
 // Given an offset into the file that defines a font, this function builds
616 625
 // the necessary cached info for the rest of the system. You must allocate
617 626
 // the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't
@@ -623,7 +632,7 @@ extern int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int o
623 632
 //
624 633
 // CHARACTER TO GLYPH-INDEX CONVERSIOn
625 634
 
626
-int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
635
+STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
627 636
 // If you're going to perform multiple operations on the same character
628 637
 // and you want a speed-up, call this function with the character you're
629 638
 // going to process, then use glyph-based functions instead of the
@@ -635,7 +644,7 @@ int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
635 644
 // CHARACTER PROPERTIES
636 645
 //
637 646
 
638
-extern float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels);
647
+STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels);
639 648
 // computes a scale factor to produce a font whose "height" is 'pixels' tall.
640 649
 // Height is measured as the distance from the highest ascender to the lowest
641 650
 // descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics
@@ -643,12 +652,12 @@ extern float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels)
643 652
 //       scale = pixels / (ascent - descent)
644 653
 // so if you prefer to measure height by the ascent only, use a similar calculation.
645 654
 
646
-extern float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels);
655
+STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels);
647 656
 // computes a scale factor to produce a font whose EM size is mapped to
648 657
 // 'pixels' tall. This is probably what traditional APIs compute, but
649 658
 // I'm not positive.
650 659
 
651
-extern void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap);
660
+STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap);
652 661
 // ascent is the coordinate above the baseline the font extends; descent
653 662
 // is the coordinate below the baseline the font extends (i.e. it is typically negative)
654 663
 // lineGap is the spacing between one row's descent and the next row's ascent...
@@ -656,23 +665,23 @@ extern void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *
656 665
 //   these are expressed in unscaled coordinates, so you must multiply by
657 666
 //   the scale factor for a given size
658 667
 
659
-extern void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1);
668
+STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1);
660 669
 // the bounding box around all possible characters
661 670
 
662
-extern void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing);
671
+STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing);
663 672
 // leftSideBearing is the offset from the current horizontal position to the left edge of the character
664 673
 // advanceWidth is the offset from the current horizontal position to the next horizontal position
665 674
 //   these are expressed in unscaled coordinates
666 675
 
667
-extern int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2);
676
+STBTT_DEF int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2);
668 677
 // an additional amount to add to the 'advance' value between ch1 and ch2
669 678
 
670
-extern int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1);
679
+STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1);
671 680
 // Gets the bounding box of the visible part of the glyph, in unscaled coordinates
672 681
 
673
-extern void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing);
674
-extern int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);
675
-extern int  stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
682
+STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing);
683
+STBTT_DEF int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);
684
+STBTT_DEF int  stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
676 685
 // as above, but takes one or more glyph indices for greater efficiency
677 686
 
678 687
 
@@ -700,11 +709,11 @@ extern int  stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *
700 709
    } stbtt_vertex;
701 710
 #endif
702 711
 
703
-extern int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index);
712
+STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index);
704 713
 // returns non-zero if nothing is drawn for this glyph
705 714
 
706
-extern int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices);
707
-extern int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices);
715
+STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices);
716
+STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices);
708 717
 // returns # of vertices and fills *vertices with the pointer to them
709 718
 //   these are expressed in "unscaled" coordinates
710 719
 //
@@ -715,7 +724,7 @@ extern int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbt
715 724
 // draws a quadratic bezier from previous endpoint to
716 725
 // its x,y, using cx,cy as the bezier control point.
717 726
 
718
-extern void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
727
+STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
719 728
 // frees the data allocated above
720 729
 
721 730
 //////////////////////////////////////////////////////////////////////////////
@@ -723,10 +732,10 @@ extern void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
723 732
 // BITMAP RENDERING
724 733
 //
725 734
 
726
-extern void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata);
735
+STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata);
727 736
 // frees the bitmap allocated below
728 737
 
729
-extern unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
738
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
730 739
 // allocates a large-enough single-channel 8bpp bitmap and renders the
731 740
 // specified character/glyph at the specified scale into it, with
732 741
 // antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque).
@@ -735,39 +744,39 @@ extern unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float
735 744
 //
736 745
 // xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap
737 746
 
738
-extern unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
747
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
739 748
 // the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel
740 749
 // shift for the character
741 750
 
742
-extern void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint);
751
+STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint);
743 752
 // the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap
744 753
 // in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap
745 754
 // is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the
746 755
 // width and height and positioning info for it first.
747 756
 
748
-extern void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint);
757
+STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint);
749 758
 // same as stbtt_MakeCodepointBitmap, but you can specify a subpixel
750 759
 // shift for the character
751 760
 
752
-extern void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
761
+STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
753 762
 // get the bbox of the bitmap centered around the glyph origin; so the
754 763
 // bitmap width is ix1-ix0, height is iy1-iy0, and location to place
755 764
 // the bitmap top left is (leftSideBearing*scale,iy0).
756 765
 // (Note that the bitmap uses y-increases-down, but the shape uses
757 766
 // y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.)
758 767
 
759
-extern void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
768
+STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
760 769
 // same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel
761 770
 // shift for the character
762 771
 
763 772
 // the following functions are equivalent to the above functions, but operate
764 773
 // on glyph indices instead of Unicode codepoints (for efficiency)
765
-extern unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff);
766
-extern unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff);
767
-extern void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph);
768
-extern void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph);
769
-extern void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
770
-extern void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
774
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff);
775
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff);
776
+STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph);
777
+STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph);
778
+STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
779
+STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
771 780
 
772 781
 
773 782
 // @TODO: don't expose this structure
@@ -777,7 +786,7 @@ typedef struct
777 786
    unsigned char *pixels;
778 787
 } stbtt__bitmap;
779 788
 
780
-extern void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata);
789
+STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata);
781 790
 
782 791
 //////////////////////////////////////////////////////////////////////////////
783 792
 //
@@ -801,7 +810,7 @@ extern void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stb
801 810
 //             You have to have called stbtt_InitFont() first.
802 811
 
803 812
 
804
-extern int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags);
813
+STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags);
805 814
 // returns the offset (not index) of the font that matches, or -1 if none
806 815
 //   if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold".
807 816
 //   if you use any other flag, use a font name like "Arial"; this checks
@@ -812,11 +821,11 @@ extern int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *nam
812 821
 #define STBTT_MACSTYLE_UNDERSCORE   4
813 822
 #define STBTT_MACSTYLE_NONE         8   // <= not same as 0, this makes us check the bitfield is 0
814 823
 
815
-extern int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2);
824
+STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2);
816 825
 // returns 1/0 whether the first string interpreted as utf8 is identical to
817 826
 // the second string interpreted as big-endian utf16... useful for strings from next func
818 827
 
819
-extern const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID);
828
+STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID);
820 829
 // returns the string (which may be big-endian double byte, e.g. for unicode)
821 830
 // and puts the length in bytes in *length.
822 831
 //
@@ -915,10 +924,10 @@ typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERS
915 924
 
916 925
 #else
917 926
 
918
-   stbtt_uint16 ttUSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; }
919
-   stbtt_int16 ttSHORT(const stbtt_uint8 *p)   { return p[0]*256 + p[1]; }
920
-   stbtt_uint32 ttULONG(const stbtt_uint8 *p)  { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
921
-   stbtt_int32 ttLONG(const stbtt_uint8 *p)    { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
927
+   static stbtt_uint16 ttUSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; }
928
+   static stbtt_int16 ttSHORT(const stbtt_uint8 *p)   { return p[0]*256 + p[1]; }
929
+   static stbtt_uint32 ttULONG(const stbtt_uint8 *p)  { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
930
+   static stbtt_int32 ttLONG(const stbtt_uint8 *p)    { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
922 931
 
923 932
 #endif
924 933
 
@@ -949,7 +958,7 @@ static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart,
949 958
    return 0;
950 959
 }
951 960
 
952
-int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index)
961
+STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index)
953 962
 {
954 963
    // if it's just a font, there's only one valid index
955 964
    if (stbtt__isfont(font_collection))
@@ -968,7 +977,7 @@ int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index)
968 977
    return -1;
969 978
 }
970 979
 
971
-int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontstart)
980
+STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontstart)
972 981
 {
973 982
    stbtt_uint8 *data = (stbtt_uint8 *) data2;
974 983
    stbtt_uint32 cmap, t;
@@ -1025,7 +1034,7 @@ int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontsta
1025 1034
    return 1;
1026 1035
 }
1027 1036
 
1028
-int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
1037
+STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
1029 1038
 {
1030 1039
    stbtt_uint8 *data = info->data;
1031 1040
    stbtt_uint32 index_map = info->index_map;
@@ -1117,7 +1126,7 @@ int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
1117 1126
    return 0;
1118 1127
 }
1119 1128
 
1120
-int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices)
1129
+STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices)
1121 1130
 {
1122 1131
    return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices);
1123 1132
 }
@@ -1149,7 +1158,7 @@ static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index)
1149 1158
    return g1==g2 ? -1 : g1; // if length is 0, return -1
1150 1159
 }
1151 1160
 
1152
-int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
1161
+STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
1153 1162
 {
1154 1163
    int g = stbtt__GetGlyfOffset(info, glyph_index);
1155 1164
    if (g < 0) return 0;
@@ -1161,12 +1170,12 @@ int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int
1161 1170
    return 1;
1162 1171
 }
1163 1172
 
1164
-int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1)
1173
+STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1)
1165 1174
 {
1166 1175
    return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1);
1167 1176
 }
1168 1177
 
1169
-int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index)
1178
+STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index)
1170 1179
 {
1171 1180
    stbtt_int16 numberOfContours;
1172 1181
    int g = stbtt__GetGlyfOffset(info, glyph_index);
@@ -1191,7 +1200,7 @@ static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_
1191 1200
    return num_vertices;
1192 1201
 }
1193 1202
 
1194
-int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
1203
+STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
1195 1204
 {
1196 1205
    stbtt_int16 numberOfContours;
1197 1206
    stbtt_uint8 *endPtsOfContours;
@@ -1417,7 +1426,7 @@ int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_verte
1417 1426
    return num_vertices;
1418 1427
 }
1419 1428
 
1420
-void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing)
1429
+STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing)
1421 1430
 {
1422 1431
    stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34);
1423 1432
    if (glyph_index < numOfLongHorMetrics) {
@@ -1429,7 +1438,7 @@ void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *ad
1429 1438
    }
1430 1439
 }
1431 1440
 
1432
-int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
1441
+STBTT_DEF int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
1433 1442
 {
1434 1443
    stbtt_uint8 *data = info->data + info->kern;
1435 1444
    stbtt_uint32 needle, straw;
@@ -1459,26 +1468,26 @@ int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph
1459 1468
    return 0;
1460 1469
 }
1461 1470
 
1462
-int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2)
1471
+STBTT_DEF int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2)
1463 1472
 {
1464 1473
    if (!info->kern) // if no kerning table, don't waste time looking up both codepoint->glyphs
1465 1474
       return 0;
1466 1475
    return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2));
1467 1476
 }
1468 1477
 
1469
-void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing)
1478
+STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing)
1470 1479
 {
1471 1480
    stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing);
1472 1481
 }
1473 1482
 
1474
-void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
1483
+STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
1475 1484
 {
1476 1485
    if (ascent ) *ascent  = ttSHORT(info->data+info->hhea + 4);
1477 1486
    if (descent) *descent = ttSHORT(info->data+info->hhea + 6);
1478 1487
    if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8);
1479 1488
 }
1480 1489
 
1481
-void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1)
1490
+STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1)
1482 1491
 {
1483 1492
    *x0 = ttSHORT(info->data + info->head + 36);
1484 1493
    *y0 = ttSHORT(info->data + info->head + 38);
@@ -1486,19 +1495,19 @@ void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int
1486 1495
    *y1 = ttSHORT(info->data + info->head + 42);
1487 1496
 }
1488 1497
 
1489
-float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height)
1498
+STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height)
1490 1499
 {
1491 1500
    int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6);
1492 1501
    return (float) height / fheight;
1493 1502
 }
1494 1503
 
1495
-float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
1504
+STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
1496 1505
 {
1497 1506
    int unitsPerEm = ttUSHORT(info->data + info->head + 18);
1498 1507
    return pixels / unitsPerEm;
1499 1508
 }
1500 1509
 
1501
-void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
1510
+STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
1502 1511
 {
1503 1512
    STBTT_free(v, info->userdata);
1504 1513
 }
@@ -1508,7 +1517,7 @@ void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
1508 1517
 // antialiasing software rasterizer
1509 1518
 //
1510 1519
 
1511
-void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
1520
+STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
1512 1521
 {
1513 1522
    int x0,y0,x1,y1;
1514 1523
    if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
@@ -1526,17 +1535,17 @@ void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, floa
1526 1535
    }
1527 1536
 }
1528 1537
 
1529
-void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
1538
+STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
1530 1539
 {
1531 1540
    stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
1532 1541
 }
1533 1542
 
1534
-void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
1543
+STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
1535 1544
 {
1536 1545
    stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1);
1537 1546
 }
1538 1547
 
1539
-void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
1548
+STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
1540 1549
 {
1541 1550
    stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1);
1542 1551
 }
@@ -1817,7 +1826,7 @@ static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x
1817 1826
 }
1818 1827
 
1819 1828
 // returns number of contours
1820
-stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata)
1829
+static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata)
1821 1830
 {
1822 1831
    stbtt__point *points=0;
1823 1832
    int num_points=0;
@@ -1886,7 +1895,7 @@ error:
1886 1895
    return NULL;
1887 1896
 }
1888 1897
 
1889
-void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata)
1898
+STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata)
1890 1899
 {
1891 1900
    float scale = scale_x > scale_y ? scale_y : scale_x;
1892 1901
    int winding_count, *winding_lengths;
@@ -1898,12 +1907,12 @@ void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vert
1898 1907
    }
1899 1908
 }
1900 1909
 
1901
-void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata)
1910
+STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata)
1902 1911
 {
1903 1912
    STBTT_free(bitmap, userdata);
1904 1913
 }
1905 1914
 
1906
-unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff)
1915
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff)
1907 1916
 {
1908 1917
    int ix0,iy0,ix1,iy1;
1909 1918
    stbtt__bitmap gbm;
@@ -1940,12 +1949,12 @@ unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float sc
1940 1949
    return gbm.pixels;
1941 1950
 }   
1942 1951
 
1943
-unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
1952
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
1944 1953
 {
1945 1954
    return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff);
1946 1955
 }
1947 1956
 
1948
-void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
1957
+STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
1949 1958
 {
1950 1959
    int ix0,iy0;
1951 1960
    stbtt_vertex *vertices;
@@ -1964,27 +1973,27 @@ void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *ou
1964 1973
    STBTT_free(vertices, info->userdata);
1965 1974
 }
1966 1975
 
1967
-void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
1976
+STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
1968 1977
 {
1969 1978
    stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph);
1970 1979
 }
1971 1980
 
1972
-unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
1981
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
1973 1982
 {
1974 1983
    return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff);
1975 1984
 }   
1976 1985
 
1977
-void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)
1986
+STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)
1978 1987
 {
1979 1988
    stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint));
1980 1989
 }
1981 1990
 
1982
-unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
1991
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
1983 1992
 {
1984 1993
    return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff);
1985 1994
 }   
1986 1995
 
1987
-void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
1996
+STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
1988 1997
 {
1989 1998
    stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint);
1990 1999
 }
@@ -1995,7 +2004,7 @@ void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output
1995 2004
 //
1996 2005
 // This is SUPER-CRAPPY packing to keep source code small
1997 2006
 
1998
-extern int stbtt_BakeFontBitmap(const unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
2007
+STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
1999 2008
                                 float pixel_height,                     // height of font in pixels
2000 2009
                                 unsigned char *pixels, int pw, int ph,  // bitmap to be filled in
2001 2010
                                 int first_char, int num_chars,          // characters to bake
@@ -2040,7 +2049,7 @@ extern int stbtt_BakeFontBitmap(const unsigned char *data, int offset,  // font
2040 2049
    return bottom_y;
2041 2050
 }
2042 2051
 
2043
-void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
2052
+STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
2044 2053
 {
2045 2054
    float d3d_bias = opengl_fillrule ? 0 : -0.5f;
2046 2055
    float ipw = 1.0f / pw, iph = 1.0f / ph;
@@ -2097,11 +2106,11 @@ typedef struct
2097 2106
    unsigned char x;
2098 2107
 } stbrp_node;
2099 2108
 
2100
-typedef struct
2109
+struct stbrp_rect
2101 2110
 {
2102 2111
    stbrp_coord x,y;
2103 2112
    int id,w,h,was_packed;
2104
-} stbrp_rect;
2113
+};
2105 2114
 
2106 2115
 static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes)
2107 2116
 {
@@ -2143,7 +2152,7 @@ static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rect
2143 2152
 // This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If
2144 2153
 // stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy.
2145 2154
 
2146
-int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context)
2155
+STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context)
2147 2156
 {
2148 2157
    stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context)            ,alloc_context);
2149 2158
    int            num_nodes = pw - padding;
@@ -2174,13 +2183,13 @@ int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int
2174 2183
    return 1;
2175 2184
 }
2176 2185
 
2177
-void stbtt_PackEnd  (stbtt_pack_context *spc)
2186
+STBTT_DEF void stbtt_PackEnd  (stbtt_pack_context *spc)
2178 2187
 {
2179 2188
    STBTT_free(spc->nodes    , spc->user_allocator_context);
2180 2189
    STBTT_free(spc->pack_info, spc->user_allocator_context);
2181 2190
 }
2182 2191
 
2183
-void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)
2192
+STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)
2184 2193
 {
2185 2194
    STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE);
2186 2195
    STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE);
@@ -2313,7 +2322,7 @@ static float stbtt__oversample_shift(int oversample)
2313 2322
 }
2314 2323
 
2315 2324
 // rects array must be big enough to accommodate all characters in the given ranges
2316
-int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
2325
+STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
2317 2326
 {
2318 2327
    int i,j,k;
2319 2328
 
@@ -2343,7 +2352,7 @@ int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *inf
2343 2352
 }
2344 2353
 
2345 2354
 // rects array must be big enough to accommodate all characters in the given ranges
2346
-int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
2355
+STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
2347 2356
 {
2348 2357
    float recip_h = 1.0f / spc->h_oversample;
2349 2358
    float recip_v = 1.0f / spc->v_oversample;
@@ -2413,7 +2422,7 @@ int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo
2413 2422
    return return_value;
2414 2423
 }
2415 2424
 
2416
-int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
2425
+STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
2417 2426
 {
2418 2427
    stbtt_fontinfo info;
2419 2428
    int i,j,n, return_value = 1;
@@ -2447,7 +2456,7 @@ int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int f
2447 2456
    return return_value;
2448 2457
 }
2449 2458
 
2450
-int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
2459
+STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
2451 2460
             int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range)
2452 2461
 {
2453 2462
    stbtt_pack_range range;
@@ -2458,7 +2467,7 @@ int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int fo
2458 2467
    return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
2459 2468
 }
2460 2469
 
2461
-void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
2470
+STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
2462 2471
 {
2463 2472
    float ipw = 1.0f / pw, iph = 1.0f / ph;
2464 2473
    stbtt_packedchar *b = chardata + char_index;
@@ -2531,14 +2540,14 @@ static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8
2531 2540
    return i;
2532 2541
 }
2533 2542
 
2534
-int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) 
2543
+STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) 
2535 2544
 {
2536 2545
    return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((const stbtt_uint8*) s1, len1, (const stbtt_uint8*) s2, len2);
2537 2546
 }
2538 2547
 
2539 2548
 // returns results in whatever encoding you request... but note that 2-byte encodings
2540 2549
 // will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare
2541
-const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID)
2550
+STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID)
2542 2551
 {
2543 2552
    stbtt_int32 i,count,stringOffset;
2544 2553
    stbtt_uint8 *fc = font->data;
@@ -2635,7 +2644,7 @@ static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *nam
2635 2644
    return 0;
2636 2645
 }
2637 2646
 
2638
-int stbtt_FindMatchingFont(const unsigned char *font_collection, const char *name_utf8, stbtt_int32 flags)
2647
+STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const char *name_utf8, stbtt_int32 flags)
2639 2648
 {
2640 2649
    stbtt_int32 i;
2641 2650
    for (i=0;;++i) {

+ 3
- 4
src/deps/stb/stb.cpp Parādīt failu

@@ -18,8 +18,7 @@
18 18
 #define STBRP_ASSERT assert
19 19
 #include "stb/stb_rect_pack.h"
20 20
 
21
-//! \TODO bring back when imgui allows it
22
-//#define STB_TRUETYPE_IMPLEMENTATION
23
-//#define STBTT_assert(x) assert(x)
24
-//#include "stb/stb_truetype.h"
21
+#define STB_TRUETYPE_IMPLEMENTATION
22
+#define STBTT_assert(x) assert(x)
23
+#include "stb/stb_truetype.h"
25 24
 

Notiek ielāde…
Atcelt
Saglabāt