Skip to content

Commit 0bb29ed

Browse files
committed
Update dear imgui from v1.77 to v1.92.2b
See https://github.com/ocornut/imgui/releases/tag/v1.92.2b
1 parent 46f4960 commit 0bb29ed

19 files changed

+44211
-16137
lines changed

include/imgui/imconfig.h

Lines changed: 75 additions & 38 deletions
Large diffs are not rendered by default.

include/imgui/imgui.h

Lines changed: 2690 additions & 947 deletions
Large diffs are not rendered by default.

include/imgui/imgui_freetype.h

Lines changed: 76 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,83 @@
1-
// dear imgui: wrapper to use FreeType (instead of stb_truetype)
2-
// Get latest version at https://github.com/ocornut/imgui/tree/master/misc/freetype
3-
// Original code by @Vuhdo (Aleksei Skriabin), maintained by @ocornut
1+
// dear imgui: FreeType font builder (used as a replacement for the stb_truetype builder)
2+
// (headers)
43

54
#pragma once
5+
#include "imgui.h" // IMGUI_API
6+
#ifndef IMGUI_DISABLE
67

7-
#include "imgui.h" // IMGUI_API, ImFontAtlas
8+
// Usage:
9+
// - Add '#define IMGUI_ENABLE_FREETYPE' in your imconfig to automatically enable support
10+
// for imgui_freetype in imgui. It is equivalent to selecting the default loader with:
11+
// io.Fonts->SetFontLoader(ImGuiFreeType::GetFontLoader())
12+
13+
// Optional support for OpenType SVG fonts:
14+
// - Add '#define IMGUI_ENABLE_FREETYPE_PLUTOSVG' to use plutosvg (not provided). See #7927.
15+
// - Add '#define IMGUI_ENABLE_FREETYPE_LUNASVG' to use lunasvg (not provided). See #6591.
16+
17+
// Forward declarations
18+
struct ImFontAtlas;
19+
struct ImFontLoader;
20+
21+
// Hinting greatly impacts visuals (and glyph sizes).
22+
// - By default, hinting is enabled and the font's native hinter is preferred over the auto-hinter.
23+
// - When disabled, FreeType generates blurrier glyphs, more or less matches the stb_truetype.h
24+
// - The Default hinting mode usually looks good, but may distort glyphs in an unusual way.
25+
// - The Light hinting mode generates fuzzier glyphs but better matches Microsoft's rasterizer.
26+
// You can set those flags globally in ImFontAtlas::FontLoaderFlags
27+
// You can set those flags on a per font basis in ImFontConfig::FontLoaderFlags
28+
typedef unsigned int ImGuiFreeTypeLoaderFlags;
29+
enum ImGuiFreeTypeLoaderFlags_
30+
{
31+
ImGuiFreeTypeLoaderFlags_NoHinting = 1 << 0, // Disable hinting. This generally generates 'blurrier' bitmap glyphs when the glyph are rendered in any of the anti-aliased modes.
32+
ImGuiFreeTypeLoaderFlags_NoAutoHint = 1 << 1, // Disable auto-hinter.
33+
ImGuiFreeTypeLoaderFlags_ForceAutoHint = 1 << 2, // Indicates that the auto-hinter is preferred over the font's native hinter.
34+
ImGuiFreeTypeLoaderFlags_LightHinting = 1 << 3, // A lighter hinting algorithm for gray-level modes. Many generated glyphs are fuzzier but better resemble their original shape. This is achieved by snapping glyphs to the pixel grid only vertically (Y-axis), as is done by Microsoft's ClearType and Adobe's proprietary font renderer. This preserves inter-glyph spacing in horizontal text.
35+
ImGuiFreeTypeLoaderFlags_MonoHinting = 1 << 4, // Strong hinting algorithm that should only be used for monochrome output.
36+
ImGuiFreeTypeLoaderFlags_Bold = 1 << 5, // Styling: Should we artificially embolden the font?
37+
ImGuiFreeTypeLoaderFlags_Oblique = 1 << 6, // Styling: Should we slant the font, emulating italic style?
38+
ImGuiFreeTypeLoaderFlags_Monochrome = 1 << 7, // Disable anti-aliasing. Combine this with MonoHinting for best results!
39+
ImGuiFreeTypeLoaderFlags_LoadColor = 1 << 8, // Enable FreeType color-layered glyphs
40+
ImGuiFreeTypeLoaderFlags_Bitmap = 1 << 9, // Enable FreeType bitmap glyphs
41+
42+
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
43+
ImGuiFreeTypeBuilderFlags_NoHinting = ImGuiFreeTypeLoaderFlags_NoHinting,
44+
ImGuiFreeTypeBuilderFlags_NoAutoHint = ImGuiFreeTypeLoaderFlags_NoAutoHint,
45+
ImGuiFreeTypeBuilderFlags_ForceAutoHint = ImGuiFreeTypeLoaderFlags_ForceAutoHint,
46+
ImGuiFreeTypeBuilderFlags_LightHinting = ImGuiFreeTypeLoaderFlags_LightHinting,
47+
ImGuiFreeTypeBuilderFlags_MonoHinting = ImGuiFreeTypeLoaderFlags_MonoHinting,
48+
ImGuiFreeTypeBuilderFlags_Bold = ImGuiFreeTypeLoaderFlags_Bold,
49+
ImGuiFreeTypeBuilderFlags_Oblique = ImGuiFreeTypeLoaderFlags_Oblique,
50+
ImGuiFreeTypeBuilderFlags_Monochrome = ImGuiFreeTypeLoaderFlags_Monochrome,
51+
ImGuiFreeTypeBuilderFlags_LoadColor = ImGuiFreeTypeLoaderFlags_LoadColor,
52+
ImGuiFreeTypeBuilderFlags_Bitmap = ImGuiFreeTypeLoaderFlags_Bitmap,
53+
#endif
54+
};
55+
56+
// Obsolete names (will be removed)
57+
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
58+
typedef ImGuiFreeTypeLoaderFlags_ ImGuiFreeTypeBuilderFlags_;
59+
#endif
860

