mirror of
https://github.com/cimgui/cimgui.git
synced 2025-12-01 06:01:38 +00:00
Compare commits
5 Commits
1.92.4dock
...
26c3254fcb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26c3254fcb | ||
|
|
0d6a84344c | ||
|
|
65f439f8b8 | ||
|
|
1407cd296d | ||
|
|
393cae9274 |
@@ -536,7 +536,7 @@ int main(int argc, char* argv[])
|
||||
if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height))
|
||||
{
|
||||
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
|
||||
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, fb_height, fb_height, g_MinImageCount, 0);
|
||||
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount, 0);
|
||||
g_MainWindowData.FrameIndex = 0;
|
||||
g_SwapChainRebuild = false;
|
||||
}
|
||||
|
||||
1149
cimgui.cpp
1149
cimgui.cpp
File diff suppressed because it is too large
Load Diff
@@ -8,44 +8,44 @@ typedef struct GLFWmonitor GLFWmonitor;
|
||||
struct GLFWwindow;
|
||||
struct GLFWmonitor;
|
||||
#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
CIMGUI_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window,bool install_callbacks);
|
||||
CIMGUI_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window,bool install_callbacks);
|
||||
CIMGUI_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window,bool install_callbacks);
|
||||
CIMGUI_API void ImGui_ImplGlfw_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplGlfw_NewFrame(void);
|
||||
CIMGUI_API void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window);
|
||||
CIMGUI_API void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window);
|
||||
CIMGUI_API void ImGui_ImplGlfw_SetCallbacksChainForAllWindows(bool chain_for_all_windows);
|
||||
CIMGUI_API void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window,int focused);
|
||||
CIMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window,unsigned int c);
|
||||
CIMGUI_API void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window,int entered);
|
||||
CIMGUI_API void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window,double x,double y);
|
||||
CIMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window,int button,int action,int mods);
|
||||
CIMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window,double xoffset,double yoffset);
|
||||
CIMGUI_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window,int key,int scancode,int action,int mods);
|
||||
CIMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window,unsigned int c);
|
||||
CIMGUI_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor,int event);
|
||||
CIMGUI_API void ImGui_ImplGlfw_Sleep(int milliseconds);
|
||||
CIMGUI_API float ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window);
|
||||
CIMGUI_API float ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor);
|
||||
CIMGUI_API float ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window);
|
||||
CIMGUI_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window,bool install_callbacks);
|
||||
CIMGUI_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window,bool install_callbacks);
|
||||
CIMGUI_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window,bool install_callbacks);
|
||||
CIMGUI_API void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window);
|
||||
CIMGUI_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window,int key,int scancode,int action,int mods);
|
||||
CIMGUI_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor,int event);
|
||||
CIMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window,int button,int action,int mods);
|
||||
CIMGUI_API void ImGui_ImplGlfw_NewFrame(void);
|
||||
CIMGUI_API void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window);
|
||||
CIMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window,double xoffset,double yoffset);
|
||||
CIMGUI_API void ImGui_ImplGlfw_SetCallbacksChainForAllWindows(bool chain_for_all_windows);
|
||||
CIMGUI_API void ImGui_ImplGlfw_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplGlfw_Sleep(int milliseconds);
|
||||
CIMGUI_API void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window,int focused);
|
||||
|
||||
#endif
|
||||
#ifdef CIMGUI_USE_OPENGL3
|
||||
CIMGUI_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_NewFrame(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
|
||||
CIMGUI_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(void);
|
||||
CIMGUI_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_NewFrame(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex);
|
||||
|
||||
#endif
|
||||
#ifdef CIMGUI_USE_OPENGL2
|
||||
CIMGUI_API bool ImGui_ImplOpenGL2_Init(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_NewFrame(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data);
|
||||
CIMGUI_API bool ImGui_ImplOpenGL2_CreateDeviceObjects(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_DestroyDeviceObjects(void);
|
||||
CIMGUI_API bool ImGui_ImplOpenGL2_Init(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_NewFrame(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_UpdateTexture(ImTextureData* tex);
|
||||
|
||||
#endif
|
||||
@@ -61,18 +61,18 @@ struct _SDL_GameController;
|
||||
typedef union SDL_Event SDL_Event;
|
||||
typedef enum { ImGui_ImplSDL2_GamepadMode_AutoFirst, ImGui_ImplSDL2_GamepadMode_AutoAll, ImGui_ImplSDL2_GamepadMode_Manual }ImGui_ImplSDL2_GamepadMode;
|
||||
#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window,void* sdl_gl_context);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
||||
CIMGUI_API float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index);
|
||||
CIMGUI_API float ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window,SDL_Renderer* renderer);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window,void* sdl_gl_context);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForOther(SDL_Window* window);
|
||||
CIMGUI_API void ImGui_ImplSDL2_Shutdown(void);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window,SDL_Renderer* renderer);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
||||
CIMGUI_API void ImGui_ImplSDL2_NewFrame(void);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
||||
CIMGUI_API float ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window);
|
||||
CIMGUI_API float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index);
|
||||
CIMGUI_API void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode,struct _SDL_GameController** manual_gamepads_array,int manual_gamepads_count);
|
||||
CIMGUI_API void ImGui_ImplSDL2_Shutdown(void);
|
||||
|
||||
#endif
|
||||
#ifdef CIMGUI_USE_SDL3
|
||||
@@ -87,17 +87,17 @@ struct SDL_Gamepad;
|
||||
typedef union SDL_Event SDL_Event;
|
||||
typedef enum { ImGui_ImplSDL3_GamepadMode_AutoFirst, ImGui_ImplSDL3_GamepadMode_AutoAll, ImGui_ImplSDL3_GamepadMode_Manual }ImGui_ImplSDL3_GamepadMode;
|
||||
#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
CIMGUI_API bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window,void* sdl_gl_context);
|
||||
CIMGUI_API bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window);
|
||||
CIMGUI_API bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window);
|
||||
CIMGUI_API bool ImGui_ImplSDL3_InitForMetal(SDL_Window* window);
|
||||
CIMGUI_API bool ImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window,SDL_Renderer* renderer);
|
||||
CIMGUI_API bool ImGui_ImplSDL3_InitForSDLGPU(SDL_Window* window);
|
||||
CIMGUI_API bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window,void* sdl_gl_context);
|
||||
CIMGUI_API bool ImGui_ImplSDL3_InitForOther(SDL_Window* window);
|
||||
CIMGUI_API void ImGui_ImplSDL3_Shutdown(void);
|
||||
CIMGUI_API bool ImGui_ImplSDL3_InitForSDLGPU(SDL_Window* window);
|
||||
CIMGUI_API bool ImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window,SDL_Renderer* renderer);
|
||||
CIMGUI_API bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window);
|
||||
CIMGUI_API void ImGui_ImplSDL3_NewFrame(void);
|
||||
CIMGUI_API bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event);
|
||||
CIMGUI_API void ImGui_ImplSDL3_SetGamepadMode(ImGui_ImplSDL3_GamepadMode mode,SDL_Gamepad** manual_gamepads_array,int manual_gamepads_count);
|
||||
CIMGUI_API void ImGui_ImplSDL3_Shutdown(void);
|
||||
|
||||
#endif
|
||||
#ifdef CIMGUI_USE_VULKAN
|
||||
@@ -189,25 +189,25 @@ struct ImGui_ImplVulkanH_Window
|
||||
typedef ImVector<ImGui_ImplVulkanH_Frame> ImVector_ImGui_ImplVulkanH_Frame;
|
||||
typedef ImVector<ImGui_ImplVulkanH_FrameSemaphores> ImVector_ImGui_ImplVulkanH_FrameSemaphores;
|
||||
#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
CIMGUI_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info);
|
||||
CIMGUI_API void ImGui_ImplVulkan_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplVulkan_NewFrame(void);
|
||||
CIMGUI_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data,VkCommandBuffer command_buffer,VkPipeline pipeline);
|
||||
CIMGUI_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count);
|
||||
CIMGUI_API void ImGui_ImplVulkan_CreateMainPipeline(const ImGui_ImplVulkan_PipelineInfo* info);
|
||||
CIMGUI_API void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex);
|
||||
CIMGUI_API VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler,VkImageView image_view,VkImageLayout image_layout);
|
||||
CIMGUI_API void ImGui_ImplVulkan_RemoveTexture(VkDescriptorSet descriptor_set);
|
||||
CIMGUI_API bool ImGui_ImplVulkan_LoadFunctions(uint32_t api_version,PFN_vkVoidFunction(*loader_func)(const char* function_name,void* user_data),void* user_data);
|
||||
CIMGUI_API void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance,VkPhysicalDevice physical_device,VkDevice device,ImGui_ImplVulkanH_Window* wd,uint32_t queue_family,const VkAllocationCallbacks* allocator,int w,int h,uint32_t min_image_count,VkImageUsageFlags image_usage);
|
||||
CIMGUI_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance,VkDevice device,ImGui_ImplVulkanH_Window* wd,const VkAllocationCallbacks* allocator);
|
||||
CIMGUI_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device,VkSurfaceKHR surface,const VkFormat* request_formats,int request_formats_count,VkColorSpaceKHR request_color_space);
|
||||
CIMGUI_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device,VkSurfaceKHR surface,const VkPresentModeKHR* request_modes,int request_modes_count);
|
||||
CIMGUI_API VkPhysicalDevice ImGui_ImplVulkanH_SelectPhysicalDevice(VkInstance instance);
|
||||
CIMGUI_API uint32_t ImGui_ImplVulkanH_SelectQueueFamilyIndex(VkPhysicalDevice physical_device);
|
||||
CIMGUI_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
|
||||
CIMGUI_API ImGui_ImplVulkanH_Window* ImGui_ImplVulkanH_GetWindowDataFromViewport(ImGuiViewport* viewport);
|
||||
CIMGUI_API VkPhysicalDevice ImGui_ImplVulkanH_SelectPhysicalDevice(VkInstance instance);
|
||||
CIMGUI_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device,VkSurfaceKHR surface,const VkPresentModeKHR* request_modes,int request_modes_count);
|
||||
CIMGUI_API uint32_t ImGui_ImplVulkanH_SelectQueueFamilyIndex(VkPhysicalDevice physical_device);
|
||||
CIMGUI_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device,VkSurfaceKHR surface,const VkFormat* request_formats,int request_formats_count,VkColorSpaceKHR request_color_space);
|
||||
CIMGUI_API ImGui_ImplVulkanH_Window* ImGui_ImplVulkanH_Window_ImGui_ImplVulkanH_Window(void);
|
||||
CIMGUI_API VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler,VkImageView image_view,VkImageLayout image_layout);
|
||||
CIMGUI_API void ImGui_ImplVulkan_CreateMainPipeline(const ImGui_ImplVulkan_PipelineInfo* info);
|
||||
CIMGUI_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info);
|
||||
CIMGUI_API bool ImGui_ImplVulkan_LoadFunctions(uint32_t api_version,PFN_vkVoidFunction(*loader_func)(const char* function_name,void* user_data),void* user_data);
|
||||
CIMGUI_API void ImGui_ImplVulkan_NewFrame(void);
|
||||
CIMGUI_API void ImGui_ImplVulkan_RemoveTexture(VkDescriptorSet descriptor_set);
|
||||
CIMGUI_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data,VkCommandBuffer command_buffer,VkPipeline pipeline);
|
||||
CIMGUI_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count);
|
||||
CIMGUI_API void ImGui_ImplVulkan_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex);
|
||||
|
||||
#endif
|
||||
#endif //CIMGUI_IMPL_DEFINED
|
||||
|
||||
@@ -49,6 +49,8 @@ struct SDL_Window;
|
||||
typedef union SDL_Event SDL_Event;
|
||||
#endif // CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
|
||||
PLACE_STRUCTS_C
|
||||
|
||||
#include "auto_funcs.h"
|
||||
|
||||
/////////////////////////hand written functions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local M = {}
|
||||
|
||||
local insert = table.insert
|
||||
local function ToStr(t,dometatables)
|
||||
local function basicToStr (o)
|
||||
if type(o) == "number" or type(o)=="boolean" then
|
||||
@@ -936,7 +936,7 @@ local function itemsCount(items)
|
||||
print(v,its and #its or 0)
|
||||
end
|
||||
end
|
||||
|
||||
--adding self argument for struct functions
|
||||
local function AdjustArguments(FP)
|
||||
for fun,defs in pairs(FP.defsT) do
|
||||
--struct function but no constructors or static functions or manuals
|
||||
@@ -1083,6 +1083,7 @@ local function DefsByStruct(FP)
|
||||
end
|
||||
return structs
|
||||
end
|
||||
M.DefsByStruct = DefsByStruct
|
||||
local function get_nonPOD(FP)
|
||||
local defbystruct = DefsByStruct(FP)
|
||||
--M.prtable(defbystruct)
|
||||
@@ -1102,8 +1103,200 @@ local function get_nonPOD(FP)
|
||||
FP.structs_and_enums_table.nonPOD = nonPOD
|
||||
return nonPOD
|
||||
end
|
||||
M.get_nonPOD = get_nonPOD
|
||||
local function gen_structs_c(FP)
|
||||
local structs = FP.structs_and_enums_table.structs
|
||||
local tabs = {}
|
||||
local tabs_c = {}
|
||||
--for k,v in pairs(FP.nP_used) do
|
||||
M.table_do_sorted(FP.nP_used, function(k,v)
|
||||
insert(tabs,"typedef struct "..k.."_c "..k.."_c;")
|
||||
insert(tabs_c,"typedef struct "..k.."_c "..k..";")
|
||||
insert(tabs,"struct "..k.."_c {")
|
||||
local struct = structs[k]
|
||||
for i,field in ipairs(struct) do
|
||||
insert(tabs," "..field.type.." "..field.name..";")
|
||||
end
|
||||
insert(tabs,"};")
|
||||
end)
|
||||
if #tabs > 0 then
|
||||
insert(tabs,1,"#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS")
|
||||
insert(tabs,"#endif")
|
||||
end
|
||||
if #tabs_c > 0 then
|
||||
insert(tabs_c,1,"#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS")
|
||||
insert(tabs_c,"#endif")
|
||||
end
|
||||
--print(table.concat(tabs_c,"\n"))
|
||||
--print(table.concat(tabs,"\n"))
|
||||
return table.concat(tabs_c,"\n").."\n"..table.concat(tabs,"\n")
|
||||
--return table.concat(tabs,"\n")
|
||||
end
|
||||
local function gen_field_conversion(tab, struct, FP, prefix)
|
||||
prefix = prefix or ""
|
||||
local structs = FP.structs_and_enums_table.structs
|
||||
for i,field in ipairs(struct) do
|
||||
if FP.nP_used[field.type] then
|
||||
gen_field_conversion(tab, structs[field.type],FP, prefix..field.name..".")
|
||||
else
|
||||
insert(tab," dest."..prefix..field.name.." = src."..prefix..field.name..";")
|
||||
end
|
||||
end
|
||||
end
|
||||
local function genConversions(FP)
|
||||
local structs = FP.structs_and_enums_table.structs
|
||||
local convers = {}
|
||||
--for k,v in pairs(FP.nP_used) do
|
||||
M.table_do_sorted(FP.nP_used, function(k,v)
|
||||
insert(convers,"static inline "..k.." ConvertToCPP_"..k.."(const "..k.."_c& src)")
|
||||
insert(convers,"{")
|
||||
insert(convers," "..k.." dest;")
|
||||
local struct = structs[k]
|
||||
gen_field_conversion(convers,struct,FP)
|
||||
insert(convers," return dest;")
|
||||
insert(convers,"}")
|
||||
insert(convers,"static inline "..k.."_c ConvertFromCPP_"..k.."(const "..k.."& src)")
|
||||
insert(convers,"{")
|
||||
insert(convers," "..k.."_c dest;")
|
||||
local struct = structs[k]
|
||||
gen_field_conversion(convers,struct,FP)
|
||||
insert(convers," return dest;")
|
||||
insert(convers,"}")
|
||||
end)
|
||||
--print(table.concat(convers,"\n"))
|
||||
return table.concat(convers,"\n")
|
||||
end
|
||||
local function get_nonPODused(FP)
|
||||
--print("get_nonPODused-----------------------------")
|
||||
local nonPOD = FP.structs_and_enums_table.nonPOD
|
||||
--M.prtable(nonPOD)
|
||||
local typeargs = {}
|
||||
local typeargs_ret = {}
|
||||
for k,defs in pairs(FP.defsT) do
|
||||
--print(k)
|
||||
for i, w in ipairs(defs) do
|
||||
if not w.templated then --and not w.location:match"internal" then
|
||||
for ii,arg in ipairs(w.argsT) do
|
||||
local typ = (arg.type):gsub("&","")
|
||||
--typ = (typ):gsub("*","")
|
||||
typ = (typ):gsub("const ","")
|
||||
if nonPOD[typ] then
|
||||
--print(arg.type,w.ov_cimguiname,w.location)
|
||||
typeargs[arg.type] = (arg.type):gsub(typ,typ.."_c")
|
||||
end
|
||||
end
|
||||
local typret = (w.ret or ""):gsub("&","")
|
||||
--typret = (typret):gsub("*","")
|
||||
typret = (typret):gsub("const ","")
|
||||
--print(typret)
|
||||
if nonPOD[typret] then
|
||||
--print(w.ret,w.ov_cimguiname,w.location)
|
||||
typeargs_ret[w.ret] = (w.ret):gsub(typret,typret.."_c")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local all_type_nP = {}
|
||||
for k,v in pairs(typeargs) do
|
||||
local k2 = k:gsub("const ","")
|
||||
all_type_nP[k2] = true
|
||||
end
|
||||
for k,v in pairs(typeargs_ret) do
|
||||
local k2 = k:gsub("const ","")
|
||||
all_type_nP[k2] = true
|
||||
end
|
||||
FP.nP_used = all_type_nP
|
||||
FP.nP_args = typeargs
|
||||
FP.nP_ret = typeargs_ret
|
||||
--genConversions(FP)
|
||||
--M.prtable(typeargs,typeargs_ret,all_type_nP)
|
||||
-- local typeargs2 = {}
|
||||
-- for k,v in pairs(typeargs) do table.insert(typeargs2,k) end
|
||||
-- table.sort(typeargs2)
|
||||
-- print"------------typeargs2----------------"
|
||||
-- M.prtable(typeargs2)
|
||||
|
||||
-- local typeargs2_ret = {}
|
||||
-- for k,v in pairs(typeargs_ret) do table.insert(typeargs2_ret,k) end
|
||||
-- table.sort(typeargs2_ret)
|
||||
-- print"------------typeargs2_ret----------------"
|
||||
-- M.prtable(typeargs2_ret)
|
||||
|
||||
end
|
||||
local function header_subs_nonPOD(FP,txt)
|
||||
--print("----------header_subs_nonPOD")
|
||||
--M.prtable(FP.nP_used)
|
||||
for k,v in pairs(FP.nP_used) do
|
||||
--txt = txt:gsub("([%s;])"..k,"%1"..k.."_c")
|
||||
for i=1,2 do
|
||||
txt = txt:gsub("([%s;])"..k.."([%s;%*])", "%1"..k.."_c%2")
|
||||
end
|
||||
--txt = txt:gsub("%s"..k..";", " "..k.."_c;")
|
||||
--txt = txt:gsub("%s"..k.."%*", " "..k.."_c*")
|
||||
end
|
||||
return txt
|
||||
end
|
||||
M.header_subs_nonPOD = header_subs_nonPOD
|
||||
local function ADDnonUDT(FP)
|
||||
local nonPOD = get_nonPOD(FP)
|
||||
get_nonPODused(FP)
|
||||
for k,defs in pairs(FP.defsT) do
|
||||
for i, def in ipairs(defs) do
|
||||
--ret
|
||||
local rets = (def.ret or ""):gsub("const ","")
|
||||
rets = rets:gsub("*","")
|
||||
if FP.nP_ret[def.ret] then
|
||||
def.conv = (def.ret):gsub("const ","")
|
||||
def.ret = FP.nP_ret[def.ret]
|
||||
def.nonUDT = 1
|
||||
elseif FP.nP_ret[rets] then
|
||||
def.ret = def.ret:gsub(rets, FP.nP_ret[rets])
|
||||
def.nonUDT = 2
|
||||
end
|
||||
--args
|
||||
local caar,asp
|
||||
if #def.argsT > 0 then
|
||||
caar = "("
|
||||
asp = "("
|
||||
for i,v in ipairs(def.argsT) do
|
||||
local name = v.name
|
||||
if v.ret then --function pointer
|
||||
local f_ = v.has_cdecl and "(__cdecl*" or "(*"
|
||||
asp = asp .. v.ret .. f_ .. v.name .. ")" .. v.signature .. ","
|
||||
caar = caar .. name .. ","
|
||||
else
|
||||
local typ = v.type:gsub("const ","")
|
||||
local typ2 = typ:gsub("*","")
|
||||
if FP.nP_args[v.type] then
|
||||
caar = caar .. "ConvertToCPP_"..typ.."("..name.."),"
|
||||
asp = asp .. v.type:gsub(typ,typ.."_c").." "..v.name..","
|
||||
elseif FP.nP_args[typ2] then
|
||||
local typ3 = v.type:gsub(typ2,typ2.."_c")
|
||||
caar = caar .. "reinterpret_cast<"..v.type..">("..name.."),"
|
||||
asp = asp .. typ3 .." "..v.name..","
|
||||
else
|
||||
local siz = v.type:match("(%[%d*%])") or ""
|
||||
local typ = v.type:gsub("(%[%d*%])","")
|
||||
asp = asp .. typ .. (v.name~="..." and " "..v.name or "") .. siz .. ","
|
||||
local callname = v.reftoptr and "*"..name or name
|
||||
caar = caar .. callname .. ","
|
||||
end
|
||||
end
|
||||
end
|
||||
caar = caar:sub(1,-2)..")"
|
||||
asp = asp:sub(1,-2)..")"
|
||||
else
|
||||
caar = "()"
|
||||
asp = "()"
|
||||
end
|
||||
def.call_args = caar
|
||||
def.args = asp
|
||||
end
|
||||
end
|
||||
end
|
||||
local function ADDnonUDT_OLD(FP)
|
||||
local nonPOD = get_nonPOD(FP)
|
||||
get_nonPODused(FP)
|
||||
--print"nonPOD"
|
||||
--M.prtable(nonPOD)
|
||||
local defsT = FP.defsT
|
||||
@@ -1125,6 +1318,7 @@ local function ADDnonUDT(FP)
|
||||
if (not isUDT) and FP.cimgui_inherited and FP.cimgui_inherited.nonPOD[defT.ret] then
|
||||
isUDT = true
|
||||
end
|
||||
--given in generator.lua , could be skipped
|
||||
for _,udt_ret in ipairs(FP.UDTs) do
|
||||
if udt_ret == defT.ret then isUDT=true; break end
|
||||
end
|
||||
@@ -1289,6 +1483,8 @@ function M.Parser()
|
||||
par.skipped = {}
|
||||
par.UDTs = {}
|
||||
|
||||
par.genConversors = genConversions
|
||||
par.gen_structs_c = gen_structs_c
|
||||
function par:insert(line,loca)
|
||||
--table.insert(cdefs,{line,loca})
|
||||
--table.insert(cdefs,{line:gsub("^%s*(.-)%s*$", "%1"),loca})
|
||||
@@ -1343,8 +1539,9 @@ function M.Parser()
|
||||
function par:do_parse()
|
||||
self:parseItems()
|
||||
self:gen_structs_and_enums_table()
|
||||
self:gen_structs_and_enums()
|
||||
self:compute_overloads()
|
||||
self:gen_structs_and_enums()
|
||||
--self:compute_overloads()
|
||||
--self:compute_templated()
|
||||
ADDdestructors(self)
|
||||
end
|
||||
@@ -1714,6 +1911,30 @@ function M.Parser()
|
||||
function par:header_text_insert(tab,txt,it)
|
||||
table.insert(tab, txt)
|
||||
end
|
||||
local function function_parse(self,it)
|
||||
local stname = ""
|
||||
local namespace
|
||||
if it.parent then
|
||||
if it.parent.re_name == "struct_re" or it.parent.re_name == "typedef_st_re" or it.parent.re_name == "class_re" then
|
||||
stname = it.parent.name
|
||||
elseif it.parent.re_name == "namespace_re" then
|
||||
namespace = get_parents_nameC(it) --it.parent.name
|
||||
end
|
||||
end
|
||||
if it.item:match"^%s*template%s+<" then
|
||||
local ttype,fun = it.item:match"^%s*template%s+<%s*typename%s+([^>]+)%s*>%s*(.+)$"
|
||||
if self.ftemplate_list and self.ftemplate_list[ttype] then
|
||||
for iT,vT in ipairs(self.ftemplate_list[ttype]) do
|
||||
local funT = fun:gsub("([< %(])"..ttype,"%1"..vT)
|
||||
--funT = funT:gsub("sizeof%("..ttype.."%)","sizeof("..vT..")")
|
||||
--local funT = fun:gsub(ttype,vT)
|
||||
self:parseFunction(stname,{item=funT},namespace,it.locat)
|
||||
end
|
||||
end
|
||||
else
|
||||
self:parseFunction(stname,it,namespace,it.locat)
|
||||
end
|
||||
end
|
||||
function par:gen_structs_and_enums()
|
||||
print"--------------gen_structs_and_enums"
|
||||
--M.prtable(self.typenames)
|
||||
@@ -1820,9 +2041,11 @@ function M.Parser()
|
||||
if not structname then print("NO NAME",cleanst,it.item) end
|
||||
--if not void stname or templated
|
||||
if structname and not self.typenames[structname] then
|
||||
|
||||
--table.insert(typedefs_table,"typedef struct "..structname.." "..structname..";\n")
|
||||
local tst = "\ntypedef struct "..structname.." "..structname..";"
|
||||
--dont add typedef to non POD
|
||||
local tst = ""
|
||||
--if not self.nP_used[structname] then
|
||||
tst = "\ntypedef struct "..structname.." "..structname..";"
|
||||
--end
|
||||
if check_unique_typedefs(tst,uniques) then
|
||||
--table.insert(outtab,tst)
|
||||
self:header_text_insert(outtab, tst, it)
|
||||
@@ -1851,28 +2074,7 @@ function M.Parser()
|
||||
elseif it.re_name == "namespace_re" or it.re_name == "union_re" or it.re_name == "functype_re" then
|
||||
--nop
|
||||
elseif it.re_name == "functionD_re" or it.re_name == "function_re" then
|
||||
local stname = ""
|
||||
local namespace
|
||||
if it.parent then
|
||||
if it.parent.re_name == "struct_re" or it.parent.re_name == "typedef_st_re" or it.parent.re_name == "class_re" then
|
||||
stname = it.parent.name
|
||||
elseif it.parent.re_name == "namespace_re" then
|
||||
namespace = get_parents_nameC(it) --it.parent.name
|
||||
end
|
||||
end
|
||||
if it.item:match"^%s*template%s+<" then
|
||||
local ttype,fun = it.item:match"^%s*template%s+<%s*typename%s+([^>]+)%s*>%s*(.+)$"
|
||||
if self.ftemplate_list and self.ftemplate_list[ttype] then
|
||||
for iT,vT in ipairs(self.ftemplate_list[ttype]) do
|
||||
local funT = fun:gsub("([< %(])"..ttype,"%1"..vT)
|
||||
--funT = funT:gsub("sizeof%("..ttype.."%)","sizeof("..vT..")")
|
||||
--local funT = fun:gsub(ttype,vT)
|
||||
self:parseFunction(stname,{item=funT},namespace,it.locat)
|
||||
end
|
||||
end
|
||||
else
|
||||
self:parseFunction(stname,it,namespace,it.locat)
|
||||
end
|
||||
--function_parse(self,it)
|
||||
else
|
||||
if it.re_name~="operator_re" then
|
||||
print("not processed gen",it.re_name,it.item:sub(1,20))
|
||||
@@ -1892,7 +2094,10 @@ function M.Parser()
|
||||
--check arg detection failure if no name in function declaration
|
||||
check_arg_detection(self.defsT,self.typedefs_dict)
|
||||
local outtabprest, outtabst = table.concat(outtabpre,""),table.concat(outtab,"")
|
||||
outtabprest = M.header_subs_nonPOD(self,outtabprest)
|
||||
outtabst = M.header_subs_nonPOD(self,outtabst)
|
||||
self.structs_and_enums = {outtabprest, outtabst or ""}
|
||||
|
||||
return outtabprest, outtabst
|
||||
end
|
||||
-----------
|
||||
@@ -2086,7 +2291,9 @@ function M.Parser()
|
||||
end
|
||||
elseif it.re_name == "namespace_re" or it.re_name == "union_re" or it.re_name == "functype_re" then
|
||||
--nop
|
||||
elseif it.re_name ~= "functionD_re" and it.re_name ~= "function_re" and it.re_name ~= "operator_re" then
|
||||
elseif it.re_name ~= "functionD_re" or it.re_name ~= "function_re" then
|
||||
function_parse(self,it)
|
||||
elseif it.re_name ~= "operator_re" then
|
||||
print("not processed gen table",it.re_name)
|
||||
end
|
||||
end
|
||||
@@ -2215,9 +2422,9 @@ function M.Parser()
|
||||
end)
|
||||
--print(numoverloaded, "overloaded")
|
||||
table.insert(strt,string.format("%d overloaded",numoverloaded))
|
||||
--ADDIMSTR_S(self)
|
||||
AdjustArguments(self)
|
||||
ADDnonUDT(self)
|
||||
AdjustArguments(self)
|
||||
--ADDnonUDT(self)
|
||||
|
||||
--ADDdestructors(self)
|
||||
self.overloadstxt = table.concat(strt,"\n")
|
||||
@@ -2683,7 +2890,10 @@ local function ImGui_f_implementation(def)
|
||||
table.insert(outtab, "#endif\n")
|
||||
elseif def.nonUDT then
|
||||
if def.nonUDT == 1 then
|
||||
table.insert(outtab," *pOut = "..namespace..def.funcname..def.call_args..";\n")
|
||||
--table.insert(outtab," *pOut = "..namespace..def.funcname..def.call_args..";\n")
|
||||
insert(outtab," return ConvertFromCPP_"..def.conv.."("..namespace..def.funcname..def.call_args..");\n")
|
||||
elseif def.nonUDT == 2 then
|
||||
insert(outtab," return reinterpret_cast<"..def.ret..">("..ptret..namespace..def.funcname..def.call_args..");\n")
|
||||
end
|
||||
table.insert(outtab,"}\n")
|
||||
else --standard ImGui
|
||||
@@ -2717,7 +2927,11 @@ local function struct_f_implementation(def)
|
||||
end
|
||||
elseif def.nonUDT then
|
||||
if def.nonUDT == 1 then
|
||||
table.insert(outtab," *pOut = self->"..def.funcname..def.call_args..";\n")
|
||||
--table.insert(outtab," *pOut = self->"..def.funcname..def.call_args..";\n")
|
||||
--local typret = (def.ret):gsub("const ","")
|
||||
insert(outtab," return ConvertFromCPP_"..def.conv.."(self->"..def.funcname..def.call_args..");\n")
|
||||
elseif def.nonUDT == 2 then
|
||||
insert(outtab," return reinterpret_cast<"..def.ret..">("..ptret.."self->"..def.funcname..def.call_args..");\n")
|
||||
end
|
||||
else --standard struct
|
||||
table.insert(outtab," return "..ptret.."self->"..def.funcname..def.call_args..";\n")
|
||||
@@ -2793,7 +3007,7 @@ M.table_do_sorted = table_do_sorted
|
||||
|
||||
local function func_header_generate_structs(FP)
|
||||
|
||||
local outtab = {}
|
||||
local outtab = {}--"\n/////func_header_generate_structs\n"}
|
||||
|
||||
table_do_sorted(FP.embeded_structs,function(k,v)
|
||||
table.insert(outtab,"typedef "..v.." "..k..";\n")
|
||||
@@ -2811,6 +3025,7 @@ local function func_header_generate_structs(FP)
|
||||
end
|
||||
M.func_header_generate_structs = func_header_generate_structs
|
||||
|
||||
|
||||
local function func_header_generate_funcs(FP)
|
||||
|
||||
local outtab = {}
|
||||
@@ -2839,17 +3054,18 @@ local function func_header_generate_funcs(FP)
|
||||
elseif def.destructor then
|
||||
table.insert(outtab,"CIMGUI_API void "..def.ov_cimguiname..def.args..";"..addcoment.."\n")
|
||||
else --not constructor
|
||||
|
||||
--local ret = FP.nP_ret[def.ret] or def.ret
|
||||
local ret = def.ret
|
||||
if def.stname == "" or def.is_static_function then --ImGui namespace or top level
|
||||
table.insert(outtab,"CIMGUI_API "..def.ret.." ".. def.ov_cimguiname ..(empty and "(void)" or def.args)..";"..addcoment.."\n")
|
||||
table.insert(outtab,"CIMGUI_API "..ret.." ".. def.ov_cimguiname ..(empty and "(void)" or def.args)..";"..addcoment.."\n")
|
||||
if def.isvararg then
|
||||
-- For variadic functions we add a function implementation with zero argumets, for compatibility with languages such as C#.
|
||||
table.insert(outtab, "#ifdef CIMGUI_VARGS0\n")
|
||||
table.insert(outtab, "CIMGUI_API".." "..def.ret.." "..def.ov_cimguiname.."0"..paramListWithoutDots(def.args)..";\n")
|
||||
table.insert(outtab, "CIMGUI_API".." "..ret.." "..def.ov_cimguiname.."0"..paramListWithoutDots(def.args)..";\n")
|
||||
table.insert(outtab, "#endif\n")
|
||||
end
|
||||
else
|
||||
table.insert(outtab,"CIMGUI_API "..def.ret.." "..def.ov_cimguiname..def.args..";"..addcoment.."\n")
|
||||
table.insert(outtab,"CIMGUI_API "..ret.." "..def.ov_cimguiname..def.args..";"..addcoment.."\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2873,8 +3089,10 @@ local function func_header_generate(FP)
|
||||
table.insert(outtab,"#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n")
|
||||
|
||||
local outtabf = func_header_generate_funcs(FP)
|
||||
|
||||
local cfuncsstr = table.concat(outtab)..table.concat(outtabf)
|
||||
outtabf = table.concat(outtabf)
|
||||
assert(type(outtabf)=="string")
|
||||
--outtabf = M.header_subs_nonPOD(FP,outtabf)
|
||||
local cfuncsstr = table.concat(outtab)..outtabf
|
||||
cfuncsstr = cfuncsstr:gsub("\n+","\n") --several empty lines to one empty line
|
||||
return cfuncsstr
|
||||
end
|
||||
|
||||
@@ -124,10 +124,14 @@ local function func_header_impl_generate(FP)
|
||||
|
||||
local outtab = {}
|
||||
|
||||
for _,t in ipairs(FP.funcdefs) do
|
||||
if t.cimguiname then
|
||||
local cimf = FP.defsT[t.cimguiname]
|
||||
local def = cimf[t.signature]
|
||||
-- for _,t in ipairs(FP.funcdefs) do
|
||||
-- if t.cimguiname then
|
||||
-- local cimf = FP.defsT[t.cimguiname]
|
||||
-- local def = cimf[t.signature]
|
||||
--for k,defs in pairs(FP.defsT) do
|
||||
cpp2ffi.table_do_sorted(FP.defsT, function(i,defs)
|
||||
if true then
|
||||
for i, def in ipairs(defs) do
|
||||
local addcoment = def.comment or ""
|
||||
local empty = def.args:match("^%(%)") --no args
|
||||
if def.constructor then
|
||||
@@ -147,10 +151,11 @@ local function func_header_impl_generate(FP)
|
||||
error("class function in implementations")
|
||||
end
|
||||
end
|
||||
end
|
||||
else --not cimguiname
|
||||
table.insert(outtab,t.comment:gsub("%%","%%%%").."\n")-- %% substitution for gsub
|
||||
end
|
||||
end
|
||||
end)
|
||||
local cfuncsstr = table.concat(outtab)
|
||||
cfuncsstr = cfuncsstr:gsub("\n+","\n") --several empty lines to one empty line
|
||||
return cfuncsstr
|
||||
@@ -272,12 +277,16 @@ local function cimgui_generation(parser)
|
||||
--------------------------------------------------
|
||||
local hstrfile = read_data"./cimgui_template.h"
|
||||
|
||||
|
||||
hstrfile = hstrfile:gsub([[PLACE_STRUCTS_C]],parser:gen_structs_c())
|
||||
|
||||
local outpre,outpost = parser.structs_and_enums[1],parser.structs_and_enums[2]
|
||||
cpp2ffi.prtable(parser.templates)
|
||||
cpp2ffi.prtable(parser.typenames)
|
||||
|
||||
|
||||
local tdt = parser:generate_templates()
|
||||
--local cstructsstr = "\n//7777estio es outpre\n"..outpre.."\n///////////////tdt\n"..tdt.."\n////////////////////outpost\n"..outpost
|
||||
local cstructsstr = outpre..tdt..outpost
|
||||
|
||||
if gdefines.IMGUI_HAS_DOCK then
|
||||
@@ -286,6 +295,9 @@ local function cimgui_generation(parser)
|
||||
if gdefines.ImDrawCallback_ResetRenderState then
|
||||
cstructsstr = cstructsstr.."\n#define ImDrawCallback_ResetRenderState "..gdefines.ImDrawCallback_ResetRenderState.."\n"
|
||||
end
|
||||
if gdefines.ImTextureID_Invalid then
|
||||
cstructsstr = cstructsstr.."\n#define ImTextureID_Invalid "..gdefines.ImTextureID_Invalid.."\n"
|
||||
end
|
||||
if gdefines.IMGUI_HAS_IMSTR then
|
||||
if not (NOCHAR or NOIMSTRV) then
|
||||
cstructsstr = cstructsstr.."\n#define IMGUI_HAS_IMSTR 1\n"
|
||||
@@ -311,6 +323,9 @@ local function cimgui_generation(parser)
|
||||
cimplem = colapse_defines(cimplem, "IMGUI_ENABLE_FREETYPE")
|
||||
local hstrfile = read_data"./cimgui_template.cpp"
|
||||
|
||||
local conversors = parser:genConversors()
|
||||
cimplem = conversors .. cimplem
|
||||
|
||||
hstrfile = hstrfile:gsub([[#include "auto_funcs%.cpp"]],cimplem)
|
||||
local ftdef = "" --FREETYPE_GENERATION and "#define IMGUI_ENABLE_FREETYPE\n" or ""
|
||||
save_data("./output/cimgui.cpp",cimgui_header, ftdef, hstrfile)
|
||||
@@ -321,7 +336,7 @@ end
|
||||
--------------------------------------------------------
|
||||
--get imgui.h version and IMGUI_HAS_DOCK--------------------------
|
||||
--defines for the cl compiler must be present in the print_defines.cpp file
|
||||
gdefines = get_defines{"IMGUI_VERSION","IMGUI_VERSION_NUM","FLT_MAX","FLT_MIN","IMGUI_HAS_DOCK","IMGUI_HAS_IMSTR","ImDrawCallback_ResetRenderState","IMGUI_HAS_TEXTURES"}
|
||||
gdefines = get_defines{"IMGUI_VERSION","IMGUI_VERSION_NUM","FLT_MAX","FLT_MIN","IMGUI_HAS_DOCK","IMGUI_HAS_IMSTR","ImDrawCallback_ResetRenderState","IMGUI_HAS_TEXTURES","ImTextureID_Invalid"}
|
||||
cpp2ffi.prtable(gdefines)
|
||||
if gdefines.IMGUI_HAS_DOCK then gdefines.IMGUI_HAS_DOCK = true end
|
||||
if gdefines.IMGUI_HAS_IMSTR then gdefines.IMGUI_HAS_IMSTR = true end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -34,6 +34,7 @@ int main(void)
|
||||
display_size.x = 1920;
|
||||
display_size.y = 1080;
|
||||
io->DisplaySize = display_size;
|
||||
printf("DisplaySice %f, %f\n", io->DisplaySize.x, io->DisplaySize.y);
|
||||
io->DeltaTime = 1.0f / 60.0f;
|
||||
igNewFrame();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user