Compare commits

...

4 Commits

Author SHA1 Message Date
sonoro1234
bcb179376b cpp2ffi.lua: clean = default in constructor (appears in implot3d) 2025-06-27 18:00:19 +02:00
sonoro1234
dd9196a19b move imgui_freetype include from cimgui.cpp to cimgui.h 2025-06-27 17:10:26 +02:00
sonoro1234
439e8073c2 backends_test for 1.92.0 2025-06-27 11:40:08 +02:00
sonoro1234
63e6dd0ef3 backend tests adapted for 1.92.0
pull imgui 1.92.0 - docking and generate
2025-06-27 11:11:55 +02:00
11 changed files with 84 additions and 21 deletions

View File

@@ -45,10 +45,13 @@ add_compile_definitions("IMGUI_IMPL_OPENGL_LOADER_GL3W")
option(IMGUI_FREETYPE "add Freetype2" OFF)
if(IMGUI_FREETYPE)
message("building with freetype")
FIND_PACKAGE(freetype REQUIRED PATHS ${FREETYPE_PATH})
list(APPEND IMGUI_LIBRARIES freetype)
list(APPEND IMGUI_SOURCES ../../imgui/misc/freetype/imgui_freetype.cpp)
add_definitions("-DCIMGUI_FREETYPE=1")
#add_definitions("-DCIMGUI_FREETYPE=1")
add_definitions("-DIMGUI_ENABLE_FREETYPE=1")
add_definitions("-DIMGUI_ENABLE_STB_TRUETYPE=1")
endif(IMGUI_FREETYPE)
# opengl3

View File