961
namespace ImGuiFreeType
1062
{
11-
// Hinting greatly impacts visuals (and glyph sizes).
12-
// When disabled, FreeType generates blurrier glyphs, more or less matches the stb's output.
13-
// The Default hinting mode usually looks good, but may distort glyphs in an unusual way.
14-
// The Light hinting mode generates fuzzier glyphs but better matches Microsoft's rasterizer.
15-
16-
// You can set those flags on a per font basis in ImFontConfig::RasterizerFlags.
17-
// Use the 'extra_flags' parameter of BuildFontAtlas() to force a flag on all your fonts.
18-
enum RasterizerFlags
19-
{
20-
// By default, hinting is enabled and the font's native hinter is preferred over the auto-hinter.
21-
NoHinting = 1 << 0, // Disable hinting. This generally generates 'blurrier' bitmap glyphs when the glyph are rendered in any of the anti-aliased modes.
22-
NoAutoHint = 1 << 1, // Disable auto-hinter.
23-
ForceAutoHint = 1 << 2, // Indicates that the auto-hinter is preferred over the font's native hinter.
24-
LightHinting = 1 << 3, // A lighter hinting algorithm for gray-level modes. Many generated glyphs are fuzzier but better resemble their original shape. This is achieved by snapping glyphs to the pixel grid only vertically (Y-axis), as is done by Microsoft's ClearType and Adobe's proprietary font renderer. This preserves inter-glyph spacing in horizontal text.
25-
MonoHinting = 1 << 4, // Strong hinting algorithm that should only be used for monochrome output.
26-
Bold = 1 << 5, // Styling: Should we artificially embolden the font?
27-
Oblique = 1 << 6, // Styling: Should we slant the font, emulating italic style?
28-
Monochrome = 1 << 7 // Disable anti-aliasing. Combine this with MonoHinting for best results!
29-
};
30-
31-
IMGUI_API bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int extra_flags = 0);
32-
33-
// By default ImGuiFreeType will use IM_ALLOC()/IM_FREE().
34-
// However, as FreeType does lots of allocations we provide a way for the user to redirect it to a separate memory heap if desired:
35-
IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = NULL);
63+
// This is automatically assigned when using '#define IMGUI_ENABLE_FREETYPE'.
64+
// If you need to dynamically select between multiple builders:
65+
// - you can manually assign this builder with 'atlas->SetFontLoader(ImGuiFreeType::GetFontLoader())'
66+
// - prefer deep-copying this into your own ImFontLoader instance if you use hot-reloading that messes up static data.
67+
IMGUI_API const ImFontLoader* GetFontLoader();
68+
69+
// Override allocators. By default ImGuiFreeType will use IM_ALLOC()/IM_FREE()
70+
// However, as FreeType does lots of allocations we provide a way for the user to redirect it to a separate memory heap if desired.
71+
IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = nullptr);
72+
73+
// Display UI to edit ImFontAtlas::FontLoaderFlags (shared) or ImFontConfig::FontLoaderFlags (single source)
74+
IMGUI_API bool DebugEditFontLoaderFlags(ImGuiFreeTypeLoaderFlags* p_font_loader_flags);
75+
76+
// Obsolete names (will be removed)
77+
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
78+
//IMGUI_API const ImFontBuilderIO* GetBuilderForFreeType(); // Renamed/changed in 1.92. Change 'io.Fonts->FontBuilderIO = ImGuiFreeType::GetBuilderForFreeType()' to 'io.Fonts->SetFontLoader(ImGuiFreeType::GetFontLoader())' if you need runtime selection.
79+
//static inline bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int flags = 0) { atlas->FontBuilderIO = GetBuilderForFreeType(); atlas->FontLoaderFlags = flags; return atlas->Build(); } // Prefer using '#define IMGUI_ENABLE_FREETYPE'
80+
#endif
3681
}
82+
83+
#endif // #ifndef IMGUI_DISABLE

