Skip to content

Commit b0c2d98

Browse files
committed
small changes
updated: CImGui/Dear ImGui to 1.92.9.dock
1 parent f096c7e commit b0c2d98

25 files changed

Lines changed: 4602 additions & 2587 deletions

demo/c/imgui.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
Pos=60,60
33
Size=400,400
44
Collapsed=0
5+
LastUsed=20260824
56

67
[Window][Dear ImGui Demo]
78
Pos=651,10
89
Size=470,527
910
Collapsed=0
11+
LastUsed=20260824
1012

1113
[Window][Hello, world!]
1214
Pos=12,8
@@ -97,6 +99,7 @@ Collapsed=0
9799
Pos=14,15
98100
Size=602,242
99101
Collapsed=0
102+
LastUsed=20260824
100103

101104
[Table][0xE525F08B,2]
102105
Column 0 Weight=1.5220

demo/c/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void gui_main(Window *window) {
9797
// main
9898
//------
9999
int main(int argc, char *argv[]) {
100-
Window *window = createImGui(1024, 768);
100+
Window *window = createImGui(1024, 768, "Knobs");
101101

102102
gui_main(window);
103103

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
#include "appImGui.h"
2-
#include <stdlib.h>
3-
#include <stdbool.h>
42

53
//------------------
64
// --- setTheme
75
//------------------
86
void setTheme(int32_t num){
97
switch (num){
108
case 0:
11-
igStyleColorsDark(NULL);
9+
ImGui::StyleColorsDark(NULL);
1210
break;
1311
case 1:
14-
igStyleColorsClassic(NULL);
12+
ImGui::StyleColorsClassic(NULL);
1513
break;
1614
case 2:
17-
igStyleColorsLight(NULL);
15+
ImGui::StyleColorsLight(NULL);
1816
break;
1917
default:
2018
break;
@@ -24,7 +22,7 @@ void setTheme(int32_t num){
2422
//---------------
2523
// --- initImGui
2624
//---------------
27-
Window* createImGui(int32_t width, int32_t height){
25+
Window* createImGui(int32_t width, int32_t height, const char* title){
2826
if (!glfwInit())
2927
return NULL;
3028

@@ -40,7 +38,7 @@ Window* createImGui(int32_t width, int32_t height){
4038
// just an extra window hint for resize
4139
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
4240

43-
GLFWwindow* glfwwindow = glfwCreateWindow(width, height, "CImGuiFileDialog example", NULL, NULL);
41+
GLFWwindow* glfwwindow = glfwCreateWindow(width, height, title, NULL, NULL);
4442
if (!glfwwindow)
4543
{
4644
printf("Failed to create window! Terminating!\n");
@@ -57,17 +55,7 @@ Window* createImGui(int32_t width, int32_t height){
5755
printf("opengl version: %s\n", (char *)glGetString(GL_VERSION));
5856

5957
// setup imgui
60-
igCreateContext(NULL);
61-
62-
// set docking
63-
ImGuiIO *ioptr = igGetIO();
64-
ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
65-
//ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
66-
#undef IMGUI_HAS_DOCK
67-
#ifdef IMGUI_HAS_DOCK
68-
ioptr->ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
69-
ioptr->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
70-
#endif
58+
ImGui::CreateContext(NULL);
7159

7260
ImGui_ImplGlfw_InitForOpenGL(glfwwindow, true);
7361
ImGui_ImplOpenGL3_Init(glsl_version);
@@ -90,7 +78,7 @@ void destroyImGui(Window* window){
9078
// clean up
9179
ImGui_ImplOpenGL3_Shutdown();
9280
ImGui_ImplGlfw_Shutdown();
93-
igDestroyContext(NULL);
81+
ImGui::DestroyContext(NULL);
9482

9583
glfwDestroyWindow(window->handle);
9684
glfwTerminate();
@@ -101,24 +89,15 @@ void destroyImGui(Window* window){
10189
// --- render
10290
//------------
10391
void render(Window* window){
104-
ImGuiIO* ioptr = igGetIO();
92+
auto ioptr = ImGui::GetIO();
10593
// render
106-
igRender();
94+
ImGui::Render();
10795
glfwMakeContextCurrent(window->handle);
108-
glViewport(0, 0, (int)ioptr->DisplaySize.x, (int)ioptr->DisplaySize.y);
96+
glViewport(0, 0, (int)ioptr.DisplaySize.x, (int)ioptr.DisplaySize.y);
10997
glClearColor(window->clearColor.x, window->clearColor.y, window->clearColor.z, window->clearColor.w);
11098

11199
glClear(GL_COLOR_BUFFER_BIT);
112-
ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
113-
#ifdef IMGUI_HAS_DOCK
114-
if (ioptr->ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
115-
{
116-
GLFWwindow *backup_current_window = glfwGetCurrentContext();
117-
igUpdatePlatformWindows();
118-
igRenderPlatformWindowsDefault(NULL, NULL);
119-
glfwMakeContextCurrent(backup_current_window);
120-
}
121-
#endif
100+
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
122101
glfwSwapBuffers(window->handle);
123102

124103
if (window->showDelayWindow >= 0) window->showDelayWindow--;
@@ -132,5 +111,5 @@ void newFrame(void){
132111
// start imgui frame
133112
ImGui_ImplOpenGL3_NewFrame();
134113
ImGui_ImplGlfw_NewFrame();
135-
igNewFrame();
114+
ImGui::NewFrame();
136115
}

demo/utils/appImGui.h

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
11
#pragma once
2-
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
3-
#include "cimgui.h"
4-
#include "cimgui_impl.h"
2+
3+
#ifdef __cplusplus
4+
# include "imgui.h"
5+
# include "imgui_impl_glfw.h"
6+
# include "imgui_impl_opengl3.h"
7+
extern "C" {
8+
#else
9+
# ifdef DCIMGUI
10+
# include "dcimgui.h"
11+
# else
12+
# define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
13+
# include "cimgui.h"
14+
15+
# ifdef IMGUI_HAS_IMSTR
16+
# define igBegin igBegin_Str
17+
# define igCheckbox igCheckbox_Str
18+
# define igButton igButton_Str
19+
#endif
20+
21+
#define igGetIO igGetIO_Nil
22+
# endif
23+
#endif
24+
525
#include <GLFW/glfw3.h>
626
#include <stdio.h>
727
#ifdef _MSC_VER
828
#include <windows.h>
929
#endif
1030
#include <GL/gl.h>
1131

12-
#define igGetIO igGetIO_Nil
13-
14-
#ifdef IMGUI_HAS_IMSTR
15-
#define igBegin igBegin_Str
16-
#define igCheckbox igCheckbox_Str
17-
#define igButton igButton_Str
18-
#endif
19-
2032
#include "setupFonts.h"
2133
#include <stdlib.h>
2234

@@ -26,8 +38,12 @@ typedef struct stWindow {
2638
int showDelayWindow;
2739
} Window;
2840

29-
Window* createImGui(int32_t width, int32_t height);
41+
Window* createImGui(int32_t width, int32_t height, const char* title);
3042
void destroyImGui(Window* window);
3143
void render(Window* window);
3244
void newFrame(void);
3345
void setTheme(int32_t num);
46+
47+
#ifdef __cplusplus
48+
}
49+
#endif
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
#include <float.h>
21
#include <stdio.h>
32
#include <stdlib.h>
43
#include <strings.h>
54

6-
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
7-
#include "cimgui.h"
5+
#include "imgui.h"
86
#include "utils.h"
97
#include "setupFonts.h"
108

11-
#define ImGui_GetIO igGetIO_Nil
12-
139
#define MAX_PATH 2048
1410
const char* IconFontPath = "../utils/fonticon/fa6/fa-solid-900.ttf";
1511
char sBufFontPath[MAX_PATH];
@@ -27,7 +23,7 @@ char LinuxFontNameTbl[][MAX_PATH] = { // For Linux Mint 22 (Ubuntu/Debian family
2723
};
2824

2925
/*-----------------
30-
* getFontPath()
26+
* getWinFontPath()
3127
*----------------*/
3228
char* getWinFontPath(char* sBuf, int bufSize, const char* fontName) {
3329
char* sWinDir = getenv("windir");
@@ -43,20 +39,19 @@ float point2px(float point) { //## Convert point to pixel
4339
return (point * 96) / 72;
4440
}
4541

46-
const ImWchar ranges_icon_fonts[] = {(ImWchar)ICON_MIN_FA, (ImWchar)ICON_MAX_FA, (ImWchar)0};
4742
/*--------------
4843
* setupFonts()
4944
*-------------*/
5045
void setupFonts(void) {
51-
ImGuiIO* pio = ImGui_GetIO();
52-
ImFontConfig* config = ImFontConfig_ImFontConfig();
46+
ImGuiIO& pio = ImGui::GetIO();
47+
ImFontConfig* config = new ImFontConfig();
5348
ImFont* font = NULL;
5449
char* fontPath;
5550
int tableLen = sizeof(WinFontNameTbl) / MAX_PATH;
5651
for(int i=0; i<tableLen; i++){
5752
fontPath = getWinFontPath(sBufFontPath, sizeof(sBufFontPath), WinFontNameTbl[i]);
5853
if (existsFile(fontPath)) {
59-
font = ImFontAtlas_AddFontFromFileTTF(pio->Fonts, fontPath, point2px(14.5)
54+
font = pio.Fonts->AddFontFromFileTTF(fontPath, point2px(15.0)
6055
, config
6156
, NULL);
6257
printf("Found FontPath: [%s]\n",fontPath);
@@ -67,7 +62,7 @@ void setupFonts(void) {
6762
for(int i=0; i<tableLen; i++){
6863
fontPath = LinuxFontNameTbl[i];
6964
if (existsFile(fontPath)) {
70-
font = ImFontAtlas_AddFontFromFileTTF(pio->Fonts, fontPath, point2px(13)
65+
font = pio.Fonts->AddFontFromFileTTF(fontPath, point2px(13)
7166
, config
7267
, NULL);
7368
printf("Found FontPath: [%s]\n",fontPath);
@@ -77,9 +72,12 @@ void setupFonts(void) {
7772
if (font == NULL) {
7873
printf("Error!: Font loading falied: in %s\n", __FILE__);
7974
printf("Default has been set.\n");
80-
ImFontAtlas_AddFontDefault(pio->Fonts, NULL);
75+
pio.Fonts->AddFontDefaultVector(NULL);
8176
}
82-
// Merge Icon font
77+
// Merge IconFont
8378
config->MergeMode = true;
84-
ImFontAtlas_AddFontFromFileTTF(pio->Fonts, IconFontPath, point2px(11), config , ranges_icon_fonts);
79+
font = pio.Fonts->AddFontFromFileTTF(IconFontPath, point2px(11), config , NULL);
80+
if (font != NULL){
81+
printf("Found Icon FontPath: [%s]\n",IconFontPath);
82+
}
8583
}

demo/utils/setupFonts.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,13 @@
22
#include <stdbool.h>
33
#include "IconsFontAwesome6.h"
44

5+
#ifdef __cplusplus
6+
extern "C" {
7+
#endif
8+
59
void setupFonts(void);
610
bool existFile(const char* path);
11+
12+
#ifdef __cplusplus
13+
}
14+
#endif

libs/cimgui/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ History:
1111
Initially cimgui was developed by Stephan Dilly as hand-written code but lately turned into an auto-generated version by sonoro1234 in order to keep up with imgui more easily (letting the user select the desired branch and commit)
1212

1313
Notes:
14-
* currently this wrapper is based on version [1.92.4 of Dear ImGui with internal api]
14+
* currently this wrapper is based on version [1.92.9 of Dear ImGui with internal api]
1515
* only functions, structs and enums from imgui.h (an optionally imgui_internal.h) are wrapped.
1616
* if you are interested in imgui backends you should look [LuaJIT-ImGui](https://github.com/sonoro1234/LuaJIT-ImGui) project.
1717
* All naming is algorithmic except for those names that were coded in cimgui_overloads table (https://github.com/cimgui/cimgui/blob/master/generator/generator.lua#L60). In the official version this table is empty.
@@ -106,10 +106,14 @@ Notes:
106106
# example bindings based on cimgui
107107

108108
* [LuaJIT-ImGui](https://github.com/sonoro1234/LuaJIT-ImGui)
109+
* [cimgui-go](https://github.com/AllenDang/cimgui-go)
110+
* [Hexa.NET.ImGui](https://github.com/HexaEngine/Hexa.NET.ImGui)
111+
* [dear-imgui-rs](https://github.com/Latias94/dear-imgui-rs)
112+
* [CImGui.jl](https://github.com/Gnimuc/CImGui.jl)
109113
* [ImGui.NET](https://github.com/mellinoe/ImGui.NET)
114+
* [Zig-ImGui](https://github.com/SpexGuy/Zig-ImGui)
110115
* [nimgl/imgui](https://github.com/nimgl/imgui)
111116
* [kotlin-imgui](https://github.com/Dominaezzz/kotlin-imgui)
112-
* [CImGui.jl](https://github.com/Gnimuc/CImGui.jl)
113117
* [odin-imgui](https://github.com/ThisDrunkDane/odin-imgui)
114118
* [DerelictImgui](https://github.com/Extrawurst/DerelictImgui)
115119
* [BindBC-CimGui](https://github.com/MrcSnm/bindbc-cimgui)

0 commit comments

Comments
 (0)