@@ -43,8 +43,9 @@ int main(int argc, char *argv[])
// just an extra window hint for resize
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
float main_scale = ImGui_ImplGlfw_GetContentScaleForMonitor(glfwGetPrimaryMonitor()); // Valid on GLFW 3.3+ only
window = glfwCreateWindow((int)(1280 * main_scale), (int)(800 * main_scale), "Dear ImGui GLFW+OpenGL3 example", NULL, NULL);
window = glfwCreateWindow(1024, 768, "Hello World!", NULL, NULL);
if (!window)
{
printf("Failed to create window! Terminating!\n");
@@ -72,6 +73,15 @@ int main(int argc, char *argv[])
ioptr->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
#endif
// Setup scaling
ImGuiStyle* style = igGetStyle();
ImGuiStyle_ScaleAllSizes(style, main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
style->FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
#if GLFW_VERSION_MAJOR >= 3 && GLFW_VERSION_MINOR >= 3
ioptr->ConfigDpiScaleFonts = true; // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
ioptr->ConfigDpiScaleViewports = true; // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.
#endif
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init(glsl_version);

View File

@@ -392,8 +392,9 @@ int main(int argc, char* argv[])
#endif
// Create window with Vulkan graphics context
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_HIDDEN);
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+Vulkan example", 1280, 720, window_flags);
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
SDL_WindowFlags window_flags = SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+Vulkan example", (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
if (window == NULL)
{
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
@@ -451,6 +452,10 @@ int main(int argc, char* argv[])
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle* style = igGetStyle();
ImGuiStyle_ScaleAllSizes(style, main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
style->FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
io->ConfigDpiScaleFonts = true; // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
io->ConfigDpiScaleViewports = true; // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.
if (io->ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style->WindowRounding = 0.0f;

View File

@@ -10,6 +10,10 @@
#include <GL/gl.h>
#include <GL/glu.h>
#ifdef _WIN32
#include <windows.h> // SetProcessDPIAware()
#endif
#ifdef IMGUI_HAS_IMSTR
#define igBegin igBegin_Str
#define igSliderFloat igSliderFloat_Str
@@ -24,6 +28,9 @@ SDL_Window *window = NULL;
int main(int argc, char* argv[])
{
#ifdef _WIN32
SetProcessDPIAware();
#endif
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
SDL_Log("failed to init: %s", SDL_GetError());
@@ -54,11 +61,10 @@ int main(int argc, char* argv[])
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_DisplayMode current;
SDL_GetCurrentDisplayMode(0, &current);
window = SDL_CreateWindow(
"Hello", 0, 0, 1024, 768,
SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE
);
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
if (window == NULL) {
SDL_Log("Failed to create window: %s", SDL_GetError());
return -1;
@@ -83,6 +89,14 @@ int main(int argc, char* argv[])
ioptr->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
#endif
// Setup scaling
ImGuiStyle* style = igGetStyle();
ImGuiStyle_ScaleAllSizes(style, main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
style->FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
ioptr->ConfigDpiScaleFonts = true; // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
ioptr->ConfigDpiScaleViewports = true; // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
ImGui_ImplOpenGL3_Init(glsl_version);

View File

@@ -11,6 +11,10 @@
#include <volk.h>
#endif
#ifdef _WIN32
#include <windows.h> // SetProcessDPIAware()
#endif
//this must be equal to that in imgui_impl_vulkan.h
#define IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE (1) // Minimum per atlas
@@ -376,6 +380,9 @@ static void FramePresent(ImGui_ImplVulkanH_Window* wd)
// Main code
int main(int argc, char* argv[])
{
#ifdef _WIN32
SetProcessDPIAware();
#endif
//g_MainWindowData.ClearEnable = true;
//ImGui_ImplVulkanH_Window_Construct(&g_MainWindowData);
g_MainWindowData = *ImGui_ImplVulkanH_Window_ImGui_ImplVulkanH_Window();
@@ -391,9 +398,10 @@ int main(int argc, char* argv[])
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
#endif
// Create window with Vulkan graphics context
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
if (window == NULL)
{
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
@@ -445,6 +453,10 @@ int main(int argc, char* argv[])
style->Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup scaling
ImGuiStyle_ScaleAllSizes(style, main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
style->FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
// Setup Platform/Renderer backends
ImGui_ImplSDL2_InitForVulkan(window);
ImGui_ImplVulkan_InitInfo init_info = {};

View File

@@ -13,18 +13,22 @@
#define igGetIO igGetIO_Nil
int main() {
if (!SDL_Init(SDL_INIT_VIDEO)) {
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) {
fprintf(stderr, "Failed to init video! %s", SDL_GetError());
return 1;
};
SDL_Window *window = NULL;
window = SDL_CreateWindow("cimgui SDL3+SDL_GPU example", 1280, 720, SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY);
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
SDL_Window* window = NULL;
window = SDL_CreateWindow("Dear ImGui SDL3+SDL_GPU example", (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
if (window == NULL)
{
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
return -1;
}
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
SDL_ShowWindow(window);
// Create GPU Device
SDL_GPUDevice* gpu_device = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_SPIRV | SDL_GPU_SHADERFORMAT_DXIL | SDL_GPU_SHADERFORMAT_METALLIB,true,NULL);
@@ -52,6 +56,12 @@ int main() {
// Setup Dear ImGui style
igStyleColorsDark(NULL);
//igStyleColorsLight(NULL);
// Setup scaling
ImGuiStyle* style = igGetStyle();
ImGuiStyle_ScaleAllSizes(style, main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
style->FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
io->ConfigDpiScaleFonts = true; // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
io->ConfigDpiScaleViewports = true; // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.
// Setup Platform/Renderer backends
ImGui_ImplSDL3_InitForSDLGPU(window);
@@ -158,7 +168,7 @@ int main() {
if (swapchain_texture != NULL && !is_minimized)
{
// This is mandatory: call Imgui_ImplSDLGPU3_PrepareDrawData() to upload the vertex/index buffer!
Imgui_ImplSDLGPU3_PrepareDrawData(draw_data, command_buffer);
ImGui_ImplSDLGPU3_PrepareDrawData(draw_data, command_buffer);
// Setup and start a render pass
SDL_GPUColorTargetInfo target_info ;//= {};

View File

@@ -5,9 +5,6 @@
//docking branch
#include "./imgui/imgui.h"
#ifdef IMGUI_ENABLE_FREETYPE
#include "./imgui/misc/freetype/imgui_freetype.h"
#endif
#include "./imgui/imgui_internal.h"
#include "cimgui.h"

View File

@@ -39,6 +39,12 @@ typedef unsigned __int64 ImU64;
//typedef unsigned long long ImU64;
#endif
#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
#ifdef IMGUI_ENABLE_FREETYPE
#include "./imgui/misc/freetype/imgui_freetype.h"
#endif
#endif
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS

View File

@@ -1,8 +1,5 @@
#include "./imgui/imgui.h"
#ifdef IMGUI_ENABLE_FREETYPE
#include "./imgui/misc/freetype/imgui_freetype.h"
#endif
#include "./imgui/imgui_internal.h"
#include "cimgui.h"

View File

@@ -34,6 +34,12 @@ typedef unsigned __int64 ImU64;
//typedef unsigned long long ImU64;
#endif
#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
#ifdef IMGUI_ENABLE_FREETYPE
#include "./imgui/misc/freetype/imgui_freetype.h"
#endif
#endif
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
#include "imgui_structs.h"

View File

@@ -1475,6 +1475,8 @@ function M.Parser()
txt = txt:gsub(k,v)
end
end
--clean = default in constructor (implot3d)
txt = txt:gsub("=%s*default","")
--save_data("./preprocode"..tostring(self):gsub("table: ","")..".c",txt)
--clean bad positioned comments inside functionD_re
if self.COMMENTS_GENERATION then
@@ -1557,6 +1559,7 @@ function M.Parser()
local inistruct = clean_spaces(stru:match("(.-)%b{}"))
--clean final:
inistruct = inistruct:gsub("%s*final%s*:",":")
--local stname = stru:match("struct%s*(%S+)%s*%b{}")
local stname, derived
if inistruct:match":" then