include/imgui/imgui_impl_opengl3.h

Lines changed: 33 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,68 @@
1-
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
1+
// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline
22
// - Desktop GL: 2.x 3.x 4.x
33
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
4-
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
4+
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
55

66
// Implemented features:
7-
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
8-
// [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices.
7+
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
8+
// [x] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset) [Desktop OpenGL only!]
9+
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
910

10-
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
11-
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
12-
// https://github.com/ocornut/imgui
11+
// About WebGL/ES:
12+
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
13+
// - This is done automatically on iOS, Android and Emscripten targets.
14+
// - For other targets, the define needs to be visible from the imgui_impl_opengl3.cpp compilation unit. If unsure, define globally or in imconfig.h.
1315

14-
// About Desktop OpenGL function loaders:
15-
// Modern Desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
16-
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
17-
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
16+
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
17+
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
18+
// Learn about Dear ImGui:
19+
// - FAQ https://dearimgui.com/faq
20+
// - Getting Started https://dearimgui.com/getting-started
21+
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
22+
// - Introduction, links and more at the top of imgui.cpp
1823

1924
// About GLSL version:
20-
// The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string.
25+
// The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string.
2126
// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
2227
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
2328

2429
#pragma once
25-
#include "cinder/CinderImGuiConfig.h"
26-
2730
#include "imgui.h" // IMGUI_IMPL_API
31+
#ifndef IMGUI_DISABLE
2832

29-
// Backend API
30-
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL);
33+
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
34+
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
3135
IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
3236
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
3337
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
3438

3539
// (Optional) Called by Init/NewFrame/Shutdown
36-
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
37-
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
3840
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
3941
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
4042

41-
// Specific OpenGL ES versions
42-
//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
43-
//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
43+
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
44+
IMGUI_IMPL_API void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex);
45+
46+
// Configuration flags to add in your imconfig file:
47+
//#define IMGUI_IMPL_OPENGL_ES2 // Enable ES 2 (Auto-detected on Emscripten)
48+
//#define IMGUI_IMPL_OPENGL_ES3 // Enable ES 3 (Auto-detected on iOS/Android)
4449

45-
// Attempt to auto-detect the default Desktop GL loader based on available header files.
46-
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
47-
// you are likely to get a crash in ImGui_ImplOpenGL3_Init().
48-
// You can explicitly select a loader by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
50+
// You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
4951
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
50-
&& !defined(IMGUI_IMPL_OPENGL_ES3) \
51-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
52-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
53-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
54-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) \
55-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) \
56-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
52+
&& !defined(IMGUI_IMPL_OPENGL_ES3)
5753

5854
// Try to detect GLES on matching platforms
5955
#if defined(__APPLE__)
60-
#include "TargetConditionals.h"
56+
#include <TargetConditionals.h>
6157
#endif
6258
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
6359
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
64-
#elif defined(__EMSCRIPTEN__)
60+
#elif defined(__EMSCRIPTEN__) || defined(__amigaos4__)
6561
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
66-
67-
// Otherwise try to detect supported Desktop OpenGL loaders..
68-
#elif defined(__has_include)
69-
#if __has_include(<GL/glew.h>)
70-
#define IMGUI_IMPL_OPENGL_LOADER_GLEW
71-
#elif __has_include(<glad/glad.h>)
72-
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
73-
#elif __has_include(<GL/gl3w.h>)
74-
#define IMGUI_IMPL_OPENGL_LOADER_GL3W
75-
#elif __has_include(<glbinding/glbinding.h>)
76-
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING3
77-
#elif __has_include(<glbinding/Binding.h>)
78-
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2
7962
#else
80-
#error "Cannot detect OpenGL loader!"
81-
#endif
82-
#else
83-
#define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W embedded in our repository
63+
// Otherwise imgui_impl_opengl3_loader.h will be used.
8464
#endif
8565

8666
#endif
67+
68+
#endif // #ifndef IMGUI_DISABLE

0 commit comments

Comments
 (0)