mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 20:08:31 +01:00
Compare commits
87 Commits
1.90.7
...
d61baefa0c
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d61baefa0c | ||
![]() |
7dc88bd031 | ||
![]() |
bcb179376b | ||
![]() |
dd9196a19b | ||
![]() |
439e8073c2 | ||
![]() |
63e6dd0ef3 | ||
![]() |
85d6d12ec6 | ||
![]() |
8e95247e63 | ||
![]() |
92b0239554 | ||
![]() |
094a55523a | ||
![]() |
c561c6a6e5 | ||
![]() |
5ba6ea3fc0 | ||
![]() |
623cbefe49 | ||
![]() |
a007c438f0 | ||
![]() |
f6e14c22eb | ||
![]() |
205107640d | ||
![]() |
08677d259c | ||
![]() |
8f15ab3f80 | ||
![]() |
0992dbf89c | ||
![]() |
dad6366d9b | ||
![]() |
abc0ea66b5 | ||
![]() |
4e3e9b5fb2 | ||
![]() |
334c9fa140 | ||
![]() |
03e6c8d1f2 | ||
![]() |
50c60f3da6 | ||
![]() |
140d107be5 | ||
![]() |
c32d1c0c9b | ||
![]() |
3530b937f1 | ||
![]() |
bb6f212993 | ||
![]() |
e3af31fb9c | ||
![]() |
de213c9105 | ||
![]() |
4bd8b6dbbd | ||
![]() |
a1dbf23597 | ||
![]() |
f2e203b05a | ||
![]() |
429ffc930d | ||
![]() |
95dec01325 | ||
![]() |
79504e6f7c | ||
![]() |
4edec25945 | ||
![]() |
daac7262b3 | ||
![]() |
2e5db87e99 | ||
![]() |
387e5e0d8b | ||
![]() |
10a7a9f3f3 | ||
![]() |
9bc279c4d8 | ||
![]() |
46c47d5703 | ||
![]() |
e5facd9083 | ||
![]() |
7d50243c50 | ||
![]() |
7715efaa41 | ||
![]() |
9cc8f27f61 | ||
![]() |
df65595422 | ||
![]() |
2a0af76f16 | ||
![]() |
1053d1584f | ||
![]() |
d83e8c5892 | ||
![]() |
98b667f601 | ||
![]() |
d9982af929 | ||
![]() |
58763282f8 | ||
![]() |
970c614802 | ||
![]() |
3d5b2e7650 | ||
![]() |
4e89eac938 | ||
![]() |
bd2ea2acbb | ||
![]() |
69d3b29392 | ||
![]() |
1c3d694f36 | ||
![]() |
be19fd11eb | ||
![]() |
fdd07821bb | ||
![]() |
7640b00d27 | ||
![]() |
90f2147dbe | ||
![]() |
8268b6748b | ||
![]() |
652d4cbc89 | ||
![]() |
e50a65fd62 | ||
![]() |
f276fd4ae1 | ||
![]() |
c06a46b0f2 | ||
![]() |
a051fe287b | ||
![]() |
411924f104 | ||
![]() |
0c7f67607d | ||
![]() |
51197f420a | ||
![]() |
ed017a0704 | ||
![]() |
c482a65118 | ||
![]() |
35a4e8f893 | ||
![]() |
2b4d572704 | ||
![]() |
f6fb347cf1 | ||
![]() |
d8f958f680 | ||
![]() |
ee251eaafa | ||
![]() |
00ecbb0ee2 | ||
![]() |
577f2b088a | ||
![]() |
26152eac73 | ||
![]() |
7c16d31cdb | ||
![]() |
b3e02743f2 | ||
![]() |
155d5961dc |
@@ -26,10 +26,10 @@ set(IMGUI_FREETYPE "no" CACHE STRING "Build with freetype library")
|
||||
set(IMGUI_LIBRARIES )
|
||||
|
||||
if(IMGUI_FREETYPE)
|
||||
message(STATUS "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")
|
||||
endif(IMGUI_FREETYPE)
|
||||
|
||||
#add library and link
|
||||
@@ -39,6 +39,20 @@ else (IMGUI_STATIC)
|
||||
add_library(cimgui SHARED ${IMGUI_SOURCES})
|
||||
endif (IMGUI_STATIC)
|
||||
|
||||
if(IMGUI_FREETYPE)
|
||||
target_compile_definitions(cimgui PUBLIC IMGUI_ENABLE_FREETYPE)
|
||||
target_compile_definitions(cimgui PUBLIC IMGUI_ENABLE_STB_TRUETYPE)
|
||||
endif(IMGUI_FREETYPE)
|
||||
|
||||
if(IMGUI_WCHAR32)
|
||||
target_compile_definitions(cimgui PUBLIC IMGUI_USE_WCHAR32)
|
||||
endif(IMGUI_WCHAR32)
|
||||
|
||||
if(CIMGUI_VARGS0)
|
||||
target_compile_definitions(cimgui PUBLIC CIMGUI_VARGS0)
|
||||
endif(CIMGUI_VARGS0)
|
||||
|
||||
add_definitions("-DIMGUI_USER_CONFIG=\"../cimconfig.h\"")
|
||||
target_compile_definitions(cimgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1)
|
||||
if (WIN32)
|
||||
target_compile_definitions(cimgui PUBLIC IMGUI_IMPL_API=extern\t\"C\"\t__declspec\(dllexport\))
|
||||
|
12
README.md
12
README.md
@@ -11,7 +11,7 @@ History:
|
||||
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)
|
||||
|
||||
Notes:
|
||||
* currently this wrapper is based on version [1.90.7 of Dear ImGui with internal api]
|
||||
* currently this wrapper is based on version [1.92.1 of Dear ImGui with internal api]
|
||||
* only functions, structs and enums from imgui.h (an optionally imgui_internal.h) are wrapped.
|
||||
* if you are interested in imgui backends you should look [LuaJIT-ImGui](https://github.com/sonoro1234/LuaJIT-ImGui) project.
|
||||
* 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.
|
||||
@@ -24,7 +24,7 @@ Notes:
|
||||
* `git submodule update --init --recursive` (If already cloned)
|
||||
* compile
|
||||
* using makefile on linux/macOS/mingw (Or use CMake to generate project)
|
||||
* cmake options are IMGUI_STATIC (compiling as static library), IMGUI_FREETYPE (for using Freetype2) and FREETYPE_PATH (Freetype2 cmake install location) (only if cimgui is generated with freetype option)
|
||||
* cmake options are IMGUI_STATIC (compiling as static library), IMGUI_FREETYPE (for using Freetype2) and FREETYPE_PATH (Freetype2 cmake install location), IMGUI_WCHAR32 and CIMGUI_VARGS0 for compiling a function version without varargs for vararg functions (function name with 0 sufix)
|
||||
* or as in https://github.com/sonoro1234/LuaJIT-ImGui/tree/master/build
|
||||
|
||||
For compiling with backends there are now examples with SDL2 and opengl3/vulkan in folder backend_test.
|
||||
@@ -37,12 +37,12 @@ Notes:
|
||||
* you will need LuaJIT (https://github.com/LuaJIT/LuaJIT.git better 2.1 branch) or precompiled for linux/macOS/windows in https://luapower.com/luajit/download
|
||||
* you need to use also a C++ compiler for doing preprocessing: gcc (In windows MinGW-W64-builds for example), clang or cl (MSVC). (this repo was done with gcc)
|
||||
* update `imgui` folder to the version you desire.
|
||||
* edit `generator/generator.bat` on windows, or `generator/generator.sh` on linux, to choose between gcc, clang, or cl and to choose desired backends and whether imgui_internal is generated or not, Freetype2 is used or not and comments are generated or not
|
||||
* edit `generator/generator.bat` on windows, or `generator/generator.sh` on linux, to choose between gcc, clang, or cl and to choose desired backends and whether imgui_internal is generated or not, comments are generated or not and if constructors are generated also with versions performing just initialization of structs provided by yourself (_Construct is added to the constructor names)
|
||||
* the defaults of generator are gcc as compiler, imgui_internal included and sdl, glfw, vulkan, opengl2 and opengl3 as backends.
|
||||
* edit config_generator.lua for adding includes needed by your chosen backends (vulkan needs that).
|
||||
* Run generator.bat or generator.sh with gcc, clang or cl and LuaJIT on your PATH.
|
||||
* as a result some files are generated: `cimgui.cpp`, `cimgui.h` and `cimgui_impl.h` for compiling and some lua/json files with information about the binding: `definitions.json` with function info, `structs_and_enums.json` with struct and enum info, `impl_definitions.json` with functions from the backends info.
|
||||
* You can pass compiler flags to generator.sh or generator.bat by editing them at the end of the call to further specify the compiler behavior. (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32)
|
||||
* You can pass compiler flags to generator.sh or generator.bat by editing them at the end of the call to further specify the compiler behavior. (e.g. -DIMGUI_USER_CONFIG)
|
||||
* You are able to pass any extra argument to generator.sh (.bat) in the command-line.
|
||||
* If you are using different options than cimgui repo and if you want to keep them after a cimgui update, you can keep them in a copy of generator.sh (.bat) outside of cimgui folder where `cd cimgui/generator` is used before luajit call. See https://github.com/cimgui/cimgui/issues/232#issuecomment-1497059497
|
||||
# generate binding
|
||||
@@ -92,10 +92,10 @@ Notes:
|
||||
* methods have the same parameter list and return values (where possible)
|
||||
* functions that belong to a struct have an extra first argument with a pointer to the struct.
|
||||
* where a function returns UDT (user defined type) by value some compilers complain so the function is generated accepting a pointer to the UDT type as the first argument (or second if belongs to a struct).
|
||||
|
||||
* constructors return pointer to struct and has been named Struct_name_Struct_name
|
||||
# usage with backends
|
||||
|
||||
* look at backend_test folder for a cmake module building with SDL and opengl3, glfw and opengl3, SDL and Vulkan
|
||||
* look at backend_test folder for a cmake module building with SDL and opengl3, glfw and opengl3, SDL and Vulkan, glfw and dx11
|
||||
* read [How can cimgui backends be used](https://github.com/cimgui/cimgui/issues/157)
|
||||
|
||||
# example bindings based on cimgui
|
||||
|
94
backend_test/cmake/GenerateCimguiBindings.cmake
Normal file
94
backend_test/cmake/GenerateCimguiBindings.cmake
Normal file
@@ -0,0 +1,94 @@
|
||||
# This downloads cimgui, configures it to generate the SDL3 and SDLGPU3 bindings,
|
||||
# and adds it as a cmake target for you to link to. Feel free to copy this file
|
||||
# into your project, or refit it to your needs.
|
||||
|
||||
#include(CMakePrintHelpers)
|
||||
|
||||
function(IncludesStr comp includes)
|
||||
#cmake_print_variables(includes)
|
||||
if("${comp}" STREQUAL "cl")
|
||||
set(Ist "/I")
|
||||
else()
|
||||
set(Ist "-I")
|
||||
endif()
|
||||
set(incstr "")
|
||||
foreach(inc ${${includes}})
|
||||
set(incstr ${incstr} ${Ist}${inc})
|
||||
endforeach()
|
||||
set(incstr ${incstr} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
function(GenerateCimguiBindings target platbk rendbk _inclist)
|
||||
include(FetchContent)
|
||||
set(FETCHCONTENT_QUIET OFF)
|
||||
#cmake_print_variables(_inclist)
|
||||
set(__inclist ${${_inclist}})
|
||||
#cmake_print_variables(__inclist)
|
||||
# NOTE: In your own project, you may want to pin this project to a particular commit
|
||||
FetchContent_Declare(
|
||||
cimgui
|
||||
EXCLUDE_FROM_ALL
|
||||
GIT_REPOSITORY https://github.com/cimgui/cimgui.git
|
||||
GIT_TAG docking_inter
|
||||
GIT_SUBMODULES_RECURSE true
|
||||
GIT_PROGRESS true
|
||||
GIT_SHALLOW true
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(cimgui)
|
||||
|
||||
file(READ ${cimgui_SOURCE_DIR}/cimgui_impl.h cimgui_impl)
|
||||
|
||||
# We're checking to see if the cimgui_impl.h file already has required bindings,
|
||||
# since this will be executed on each "configure" (whenever you run cmake)
|
||||
string(TOUPPER ${platbk} PLATBK)
|
||||
string(TOUPPER ${rendbk} RENDBK)
|
||||
string(FIND "${cimgui_impl}" CIMGUI_USE_${RENDBK} rendbk_position)
|
||||
string(FIND "${cimgui_impl}" CIMGUI_USE_${PLATBK} platbk_position)
|
||||
# If we don't find it, rendbk_position will be -1
|
||||
if(rendbk_position EQUAL -1 OR platbk_position EQUAL -1)
|
||||
#get compiler name
|
||||
cmake_path(GET CMAKE_C_COMPILER FILENAME C_COMP)
|
||||
cmake_path(REMOVE_EXTENSION C_COMP)
|
||||
#get includes string
|
||||
IncludesStr(${C_COMP} __inclist)
|
||||
message(STATUS "incstr is ${incstr}")
|
||||
execute_process(
|
||||
COMMAND luajit generator.lua ${C_COMP} "internal noimstrv" ${platbk} ${rendbk} ${incstr}
|
||||
WORKING_DIRECTORY ${cimgui_SOURCE_DIR}/generator
|
||||
ERROR_VARIABLE error_command
|
||||
RESULT_VARIABLE build_command_result
|
||||
)
|
||||
if(NOT ${build_command_result} EQUAL 0)
|
||||
message(STATUS "cimgui generation failed: Do you have LuaJIT?")
|
||||
message(STATUS "cimgui generation failed: ${build_command_result}")
|
||||
message(FATAL_ERROR "error_command: ${error_command}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(${target} SHARED
|
||||
${cimgui_SOURCE_DIR}/cimgui.cpp
|
||||
${cimgui_SOURCE_DIR}/cimgui_impl.cpp
|
||||
${cimgui_SOURCE_DIR}/imgui/imgui.cpp
|
||||
${cimgui_SOURCE_DIR}/imgui/imgui_draw.cpp
|
||||
${cimgui_SOURCE_DIR}/imgui/imgui_demo.cpp
|
||||
${cimgui_SOURCE_DIR}/imgui/imgui_widgets.cpp
|
||||
${cimgui_SOURCE_DIR}/imgui/imgui_tables.cpp
|
||||
${cimgui_SOURCE_DIR}/imgui/backends/imgui_impl_${platbk}.cpp
|
||||
${cimgui_SOURCE_DIR}/imgui/backends/imgui_impl_${rendbk}.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${target} PUBLIC ${cimgui_SOURCE_DIR} ${cimgui_SOURCE_DIR}/generator/output)
|
||||
target_include_directories(${target} PRIVATE ${cimgui_SOURCE_DIR}/imgui ${cimgui_SOURCE_DIR}/imgui/backends)
|
||||
#for ASSERT working on Release mode
|
||||
target_compile_definitions(${target} PUBLIC "-DIMGUI_USER_CONFIG=\"../cimconfig.h\"")
|
||||
target_compile_definitions(${target} PUBLIC "-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
|
||||
if (WIN32)
|
||||
target_compile_definitions(${target} PUBLIC "-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
|
||||
else(WIN32)
|
||||
target_compile_definitions(${target} PUBLIC "-DIMGUI_IMPL_API=extern \"C\" ")
|
||||
endif(WIN32)
|
||||
target_compile_features(${target} PRIVATE cxx_std_11)
|
||||
endfunction()
|
45
backend_test/example_glfw_dx11/CMakeLists.txt
Normal file
45
backend_test/example_glfw_dx11/CMakeLists.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
project(cimgui_glfwdx11 LANGUAGES C CXX)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
set(GLFW_VERSION 3.3.8)
|
||||
FetchContent_Declare(
|
||||
glfw
|
||||
EXCLUDE_FROM_ALL
|
||||
URL https://github.com/glfw/glfw/archive/refs/tags/${GLFW_VERSION}.tar.gz
|
||||
GIT_PROGRESS true)
|
||||
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
if (NOT STATIC_BUILD)
|
||||
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
|
||||
FetchContent_MakeAvailable(glfw)
|
||||
install(TARGETS glfw RUNTIME DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||
LIBRARY DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
include(../cmake/GenerateCimguiBindings.cmake)
|
||||
|
||||
set(inclulist "")
|
||||
GenerateCimguiBindings(cimgui_with_backend "glfw" dx11 inclulist)
|
||||
target_link_libraries(cimgui_with_backend PRIVATE glfw d3dcompiler dwmapi)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
main.c
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE glfw cimgui_with_backend d3d11 d3dcompiler dwmapi)
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
CIMGUI_DEFINE_ENUMS_AND_STRUCTS=1
|
||||
CIMGUI_USE_GLFW=1
|
||||
CIMGUI_USE_DX11=1
|
||||
)
|
7
backend_test/example_glfw_dx11/README.md
Normal file
7
backend_test/example_glfw_dx11/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# GLFWDX11
|
||||
|
||||
This example needs dx11 in generation before compile.
|
||||
Generation will be done from cmake but you need LuaJIT in the system.
|
||||
|
||||
`STATIC_BUILD` is the cmake variable to do static linking
|
||||
|
249
backend_test/example_glfw_dx11/main.c
Normal file
249
backend_test/example_glfw_dx11/main.c
Normal file
@@ -0,0 +1,249 @@
|
||||
//#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS is done in cmake
|
||||
#include "cimgui.h"
|
||||
#include "cimgui_impl.h"
|
||||
#define D3D11_NO_HELPERS
|
||||
#define CINTERFACE
|
||||
#define COBJMACROS
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <d3d11.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#include <GLFW/glfw3native.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#pragma comment(lib, "dxguid.lib")
|
||||
|
||||
#ifdef IMGUI_HAS_IMSTR
|
||||
#define igBegin igBegin_Str
|
||||
#define igSliderFloat igSliderFloat_Str
|
||||
#define igCheckbox igCheckbox_Str
|
||||
#define igColorEdit3 igColorEdit3_Str
|
||||
#define igButton igButton_Str
|
||||
#endif
|
||||
|
||||
#define igGetIO igGetIO_Nil
|
||||
|
||||
GLFWwindow *window;
|
||||
|
||||
// Data
|
||||
static ID3D11Device* g_pd3dDevice = NULL;
|
||||
static ID3D11DeviceContext* g_pd3dDeviceContext = NULL;
|
||||
static IDXGISwapChain* g_pSwapChain = NULL;
|
||||
static ID3D11RenderTargetView* g_mainRenderTargetView = NULL;
|
||||
|
||||
// Forward declarations of helper functions
|
||||
bool CreateDeviceD3D(HWND hWnd);
|
||||
void CleanupDeviceD3D();
|
||||
void CreateRenderTarget();
|
||||
void CleanupRenderTarget();
|
||||
|
||||
void window_size_callback(GLFWwindow* window, int width, int height)
|
||||
{
|
||||
CleanupRenderTarget();
|
||||
IDXGISwapChain_ResizeBuffers(g_pSwapChain, 0, width, height, DXGI_FORMAT_UNKNOWN, 0);
|
||||
CreateRenderTarget();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
if (!glfwInit())
|
||||
return -1;
|
||||
|
||||
// Decide GL+GLSL versions
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
|
||||
|
||||
|
||||
// just an extra window hint for resize
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
||||
|
||||
window = glfwCreateWindow(1024, 768, "Hello World!", NULL, NULL);
|
||||
if (!window)
|
||||
{
|
||||
printf("Failed to create window! Terminating!\n");
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
|
||||
//
|
||||
HWND hwnd = glfwGetWin32Window(window);
|
||||
if (hwnd == NULL)
|
||||
{
|
||||
printf("Failed to get win32 window! Terminating!\n");
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
// Initialize Direct3D
|
||||
if (!CreateDeviceD3D(hwnd))
|
||||
{
|
||||
CleanupDeviceD3D();
|
||||
return 1;
|
||||
}
|
||||
|
||||
glfwSetWindowSizeCallback(window, window_size_callback);
|
||||
|
||||
// setup imgui
|
||||
igCreateContext(NULL);
|
||||
|
||||
// set docking
|
||||
ImGuiIO *ioptr = igGetIO();
|
||||
ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
//ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
#ifdef IMGUI_HAS_DOCK
|
||||
ioptr->ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||
ioptr->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||
#endif
|
||||
|
||||
ImGui_ImplGlfw_InitForOther(window, true);
|
||||
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
||||
|
||||
igStyleColorsDark(NULL);
|
||||
// ImFontAtlas_AddFontDefault(io.Fonts, NULL);
|
||||
|
||||
bool showDemoWindow = true;
|
||||
bool showAnotherWindow = false;
|
||||
ImVec4 clearColor;
|
||||
clearColor.x = 0.45f;
|
||||
clearColor.y = 0.55f;
|
||||
clearColor.z = 0.60f;
|
||||
clearColor.w = 1.00f;
|
||||
|
||||
// main event loop
|
||||
bool quit = false;
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
|
||||
glfwPollEvents();
|
||||
|
||||
// start imgui frame
|
||||
ImGui_ImplDX11_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
igNewFrame();
|
||||
|
||||
if (showDemoWindow)
|
||||
igShowDemoWindow(&showDemoWindow);
|
||||
|
||||
// show a simple window that we created ourselves.
|
||||
{
|
||||
static float f = 0.0f;
|
||||
static int counter = 0;
|
||||
|
||||
igBegin("Hello, world!", NULL, 0);
|
||||
igText("This is some useful text");
|
||||
igCheckbox("Demo window", &showDemoWindow);
|
||||
igCheckbox("Another window", &showAnotherWindow);
|
||||
|
||||
igSliderFloat("Float", &f, 0.0f, 1.0f, "%.3f", 0);
|
||||
igColorEdit3("clear color", (float *)&clearColor, 0);
|
||||
|
||||
ImVec2 buttonSize;
|
||||
buttonSize.x = 0;
|
||||
buttonSize.y = 0;
|
||||
if (igButton("Button", buttonSize))
|
||||
counter++;
|
||||
igSameLine(0.0f, -1.0f);
|
||||
igText("counter = %d", counter);
|
||||
|
||||
igText("Application average %.3f ms/frame (%.1f FPS)",
|
||||
1000.0f / igGetIO()->Framerate, igGetIO()->Framerate);
|
||||
igEnd();
|
||||
}
|
||||
|
||||
if (showAnotherWindow)
|
||||
{
|
||||
igBegin("imgui Another Window", &showAnotherWindow, 0);
|
||||
igText("Hello from imgui");
|
||||
ImVec2 buttonSize;
|
||||
buttonSize.x = 0;
|
||||
buttonSize.y = 0;
|
||||
if (igButton("Close me", buttonSize)) {
|
||||
showAnotherWindow = false;
|
||||
}
|
||||
igEnd();
|
||||
}
|
||||
|
||||
// render
|
||||
igRender();
|
||||
const float clear_color_with_alpha[4] = { clearColor.x * clearColor.w, clearColor.y * clearColor.w, clearColor.z * clearColor.w, clearColor.w };
|
||||
ID3D11DeviceContext_OMSetRenderTargets(g_pd3dDeviceContext, 1, &g_mainRenderTargetView, NULL);
|
||||
ID3D11DeviceContext_ClearRenderTargetView(g_pd3dDeviceContext, g_mainRenderTargetView, clear_color_with_alpha);
|
||||
ImGui_ImplDX11_RenderDrawData(igGetDrawData());
|
||||
#ifdef IMGUI_HAS_DOCK
|
||||
if (ioptr->ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||
{
|
||||
igUpdatePlatformWindows();
|
||||
igRenderPlatformWindowsDefault(NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
IDXGISwapChain_Present(g_pSwapChain,1, 0); // Present with vsync
|
||||
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||
}
|
||||
|
||||
// clean up
|
||||
ImGui_ImplDX11_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
igDestroyContext(NULL);
|
||||
|
||||
CleanupDeviceD3D();
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Helper functions to use DirectX11
|
||||
bool CreateDeviceD3D(HWND hWnd)
|
||||
{
|
||||
// Setup swap chain
|
||||
DXGI_SWAP_CHAIN_DESC sd;
|
||||
ZeroMemory(&sd, sizeof(sd));
|
||||
sd.BufferCount = 2;
|
||||
sd.BufferDesc.Width = 0;
|
||||
sd.BufferDesc.Height = 0;
|
||||
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
sd.BufferDesc.RefreshRate.Numerator = 60;
|
||||
sd.BufferDesc.RefreshRate.Denominator = 1;
|
||||
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
|
||||
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
sd.OutputWindow = hWnd;
|
||||
sd.SampleDesc.Count = 1;
|
||||
sd.SampleDesc.Quality = 0;
|
||||
sd.Windowed = TRUE;
|
||||
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||
|
||||
UINT createDeviceFlags = 0;
|
||||
//createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
D3D_FEATURE_LEVEL featureLevel;
|
||||
const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, };
|
||||
if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK)
|
||||
return false;
|
||||
|
||||
CreateRenderTarget();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CleanupDeviceD3D()
|
||||
{
|
||||
CleanupRenderTarget();
|
||||
if (g_pSwapChain) { IDXGISwapChain_Release(g_pSwapChain); g_pSwapChain = NULL; }
|
||||
if (g_pd3dDeviceContext) { ID3D11DeviceContext_Release(g_pd3dDeviceContext); g_pd3dDeviceContext = NULL; }
|
||||
if (g_pd3dDevice) { ID3D11Device_Release(g_pd3dDevice); g_pd3dDevice = NULL; }
|
||||
}
|
||||
|
||||
void CreateRenderTarget()
|
||||
{
|
||||
ID3D11Resource* pBackBuffer;
|
||||
IDXGISwapChain_GetBuffer(g_pSwapChain, 0, &IID_ID3D11Texture2D, (void**)&pBackBuffer);
|
||||
ID3D11Device_CreateRenderTargetView(g_pd3dDevice, pBackBuffer, NULL, &g_mainRenderTargetView);
|
||||
ID3D11Texture2D_Release(pBackBuffer);
|
||||
}
|
||||
|
||||
void CleanupRenderTarget()
|
||||
{
|
||||
if (g_mainRenderTargetView) { ID3D11RenderTargetView_Release(g_mainRenderTargetView); g_mainRenderTargetView = NULL; }
|
||||
}
|
||||
|
@@ -4,6 +4,9 @@ if(WIN32) # to mingw work as all the others
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
||||
endif(WIN32)
|
||||
|
||||
#run in build dir
|
||||
set (CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
|
||||
# general settings
|
||||
@@ -20,6 +23,7 @@ else()
|
||||
endif()
|
||||
|
||||
include_directories(../../imgui)
|
||||
add_definitions("-DIMGUI_USER_CONFIG=\"../cimconfig.h\"")
|
||||
add_definitions("-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
|
||||
|
||||
include_directories(../../)
|
||||
@@ -32,14 +36,8 @@ set(IMGUI_SOURCES
|
||||
${TABLES_SOURCE}
|
||||
)
|
||||
|
||||
set(IMGUI_SOURCES_sdl)
|
||||
set(IMGUI_LIBRARIES )
|
||||
|
||||
if (WIN32)
|
||||
add_definitions("-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
|
||||
else(WIN32)
|
||||
add_definitions("-DIMGUI_IMPL_API=extern \"C\" ")
|
||||
endif(WIN32)
|
||||
|
||||
add_compile_definitions("IMGUI_IMPL_OPENGL_LOADER_GL3W")
|
||||
|
||||
@@ -47,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
|
||||
@@ -65,39 +66,51 @@ endif(WIN32)
|
||||
# GLFW
|
||||
list(APPEND IMGUI_SOURCES ${BAKENDS_FOLDER}imgui_impl_glfw.cpp)
|
||||
|
||||
set(GLFW_VERSION 3.3.8)
|
||||
set(GLFW_VERSION 3.4)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
glfw
|
||||
URL https://github.com/glfw/glfw/archive/refs/tags/${GLFW_VERSION}.tar.gz)
|
||||
#GIT_REPOSITORY https://github.com/glfw/glfw )
|
||||
|
||||
FetchContent_GetProperties(glfw)
|
||||
if (NOT glfw_POPULATED)
|
||||
set(FETCHCONTENT_QUIET NO)
|
||||
FetchContent_Populate(glfw)
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(${glfw_SOURCE_DIR} ${glfw_BINARY_DIR})
|
||||
if (NOT STATIC_BUILD)
|
||||
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
add_subdirectory(${glfw_SOURCE_DIR} ${glfw_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
#if dynamic glfw then install
|
||||
install(TARGETS glfw RUNTIME DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||
LIBRARY DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
#FIND_PACKAGE(glfw3 PATHS "C:/LuaGL/gitsources/BUILDS/GLFW/install" REQUIRED)
|
||||
|
||||
# glfw/imgui gets confused if it is not statically built.
|
||||
IF (WIN32)
|
||||
add_library(cimgui STATIC ${IMGUI_SOURCES})
|
||||
ELSE()
|
||||
|
||||
if (NOT STATIC_BUILD)
|
||||
add_library(cimgui SHARED ${IMGUI_SOURCES})
|
||||
ENDIF()
|
||||
else()
|
||||
add_library(cimgui STATIC ${IMGUI_SOURCES})
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
target_compile_definitions(cimgui PUBLIC "-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
|
||||
else(WIN32)
|
||||
target_compile_definitions(cimgui PUBLIC "-DIMGUI_IMPL_API=extern \"C\" ")
|
||||
endif(WIN32)
|
||||
|
||||
target_link_libraries(cimgui ${IMGUI_LIBRARIES} glfw)
|
||||
|
||||
|
||||
# using library
|
||||
include_directories(../../generator/output/)
|
||||
add_executable(${PROJECT_NAME} main.c)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC -DCIMGUI_USE_OPENGL3 -DCIMGUI_USE_GLFW)
|
||||
if (MINGW)
|
||||
target_link_options(${PROJECT_NAME} PRIVATE "-mconsole")
|
||||
endif()
|
||||
target_link_libraries(${PROJECT_NAME} ${IMGUI_SDL_LIBRARY} cimgui)
|
||||
target_link_libraries(${PROJECT_NAME} cimgui)
|
||||
|
||||
|
||||
|
4
backend_test/example_glfw_opengl3/README.md
Normal file
4
backend_test/example_glfw_opengl3/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
To build use `cmake path_to_example_glfw_opengl3` and then `make install`
|
||||
|
||||
`STATIC_BUILD` is a cmake variable if you want to do static linking.
|
@@ -17,6 +17,8 @@
|
||||
#define igButton igButton_Str
|
||||
#endif
|
||||
|
||||
#define igGetIO igGetIO_Nil
|
||||
|
||||
GLFWwindow *window;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -41,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");
|
||||
@@ -70,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);
|
||||
|
||||
|
100
backend_test/example_sdl3_vulkan/CMakeLists.txt
Normal file
100
backend_test/example_sdl3_vulkan/CMakeLists.txt
Normal file
@@ -0,0 +1,100 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
Project(cimgui_sdl3_vk)
|
||||
if(WIN32) # to make mingw work as all the others
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
||||
endif(WIN32)
|
||||
# general settings
|
||||
|
||||
|
||||
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui/backends)
|
||||
set(BACKENDS_FOLDER "../../imgui/backends/")
|
||||
else()
|
||||
set(BACKENDS_FOLDER "../../imgui/examples/")
|
||||
endif()
|
||||
|
||||
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui/imgui_tables.cpp)
|
||||
set(TABLES_SOURCE "../../imgui/imgui_tables.cpp")
|
||||
else()
|
||||
set(TABLES_SOURCE "")
|
||||
endif()
|
||||
|
||||
include_directories(../../imgui ../../imgui/backends)
|
||||
|
||||
|
||||
include_directories(../../)
|
||||
set(IMGUI_SOURCES ../../cimgui.cpp
|
||||
../../cimgui_impl.cpp
|
||||
../../imgui/imgui.cpp
|
||||
../../imgui/imgui_draw.cpp
|
||||
../../imgui/imgui_demo.cpp
|
||||
../../imgui/imgui_widgets.cpp
|
||||
${TABLES_SOURCE}
|
||||
)
|
||||
|
||||
set(IMGUI_SOURCES_sdl)
|
||||
set(IMGUI_LIBRARIES )
|
||||
|
||||
|
||||
#optional adding freetype
|
||||
option(IMGUI_FREETYPE "add Freetype2" OFF)
|
||||
|
||||
if(IMGUI_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")
|
||||
endif(IMGUI_FREETYPE)
|
||||
|
||||
# vulkan
|
||||
find_package(Vulkan REQUIRED FATAL_ERROR)
|
||||
list(APPEND IMGUI_LIBRARIES Vulkan::Vulkan)
|
||||
list(APPEND IMGUI_SOURCES ${BACKENDS_FOLDER}imgui_impl_vulkan.cpp)
|
||||
include_directories(${Vulkan_INCLUDE_DIRS})
|
||||
|
||||
#sdl3
|
||||
list(APPEND IMGUI_SOURCES ${BACKENDS_FOLDER}imgui_impl_sdl3.cpp)
|
||||
include(FetchContent)
|
||||
Set(FETCHCONTENT_QUIET FALSE)
|
||||
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
||||
GIT_TAG release-3.2.8
|
||||
#GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
FetchContent_GetProperties(SDL3)
|
||||
if (NOT sdl3_POPULATED)
|
||||
set(FETCHCONTENT_QUIET NO)
|
||||
FetchContent_Populate(SDL3)
|
||||
set(SDL_TEST OFF CACHE BOOL "" FORCE)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(${sdl3_SOURCE_DIR} ${sdl3_BINARY_DIR})
|
||||
endif()
|
||||
include_directories(${SDL3_SOURCE_DIR}/include)
|
||||
|
||||
|
||||
#if dynamic SDL3 then install
|
||||
# install(TARGETS SDL3 RUNTIME DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||
# LIBRARY DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||
# )
|
||||
|
||||
add_library(cimgui_sdl STATIC ${IMGUI_SOURCES})
|
||||
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_USER_CONFIG=\"../cimconfig.h\"")
|
||||
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
|
||||
target_compile_definitions(cimgui_sdl PUBLIC -DCIMGUI_USE_VULKAN -DCIMGUI_USE_SDL3)
|
||||
if (WIN32)
|
||||
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
|
||||
else(WIN32)
|
||||
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_IMPL_API=extern \"C\" ")
|
||||
endif(WIN32)
|
||||
#target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} SDL3-static)
|
||||
|
||||
#using library
|
||||
add_executable(test_sdl main.c)
|
||||
target_compile_definitions(test_sdl PUBLIC -DCIMGUI_USE_VULKAN -DCIMGUI_USE_SDL3)
|
||||
if (MINGW)
|
||||
target_link_options(test_sdl PRIVATE "-mconsole")
|
||||
endif()
|
||||
target_link_libraries(test_sdl SDL3-static cimgui_sdl ${IMGUI_LIBRARIES})
|
||||
|
2
backend_test/example_sdl3_vulkan/README.md
Normal file
2
backend_test/example_sdl3_vulkan/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
To build use `cmake path_to_example_sdl3_vulkan` and then `make install`
|
630
backend_test/example_sdl3_vulkan/main.c
Normal file
630
backend_test/example_sdl3_vulkan/main.c
Normal file
@@ -0,0 +1,630 @@
|
||||
#include <stdio.h> // printf, fprintf
|
||||
#include <stdlib.h> // abort
|
||||
#include <assert.h>
|
||||
#define SDL_MAIN_HANDLED
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_vulkan.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
// Volk headers
|
||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
||||
#define VOLK_IMPLEMENTATION
|
||||
#include <volk.h>
|
||||
#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
|
||||
|
||||
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
#include <cimgui.h>
|
||||
#include <cimgui_impl.h>
|
||||
|
||||
#ifdef IMGUI_HAS_IMSTR
|
||||
#define igBegin igBegin_Str
|
||||
#define igSliderFloat igSliderFloat_Str
|
||||
#define igCheckbox igCheckbox_Str
|
||||
#define igColorEdit3 igColorEdit3_Str
|
||||
#define igButton igButton_Str
|
||||
#endif
|
||||
|
||||
#define igGetIO igGetIO_Nil
|
||||
|
||||
#define IM_UNUSED(_VAR) ((void)(_VAR))
|
||||
#define IM_ASSERT(_EXPR) assert(_EXPR)
|
||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR))))
|
||||
|
||||
//#define APP_USE_UNLIMITED_FRAME_RATE
|
||||
#ifdef _DEBUG
|
||||
#define APP_USE_VULKAN_DEBUG_REPORT
|
||||
#endif
|
||||
#define APP_USE_VULKAN_DEBUG_REPORT
|
||||
// Data
|
||||
static VkAllocationCallbacks* g_Allocator = NULL;
|
||||
static VkInstance g_Instance = VK_NULL_HANDLE;
|
||||
static VkPhysicalDevice g_PhysicalDevice = VK_NULL_HANDLE;
|
||||
static VkDevice g_Device = VK_NULL_HANDLE;
|
||||
static uint32_t g_QueueFamily = (uint32_t)-1;
|
||||
static VkQueue g_Queue = VK_NULL_HANDLE;
|
||||
static VkDebugReportCallbackEXT g_DebugReport = VK_NULL_HANDLE;
|
||||
static VkPipelineCache g_PipelineCache = VK_NULL_HANDLE;
|
||||
static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
|
||||
|
||||
static ImGui_ImplVulkanH_Window g_MainWindowData;
|
||||
static uint32_t g_MinImageCount = 2;
|
||||
static bool g_SwapChainRebuild = false;
|
||||
|
||||
static void check_vk_result(VkResult err)
|
||||
{
|
||||
if (err == VK_SUCCESS)
|
||||
return;
|
||||
fprintf(stderr, "[vulkan] Error: VkResult = %d\n", err);
|
||||
if (err < 0)
|
||||
abort();
|
||||
}
|
||||
|
||||
static void check_vk_result_line(VkResult err,int line)
|
||||
{
|
||||
if (err == VK_SUCCESS)
|
||||
return;
|
||||
fprintf(stderr, "[vulkan] Error: VkResult = %d in line: (%d)\n", err, line);
|
||||
if (err < 0)
|
||||
abort();
|
||||
}
|
||||
|
||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
||||
static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
|
||||
{
|
||||
(void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguments
|
||||
fprintf(stderr, "[vulkan] Debug report from ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
|
||||
return VK_FALSE;
|
||||
}
|
||||
#endif // APP_USE_VULKAN_DEBUG_REPORT
|
||||
//*
|
||||
static bool IsExtensionAvailable(VkExtensionProperties* properties, uint32_t properties_count, const char* extension)
|
||||
{
|
||||
for(uint32_t i = 0 ; i < properties_count; i++){
|
||||
if (strcmp(properties[i].extensionName, extension) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void SetupVulkan(const char** extensions, uint32_t extensions_count)
|
||||
{
|
||||
VkResult err;
|
||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
||||
volkInitialize();
|
||||
#endif
|
||||
|
||||
// Create Vulkan Instance
|
||||
{
|
||||
VkInstanceCreateInfo create_info = {};
|
||||
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||
|
||||
// Enumerate available extensions
|
||||
uint32_t properties_count;
|
||||
vkEnumerateInstanceExtensionProperties(NULL, &properties_count, NULL);
|
||||
VkExtensionProperties* properties = (VkExtensionProperties*)malloc(properties_count * sizeof(VkExtensionProperties));
|
||||
err = vkEnumerateInstanceExtensionProperties(NULL, &properties_count, properties);
|
||||
check_vk_result_line(err, __LINE__);
|
||||
|
||||
// Enable required extensions
|
||||
if (IsExtensionAvailable(properties, properties_count, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)){
|
||||
//instance_extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||
extensions_count++;
|
||||
extensions = realloc(extensions, extensions_count * sizeof(char*));
|
||||
assert(extensions);
|
||||
extensions[extensions_count-1] = VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME;
|
||||
}
|
||||
#ifdef VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME
|
||||
if (IsExtensionAvailable(properties, properties_count, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME))
|
||||
{
|
||||
//instance_extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
|
||||
extensions_count++;
|
||||
extensions = realloc(extensions, extensions_count * sizeof(char*));
|
||||
assert(extensions);
|
||||
extensions[extensions_count-1] = VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME;
|
||||
create_info.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
|
||||
}
|
||||
#endif
|
||||
free(properties);
|
||||
// Enabling validation layers
|
||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
||||
const char* layers[] = { "VK_LAYER_KHRONOS_validation" };
|
||||
create_info.enabledLayerCount = 1;
|
||||
create_info.ppEnabledLayerNames = layers;
|
||||
//instance_extensions.push_back("VK_EXT_debug_report");
|
||||
extensions_count++;
|
||||
extensions = realloc(extensions, extensions_count * sizeof(char*));
|
||||
assert(extensions);
|
||||
extensions[extensions_count-1] = "VK_EXT_debug_report";
|
||||
#endif
|
||||
|
||||
// Create Vulkan Instance
|
||||
create_info.enabledExtensionCount = extensions_count;//(uint32_t)instance_extensions.Size;
|
||||
create_info.ppEnabledExtensionNames = extensions;//instance_extensions.Data;
|
||||
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
|
||||
check_vk_result_line(err, __LINE__);
|
||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
||||
volkLoadInstance(g_Instance);
|
||||
#endif
|
||||
|
||||
// Setup the debug report callback
|
||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
||||
PFN_vkCreateDebugReportCallbackEXT f_vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
|
||||
IM_ASSERT(f_vkCreateDebugReportCallbackEXT != NULL);
|
||||
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
||||
debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
|
||||
debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
|
||||
debug_report_ci.pfnCallback = debug_report;
|
||||
debug_report_ci.pUserData = NULL;
|
||||
err = f_vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport);
|
||||
check_vk_result_line(err, __LINE__);
|
||||
#endif
|
||||
}
|
||||
// Select Physical Device (GPU)
|
||||
g_PhysicalDevice = ImGui_ImplVulkanH_SelectPhysicalDevice(g_Instance);
|
||||
IM_ASSERT(g_PhysicalDevice != VK_NULL_HANDLE);
|
||||
// Select graphics queue family
|
||||
g_QueueFamily = ImGui_ImplVulkanH_SelectQueueFamilyIndex(g_PhysicalDevice);
|
||||
IM_ASSERT(g_QueueFamily != (uint32_t)-1);
|
||||
|
||||
// Create Logical Device (with 1 queue)
|
||||
{
|
||||
//ImVector<const char*> device_extensions;
|
||||
//device_extensions.push_back("VK_KHR_swapchain");
|
||||
uint32_t device_extensions_count = 1;
|
||||
const char** device_extensions = (const char**)malloc(device_extensions_count * sizeof(char*));
|
||||
device_extensions[0] = "VK_KHR_swapchain";
|
||||
|
||||
// Enumerate physical device extension
|
||||
uint32_t properties_count;
|
||||
//ImVector<VkExtensionProperties> properties;
|
||||
vkEnumerateDeviceExtensionProperties(g_PhysicalDevice, NULL, &properties_count, NULL);
|
||||
//properties.resize(properties_count);
|
||||
VkExtensionProperties* properties = (VkExtensionProperties*)malloc(properties_count * sizeof(VkExtensionProperties));
|
||||
vkEnumerateDeviceExtensionProperties(g_PhysicalDevice, NULL, &properties_count, properties);
|
||||
#ifdef VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME
|
||||
if (IsExtensionAvailable(properties, properties_count, VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME)){
|
||||
//device_extensions.push_back(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME);
|
||||
device_extensions_count++;
|
||||
device_extensions = realloc(device_extensions, device_extensions_count * sizeof(const char*));
|
||||
assert(device_extensions);
|
||||
device_extensions[device_extensions_count-1] = VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME;
|
||||
}
|
||||
#endif
|
||||
|
||||
const float queue_priority[] = { 1.0f };
|
||||
VkDeviceQueueCreateInfo queue_info[1] = {};
|
||||
queue_info[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||
queue_info[0].queueFamilyIndex = g_QueueFamily;
|
||||
queue_info[0].queueCount = 1;
|
||||
queue_info[0].pQueuePriorities = queue_priority;
|
||||
VkDeviceCreateInfo create_info = {};
|
||||
create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
||||
create_info.queueCreateInfoCount = sizeof(queue_info) / sizeof(queue_info[0]);
|
||||
create_info.pQueueCreateInfos = queue_info;
|
||||
create_info.enabledExtensionCount = device_extensions_count; //(uint32_t)device_extensions.Size;
|
||||
create_info.ppEnabledExtensionNames = device_extensions;//device_extensions.Data;
|
||||
err = vkCreateDevice(g_PhysicalDevice, &create_info, g_Allocator, &g_Device);
|
||||
check_vk_result_line(err, __LINE__);
|
||||
vkGetDeviceQueue(g_Device, g_QueueFamily, 0, &g_Queue);
|
||||
}
|
||||
// Create Descriptor Pool
|
||||
// If you wish to load e.g. additional textures you may need to alter pools sizes and maxSets.
|
||||
{
|
||||
VkDescriptorPoolSize pool_sizes[] =
|
||||
{
|
||||
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE },
|
||||
};
|
||||
VkDescriptorPoolCreateInfo pool_info = {};
|
||||
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||
pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
|
||||
pool_info.maxSets = 0;
|
||||
//for (VkDescriptorPoolSize& pool_size : pool_sizes)
|
||||
// pool_info.maxSets += pool_size.descriptorCount;
|
||||
for(int i = 0; i < IM_ARRAYSIZE(pool_sizes); i++){
|
||||
VkDescriptorPoolSize pool_size = pool_sizes[i];
|
||||
pool_info.maxSets += pool_size.descriptorCount;
|
||||
}
|
||||
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes);
|
||||
pool_info.pPoolSizes = pool_sizes;
|
||||
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
|
||||
check_vk_result_line(err, __LINE__);
|
||||
}
|
||||
}
|
||||
//*/
|
||||
// All the ImGui_ImplVulkanH_XXX structures/functions are optional helpers used by the demo.
|
||||
// Your real engine/app may not use them.
|
||||
static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface, int width, int height)
|
||||
{
|
||||
wd->Surface = surface;
|
||||
|
||||
// Check for WSI support
|
||||
VkBool32 res;
|
||||
vkGetPhysicalDeviceSurfaceSupportKHR(g_PhysicalDevice, g_QueueFamily, wd->Surface, &res);
|
||||
if (res != VK_TRUE)
|
||||
{
|
||||
fprintf(stderr, "Error no WSI support on physical device 0\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// Select Surface Format
|
||||
const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };
|
||||
const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
|
||||
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace);
|
||||
|
||||
// Select Present Mode
|
||||
#ifdef APP_USE_UNLIMITED_FRAME_RATE
|
||||
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
|
||||
#else
|
||||
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
|
||||
#endif
|
||||
wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes));
|
||||
//printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode);
|
||||
|
||||
// Create SwapChain, RenderPass, Framebuffer, etc.
|
||||
IM_ASSERT(g_MinImageCount >= 2);
|
||||
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount);
|
||||
}
|
||||
|
||||
static void CleanupVulkan()
|
||||
{
|
||||
vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
|
||||
|
||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
||||
// Remove the debug report callback
|
||||
PFN_vkDestroyDebugReportCallbackEXT f_vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
|
||||
f_vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
|
||||
#endif // APP_USE_VULKAN_DEBUG_REPORT
|
||||
|
||||
vkDestroyDevice(g_Device, g_Allocator);
|
||||
vkDestroyInstance(g_Instance, g_Allocator);
|
||||
}
|
||||
|
||||
static void CleanupVulkanWindow()
|
||||
{
|
||||
ImGui_ImplVulkanH_DestroyWindow(g_Instance, g_Device, &g_MainWindowData, g_Allocator);
|
||||
}
|
||||
|
||||
static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data)
|
||||
{
|
||||
VkSemaphore image_acquired_semaphore = wd->FrameSemaphores.Data[wd->SemaphoreIndex].ImageAcquiredSemaphore;
|
||||
VkSemaphore render_complete_semaphore = wd->FrameSemaphores.Data[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
||||
VkResult err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex);
|
||||
if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR)
|
||||
g_SwapChainRebuild = true;
|
||||
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||
return;
|
||||
if (err != VK_SUBOPTIMAL_KHR)
|
||||
check_vk_result_line(err, __LINE__);
|
||||
|
||||
ImGui_ImplVulkanH_Frame* fd = &wd->Frames.Data[wd->FrameIndex];
|
||||
{
|
||||
err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking
|
||||
check_vk_result_line(err, __LINE__);
|
||||
|
||||
err = vkResetFences(g_Device, 1, &fd->Fence);
|
||||
check_vk_result_line(err, __LINE__);
|
||||
}
|
||||
{
|
||||
err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
|
||||
check_vk_result_line(err, __LINE__);
|
||||
VkCommandBufferBeginInfo info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
|
||||
info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
|
||||
err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
|
||||
check_vk_result_line(err, __LINE__);
|
||||
}
|
||||
{
|
||||
VkRenderPassBeginInfo info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||
info.renderPass = wd->RenderPass;
|
||||
info.framebuffer = fd->Framebuffer;
|
||||
info.renderArea.extent.width = wd->Width;
|
||||
info.renderArea.extent.height = wd->Height;
|
||||
info.clearValueCount = 1;
|
||||
info.pClearValues = &wd->ClearValue;
|
||||
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
|
||||
}
|
||||
|
||||
// Record dear imgui primitives into command buffer
|
||||
ImGui_ImplVulkan_RenderDrawData(draw_data, fd->CommandBuffer, VK_NULL_HANDLE);
|
||||
|
||||
// Submit command buffer
|
||||
vkCmdEndRenderPass(fd->CommandBuffer);
|
||||
{
|
||||
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
VkSubmitInfo info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||
info.waitSemaphoreCount = 1;
|
||||
info.pWaitSemaphores = &image_acquired_semaphore;
|
||||
info.pWaitDstStageMask = &wait_stage;
|
||||
info.commandBufferCount = 1;
|
||||
info.pCommandBuffers = &fd->CommandBuffer;
|
||||
info.signalSemaphoreCount = 1;
|
||||
info.pSignalSemaphores = &render_complete_semaphore;
|
||||
|
||||
err = vkEndCommandBuffer(fd->CommandBuffer);
|
||||
check_vk_result_line(err, __LINE__);
|
||||
err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
|
||||
check_vk_result_line(err, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
||||
{
|
||||
if (g_SwapChainRebuild)
|
||||
return;
|
||||
VkSemaphore render_complete_semaphore = wd->FrameSemaphores.Data[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
||||
VkPresentInfoKHR info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||
info.waitSemaphoreCount = 1;
|
||||
info.pWaitSemaphores = &render_complete_semaphore;
|
||||
info.swapchainCount = 1;
|
||||
info.pSwapchains = &wd->Swapchain;
|
||||
info.pImageIndices = &wd->FrameIndex;
|
||||
VkResult err = vkQueuePresentKHR(g_Queue, &info);
|
||||
if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR)
|
||||
g_SwapChainRebuild = true;
|
||||
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||
return;
|
||||
if (err != VK_SUBOPTIMAL_KHR)
|
||||
check_vk_result_line(err, __LINE__);
|
||||
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->SemaphoreCount; // Now we can use the next set of semaphores
|
||||
}
|
||||
|
||||
// Main code
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
//g_MainWindowData.ClearEnable = true;
|
||||
//ImGui_ImplVulkanH_Window_Construct(&g_MainWindowData);
|
||||
g_MainWindowData = *ImGui_ImplVulkanH_Window_ImGui_ImplVulkanH_Window();
|
||||
// Setup SDL
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD))
|
||||
{
|
||||
printf("Error: SDL_Init(): %s\n", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
// From 2.0.18: Enable native IME.
|
||||
#ifdef SDL_HINT_IME_SHOW_UI
|
||||
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
||||
#endif
|
||||
|
||||
// Create window with Vulkan graphics context
|
||||
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());
|
||||
return -1;
|
||||
}
|
||||
// Setup Vulkan
|
||||
uint32_t extensions_count = 0;
|
||||
const char *const *extensions_nude = SDL_Vulkan_GetInstanceExtensions(&extensions_count);
|
||||
if (extensions_nude == NULL) {
|
||||
printf("Error: SDL_Vulkan_GetInstanceExtensions(): %s\n", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
const char** extensions = (const char**)malloc(extensions_count * sizeof(const char*));
|
||||
if (extensions == NULL) {
|
||||
printf("Error allocating space for extensions array\n");
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < extensions_count; i++) {
|
||||
extensions[i] = extensions_nude[i];
|
||||
}
|
||||
SetupVulkan(extensions, extensions_count);
|
||||
//leak?? but free crashes
|
||||
// free(extensions);
|
||||
// Create Window Surface
|
||||
VkSurfaceKHR surface;
|
||||
VkResult err;
|
||||
if (SDL_Vulkan_CreateSurface(window, g_Instance, g_Allocator, &surface) == 0)
|
||||
{
|
||||
printf("Failed to create Vulkan surface.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create Framebuffers
|
||||
int w, h;
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
ImGui_ImplVulkanH_Window* wd = &g_MainWindowData;
|
||||
SetupVulkanWindow(wd, surface, w, h);
|
||||
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
SDL_ShowWindow(window);
|
||||
|
||||
// Setup Dear ImGui context
|
||||
//IMGUI_CHECKVERSION();
|
||||
igCreateContext(NULL);
|
||||
ImGuiIO* io = igGetIO(); (void)io;
|
||||
io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
io->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
io->ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||
io->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge;
|
||||
|
||||
// Setup Dear ImGui style
|
||||
igStyleColorsDark(NULL);
|
||||
//ImGui::StyleColorsLight();
|
||||
|
||||
// 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;
|
||||
style->Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||
}
|
||||
|
||||
// Setup Platform/Renderer backends
|
||||
ImGui_ImplSDL3_InitForVulkan(window);
|
||||
ImGui_ImplVulkan_InitInfo init_info = {};
|
||||
init_info.Instance = g_Instance;
|
||||
init_info.PhysicalDevice = g_PhysicalDevice;
|
||||
init_info.Device = g_Device;
|
||||
init_info.QueueFamily = g_QueueFamily;
|
||||
init_info.Queue = g_Queue;
|
||||
init_info.PipelineCache = g_PipelineCache;
|
||||
init_info.DescriptorPool = g_DescriptorPool;
|
||||
init_info.RenderPass = wd->RenderPass;
|
||||
init_info.Subpass = 0;
|
||||
init_info.MinImageCount = g_MinImageCount;
|
||||
init_info.ImageCount = wd->ImageCount;
|
||||
init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
||||
init_info.Allocator = g_Allocator;
|
||||
init_info.CheckVkResultFn = check_vk_result;
|
||||
ImGui_ImplVulkan_Init(&init_info);
|
||||
|
||||
// Load Fonts
|
||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||
//io.Fonts->AddFontDefault();
|
||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf", 18.0f);
|
||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
|
||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
|
||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, nullptr, io.Fonts->GetGlyphRangesJapanese());
|
||||
//IM_ASSERT(font != nullptr);
|
||||
|
||||
// Our state
|
||||
bool show_demo_window = true;
|
||||
bool show_another_window = false;
|
||||
ImVec4 clear_color;
|
||||
clear_color.x = 0.45f;
|
||||
clear_color.y = 0.55f;
|
||||
clear_color.z = 0.60f;
|
||||
clear_color.w = 1.00f;
|
||||
|
||||
// Main loop
|
||||
bool done = false;
|
||||
while (!done)
|
||||
{
|
||||
// Poll and handle events (inputs, window resize, etc.)
|
||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
|
||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
|
||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
ImGui_ImplSDL3_ProcessEvent(&event);
|
||||
if (event.type == SDL_EVENT_QUIT)
|
||||
done = true;
|
||||
if (event.type == SDL_EVENT_WINDOW_CLOSE_REQUESTED && event.window.windowID == SDL_GetWindowID(window))
|
||||
done = true;
|
||||
}
|
||||
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)
|
||||
{
|
||||
SDL_Delay(10);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Resize swap chain?
|
||||
int fb_width, fb_height;
|
||||
SDL_GetWindowSize(window, &fb_width, &fb_height);
|
||||
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_width, fb_height, g_MinImageCount);
|
||||
g_MainWindowData.FrameIndex = 0;
|
||||
g_SwapChainRebuild = false;
|
||||
}
|
||||
|
||||
// Start the Dear ImGui frame
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
igNewFrame();
|
||||
|
||||
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||
if (show_demo_window)
|
||||
igShowDemoWindow(&show_demo_window);
|
||||
|
||||
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window.
|
||||
{
|
||||
static float f = 0.0f;
|
||||
static int counter = 0;
|
||||
|
||||
igBegin("Hello, world!", NULL, 0);
|
||||
igText("This is some useful text");
|
||||
igCheckbox("Demo window", &show_demo_window);
|
||||
igCheckbox("Another window", &show_another_window);
|
||||
|
||||
igSliderFloat("Float", &f, 0.0f, 1.0f, "%.3f", 0);
|
||||
igColorEdit3("clear color", (float*)&clear_color, 0);
|
||||
|
||||
ImVec2 buttonSize;
|
||||
buttonSize.x = 0;
|
||||
buttonSize.y = 0;
|
||||
if (igButton("Button", buttonSize))
|
||||
counter++;
|
||||
igSameLine(0.0f, -1.0f);
|
||||
igText("counter = %d", counter);
|
||||
|
||||
igText("Application average %.3f ms/frame (%.1f FPS)",
|
||||
1000.0f / igGetIO()->Framerate, igGetIO()->Framerate);
|
||||
igEnd();
|
||||
}
|
||||
|
||||
// 3. Show another simple window.
|
||||
if (show_another_window)
|
||||
{
|
||||
igBegin("imgui Another Window", &show_another_window, 0);
|
||||
igText("Hello from imgui");
|
||||
ImVec2 buttonSize;
|
||||
buttonSize.x = 0; buttonSize.y = 0;
|
||||
if (igButton("Close me", buttonSize))
|
||||
{
|
||||
show_another_window = false;
|
||||
}
|
||||
igEnd();
|
||||
}
|
||||
|
||||
// Rendering
|
||||
igRender();
|
||||
ImDrawData* main_draw_data = igGetDrawData();
|
||||
const bool main_is_minimized = (main_draw_data->DisplaySize.x <= 0.0f || main_draw_data->DisplaySize.y <= 0.0f);
|
||||
wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w;
|
||||
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w;
|
||||
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
|
||||
wd->ClearValue.color.float32[3] = clear_color.w;
|
||||
if (!main_is_minimized)
|
||||
FrameRender(wd, main_draw_data);
|
||||
|
||||
// Update and Render additional Platform Windows
|
||||
if (io->ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||
{
|
||||
igUpdatePlatformWindows();
|
||||
igRenderPlatformWindowsDefault(NULL, NULL);
|
||||
}
|
||||
|
||||
// Present Main Platform Window
|
||||
if (!main_is_minimized)
|
||||
FramePresent(wd);
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
err = vkDeviceWaitIdle(g_Device);
|
||||
check_vk_result_line(err, __LINE__);
|
||||
ImGui_ImplVulkan_Shutdown();
|
||||
ImGui_ImplSDL3_Shutdown();
|
||||
igDestroyContext(NULL);
|
||||
|
||||
CleanupVulkanWindow();
|
||||
CleanupVulkan();
|
||||
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
@@ -22,7 +22,6 @@ else()
|
||||
endif()
|
||||
|
||||
include_directories(../../imgui)
|
||||
add_definitions("-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
|
||||
|
||||
include_directories(../../)
|
||||
set(IMGUI_SOURCES
|
||||
@@ -37,11 +36,7 @@ ${TABLES_SOURCE}
|
||||
set(IMGUI_SOURCES_sdl)
|
||||
set(IMGUI_LIBRARIES )
|
||||
|
||||
if (WIN32)
|
||||
add_definitions("-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
|
||||
else(WIN32)
|
||||
add_definitions("-DIMGUI_IMPL_API=extern \"C\" ")
|
||||
endif(WIN32)
|
||||
|
||||
|
||||
add_compile_definitions("IMGUI_IMPL_OPENGL_LOADER_GL3W")
|
||||
|
||||
@@ -65,47 +60,46 @@ else(WIN32)#Unix
|
||||
endif(WIN32)
|
||||
|
||||
|
||||
#sdl2
|
||||
list(APPEND IMGUI_SOURCES ${BAKENDS_FOLDER}imgui_impl_sdl2.cpp)
|
||||
if(DEFINED SDL_PATH)
|
||||
message(STATUS "SDL_PATH defined as " ${SDL_PATH})
|
||||
FIND_PACKAGE(SDL2 PATHS ${SDL_PATH})
|
||||
else(DEFINED SDL_PATH)
|
||||
# If SDL_PATH is not set, fallback and attempt to find SDL cmake script at a default location
|
||||
find_package(SDL2)
|
||||
endif(DEFINED SDL_PATH)
|
||||
include(FetchContent)
|
||||
Set(FETCHCONTENT_QUIET FALSE)
|
||||
|
||||
if(SDL2_FOUND)
|
||||
get_target_property(SDL_INCLUDE SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)
|
||||
message(STATUS "sdlinclude is " ${SDL_INCLUDE})
|
||||
if ("${SDL_INCLUDE}" STREQUAL "" OR "${SDL_INCLUDE}" STREQUAL "SDL_INCLUDE-NOTFOUND") #if not found latest SDL2 cmake config use older
|
||||
message(STATUS "sdlinclude2 is " ${SDL2_INCLUDE_DIRS})
|
||||
include_directories(${SDL2_INCLUDE_DIRS})
|
||||
set(IMGUI_SDL_LIBRARY ${SDL2_LIBRARIES})
|
||||
message(STATUS IMGUI_SDL_LIBRARY ${SDL2_LIBRARIES})
|
||||
else()#use new one SDL2 config
|
||||
include_directories(${SDL_INCLUDE})
|
||||
set(IMGUI_SDL_LIBRARY SDL2::SDL2)
|
||||
set(SDL_MAIN SDL2::SDL2main)
|
||||
message(STATUS ${SDL_MAIN} ${IMGUI_SDL_LIBRARY})
|
||||
endif()
|
||||
else(SDL2_FOUND)
|
||||
if(DEFINED SDL_PATH)
|
||||
message(FATAL_ERROR "Cannot find SDL at SDL_PATH")
|
||||
else(DEFINED SDL_PATH)
|
||||
message(FATAL_ERROR "Cannot find SDL. Maybe try specifying SDL_PATH?")
|
||||
endif(DEFINED SDL_PATH)
|
||||
endif(SDL2_FOUND)
|
||||
FetchContent_Declare(
|
||||
SDL2
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
||||
GIT_TAG release-2.30.12
|
||||
#GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
#FetchContent_MakeAvailable(SDL2)
|
||||
FetchContent_GetProperties(SDL2)
|
||||
if (NOT sdl2_POPULATED)
|
||||
set(FETCHCONTENT_QUIET NO)
|
||||
FetchContent_Populate(SDL2)
|
||||
set(SDL_TEST OFF CACHE BOOL "" FORCE)
|
||||
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
|
||||
add_subdirectory(${sdl2_SOURCE_DIR} ${sdl2_BINARY_DIR})
|
||||
endif()
|
||||
include_directories(${SDL2_SOURCE_DIR}/include})
|
||||
|
||||
#if dynamic SDL2 then install
|
||||
install(TARGETS SDL2 RUNTIME DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||
LIBRARY DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_library(cimgui_sdl SHARED ${IMGUI_SOURCES})
|
||||
target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} ${IMGUI_SDL_LIBRARY})
|
||||
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
|
||||
if (WIN32)
|
||||
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
|
||||
else(WIN32)
|
||||
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_IMPL_API=extern \"C\" ")
|
||||
endif(WIN32)
|
||||
target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} SDL2)
|
||||
|
||||
#using library
|
||||
include_directories(../../generator/output/)
|
||||
add_executable(test_sdl main.c)
|
||||
target_compile_definitions(test_sdl PUBLIC -DCIMGUI_USE_OPENGL3 -DCIMGUI_USE_SDL2)
|
||||
if (MINGW)
|
||||
target_link_options(test_sdl PRIVATE "-mconsole")
|
||||
endif()
|
||||
target_link_libraries(test_sdl ${IMGUI_SDL_LIBRARY} cimgui_sdl)
|
||||
|
||||
target_link_libraries(test_sdl SDL2 cimgui_sdl)
|
||||
|
2
backend_test/example_sdl_opengl3/README.md
Normal file
2
backend_test/example_sdl_opengl3/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
To build use `cmake path_to_example_sdl_opengl3` and then `make install`
|
@@ -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
|
||||
@@ -18,10 +22,15 @@
|
||||
#define igButton igButton_Str
|
||||
#endif
|
||||
|
||||
#define igGetIO igGetIO_Nil
|
||||
|
||||
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());
|
||||
@@ -52,11 +61,10 @@ int main(int argc, char* argv[])
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_DisplayMode current;
|
||||
SDL_GetCurrentDisplayMode(0, ¤t);
|
||||
|
||||
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;
|
||||
@@ -81,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);
|
||||
|
||||
|
@@ -18,11 +18,12 @@ else()
|
||||
set(TABLES_SOURCE "")
|
||||
endif()
|
||||
|
||||
include_directories(../../imgui)
|
||||
add_definitions("-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
|
||||
include_directories(../../imgui ../../imgui/backends)
|
||||
|
||||
|
||||
include_directories(../../)
|
||||
set(IMGUI_SOURCES ../../cimgui.cpp
|
||||
../../cimgui_impl.cpp
|
||||
../../imgui/imgui.cpp
|
||||
../../imgui/imgui_draw.cpp
|
||||
../../imgui/imgui_demo.cpp
|
||||
@@ -33,11 +34,6 @@ ${TABLES_SOURCE}
|
||||
set(IMGUI_SOURCES_sdl)
|
||||
set(IMGUI_LIBRARIES )
|
||||
|
||||
if (WIN32)
|
||||
add_definitions("-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
|
||||
else(WIN32)
|
||||
add_definitions("-DIMGUI_IMPL_API=extern \"C\" ")
|
||||
endif(WIN32)
|
||||
|
||||
#optional adding freetype
|
||||
option(IMGUI_FREETYPE "add Freetype2" OFF)
|
||||
@@ -53,48 +49,52 @@ endif(IMGUI_FREETYPE)
|
||||
find_package(Vulkan REQUIRED FATAL_ERROR)
|
||||
list(APPEND IMGUI_LIBRARIES Vulkan::Vulkan)
|
||||
list(APPEND IMGUI_SOURCES ${BACKENDS_FOLDER}imgui_impl_vulkan.cpp)
|
||||
include_directories(${Vulkan_INCLUDE_DIRS})
|
||||
|
||||
#sdl2
|
||||
list(APPEND IMGUI_SOURCES ${BACKENDS_FOLDER}imgui_impl_sdl2.cpp)
|
||||
if(DEFINED SDL_PATH)
|
||||
message(STATUS "SDL_PATH defined as " ${SDL_PATH})
|
||||
FIND_PACKAGE(SDL2 PATHS ${SDL_PATH})
|
||||
else(DEFINED SDL_PATH)
|
||||
# If SDL_PATH is not set, fallback and attempt to find SDL cmake script at a default location
|
||||
find_package(SDL2)
|
||||
endif(DEFINED SDL_PATH)
|
||||
include(FetchContent)
|
||||
Set(FETCHCONTENT_QUIET FALSE)
|
||||
|
||||
if(SDL2_FOUND)
|
||||
get_target_property(SDL_INCLUDE SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)
|
||||
message(STATUS "sdlinclude is " ${SDL_INCLUDE})
|
||||
if ("${SDL_INCLUDE}" STREQUAL "" OR "${SDL_INCLUDE}" STREQUAL "SDL_INCLUDE-NOTFOUND") #if not found latest SDL2 cmake config use older
|
||||
message(STATUS "sdlinclude2 is " ${SDL2_INCLUDE_DIRS})
|
||||
include_directories(${SDL2_INCLUDE_DIRS})
|
||||
set(IMGUI_SDL_LIBRARY ${SDL2_LIBRARIES})
|
||||
message(STATUS IMGUI_SDL_LIBRARY ${SDL2_LIBRARIES})
|
||||
else()#use new one SDL2 config
|
||||
include_directories(${SDL_INCLUDE})
|
||||
set(IMGUI_SDL_LIBRARY SDL2::SDL2)
|
||||
set(SDL_MAIN SDL2::SDL2main)
|
||||
message(STATUS ${SDL_MAIN} ${IMGUI_SDL_LIBRARY})
|
||||
endif()
|
||||
else(SDL2_FOUND)
|
||||
if(DEFINED SDL_PATH)
|
||||
message(FATAL_ERROR "Cannot find SDL at SDL_PATH")
|
||||
else(DEFINED SDL_PATH)
|
||||
message(FATAL_ERROR "Cannot find SDL. Maybe try specifying SDL_PATH?")
|
||||
endif(DEFINED SDL_PATH)
|
||||
endif(SDL2_FOUND)
|
||||
FetchContent_Declare(
|
||||
SDL2
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
||||
GIT_TAG release-2.30.12
|
||||
#GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
FetchContent_GetProperties(SDL2)
|
||||
if (NOT sdl2_POPULATED)
|
||||
set(FETCHCONTENT_QUIET NO)
|
||||
FetchContent_Populate(SDL2)
|
||||
set(SDL_TEST OFF CACHE BOOL "" FORCE)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(${sdl2_SOURCE_DIR} ${sdl2_BINARY_DIR})
|
||||
endif()
|
||||
include_directories(${SDL2_SOURCE_DIR}/include)
|
||||
|
||||
add_library(cimgui_sdl SHARED ${IMGUI_SOURCES})
|
||||
target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} ${IMGUI_SDL_LIBRARY})
|
||||
|
||||
#if dynamic SDL2 then install
|
||||
# install(TARGETS SDL2 RUNTIME DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||
# LIBRARY DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||
# )
|
||||
|
||||
add_library(cimgui_sdl STATIC ${IMGUI_SOURCES})
|
||||
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_USER_CONFIG=\"../cimconfig.h\"")
|
||||
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
|
||||
target_compile_definitions(cimgui_sdl PUBLIC -DCIMGUI_USE_VULKAN -DCIMGUI_USE_SDL2)
|
||||
if (WIN32)
|
||||
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
|
||||
else(WIN32)
|
||||
target_compile_definitions(cimgui_sdl PUBLIC "-DIMGUI_IMPL_API=extern \"C\" ")
|
||||
endif(WIN32)
|
||||
#target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} SDL2-static)
|
||||
|
||||
#using library
|
||||
include_directories(../../generator/output/)
|
||||
add_executable(test_sdl main.c)
|
||||
target_compile_definitions(test_sdl PUBLIC -DCIMGUI_USE_VULKAN -DCIMGUI_USE_SDL2)
|
||||
if (MINGW)
|
||||
target_link_options(test_sdl PRIVATE "-mconsole")
|
||||
endif()
|
||||
target_link_libraries(test_sdl ${IMGUI_SDL_LIBRARY} cimgui_sdl)
|
||||
target_link_libraries(test_sdl SDL2-static cimgui_sdl ${IMGUI_LIBRARIES})
|
||||
|
||||
|
2
backend_test/example_sdl_vulkan/README.md
Normal file
2
backend_test/example_sdl_vulkan/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
To build use `cmake path_to_example_sdl_vulkan` and then `make install`
|
File diff suppressed because it is too large
Load Diff
33
backend_test/example_sdlgpu3/CMakeLists.txt
Normal file
33
backend_test/example_sdlgpu3/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
cmake_minimum_required(VERSION 3.30)
|
||||
project(cimgui_sdlgpu3 LANGUAGES C CXX)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
sdl3
|
||||
URL https://github.com/libsdl-org/SDL/releases/download/release-3.2.8/SDL3-3.2.8.tar.gz
|
||||
)
|
||||
|
||||
set(SDL_TEST_LIBRARY OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(sdl3)
|
||||
|
||||
include(../cmake/GenerateCimguiBindings.cmake)
|
||||
|
||||
set(inclulist ${sdl3_SOURCE_DIR}/include)
|
||||
GenerateCimguiBindings(cimgui_with_backend sdl3 sdlgpu3 inclulist)
|
||||
target_link_libraries(cimgui_with_backend PRIVATE SDL3::SDL3)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
main.c
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE SDL3::SDL3 cimgui_with_backend)
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
CIMGUI_DEFINE_ENUMS_AND_STRUCTS=1
|
||||
CIMGUI_USE_SDL3=1
|
||||
CIMGUI_USE_SDLGPU3=1
|
||||
)
|
16
backend_test/example_sdlgpu3/README.md
Normal file
16
backend_test/example_sdlgpu3/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# SDLGPU3
|
||||
|
||||
This example is a little different from the others, because `cimgui` doesn't come with bindings for the SDLGPU3 backend out of the box. Instead, this example shows how to generate the necessary bindings during cmake's configure time, then add the compiled library as a target for your application to link to.
|
||||
|
||||
For the generation phase from cmake you need LuaJIT to be present.
|
||||
|
||||
## Building
|
||||
|
||||
From the build directory of your choice:
|
||||
|
||||
`cmake path_to_example_sdlgpu3`
|
||||
|
||||
and after
|
||||
|
||||
`make`
|
||||
|
216
backend_test/example_sdlgpu3/main.c
Normal file
216
backend_test/example_sdlgpu3/main.c
Normal file
@@ -0,0 +1,216 @@
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_gpu.h>
|
||||
|
||||
#include <cimgui.h>
|
||||
#include <cimgui_impl.h>
|
||||
|
||||
|
||||
#define igGetIO igGetIO_Nil
|
||||
|
||||
int main() {
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) {
|
||||
fprintf(stderr, "Failed to init video! %s", SDL_GetError());
|
||||
return 1;
|
||||
};
|
||||
|
||||
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);
|
||||
if (gpu_device == NULL)
|
||||
{
|
||||
printf("Error: SDL_CreateGPUDevice(): %s\n", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Claim window for GPU Device
|
||||
if (!SDL_ClaimWindowForGPUDevice(gpu_device, window))
|
||||
{
|
||||
printf("Error: SDL_ClaimWindowForGPUDevice(): %s\n", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
SDL_SetGPUSwapchainParameters(gpu_device, window, SDL_GPU_SWAPCHAINCOMPOSITION_SDR, SDL_GPU_PRESENTMODE_MAILBOX);
|
||||
|
||||
// Setup Dear ImGui context
|
||||
//IMGUI_CHECKVERSION();
|
||||
igCreateContext(NULL);
|
||||
ImGuiIO* io = igGetIO(); (void)io;
|
||||
io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
io->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
|
||||
// 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);
|
||||
ImGui_ImplSDLGPU3_InitInfo init_info;//= {};
|
||||
init_info.Device = gpu_device;
|
||||
init_info.ColorTargetFormat = SDL_GetGPUSwapchainTextureFormat(gpu_device, window);
|
||||
init_info.MSAASamples = SDL_GPU_SAMPLECOUNT_1;
|
||||
ImGui_ImplSDLGPU3_Init(&init_info);
|
||||
// finish loading data
|
||||
|
||||
// Our state
|
||||
bool show_demo_window = true;
|
||||
bool show_another_window = false;
|
||||
ImVec4 clear_color;
|
||||
clear_color.x = 0.45f;
|
||||
clear_color.y = 0.55f;
|
||||
clear_color.z = 0.60f;
|
||||
clear_color.w = 1.00f;
|
||||
|
||||
// Main loop
|
||||
bool done = false;
|
||||
while (!done)
|
||||
{
|
||||
// Poll and handle events (inputs, window resize, etc.)
|
||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
|
||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
|
||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||
// [If using SDL_MAIN_USE_CALLBACKS: call ImGui_ImplSDL3_ProcessEvent() from your SDL_AppEvent() function]
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
ImGui_ImplSDL3_ProcessEvent(&event);
|
||||
if (event.type == SDL_EVENT_QUIT)
|
||||
done = true;
|
||||
if (event.type == SDL_EVENT_WINDOW_CLOSE_REQUESTED && event.window.windowID == SDL_GetWindowID(window))
|
||||
done = true;
|
||||
}
|
||||
|
||||
// [If using SDL_MAIN_USE_CALLBACKS: all code below would likely be your SDL_AppIterate() function]
|
||||
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)
|
||||
{
|
||||
SDL_Delay(10);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Start the Dear ImGui frame
|
||||
ImGui_ImplSDLGPU3_NewFrame();
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
igNewFrame();
|
||||
|
||||
// 1. Show the big demo window (Most of the sample code is in igShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||
if (show_demo_window)
|
||||
igShowDemoWindow(&show_demo_window);
|
||||
|
||||
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window.
|
||||
{
|
||||
static float f = 0.0f;
|
||||
static int counter = 0;
|
||||
|
||||
igBegin("Hello, world!", NULL, 0); // Create a window called "Hello, world!" and append into it.
|
||||
|
||||
igText("This is some useful text."); // Display some text (you can use a format strings too)
|
||||
igCheckbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
||||
igCheckbox("Another Window", &show_another_window);
|
||||
|
||||
igSliderFloat("float", &f, 0.0f, 1.0f, "%.3f", 0); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||
igColorEdit4("clear color", (float*)&clear_color, 0); // Edit 3 floats representing a color
|
||||
|
||||
ImVec2 buttonSize;
|
||||
buttonSize.x = 0;
|
||||
buttonSize.y = 0;
|
||||
if (igButton("Button", buttonSize)) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||
counter++;
|
||||
igSameLine(0.0f, -1.0f);
|
||||
igText("counter = %d", counter);
|
||||
|
||||
igText("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io->Framerate, io->Framerate);
|
||||
igEnd();
|
||||
}
|
||||
|
||||
// 3. Show another simple window.
|
||||
if (show_another_window)
|
||||
{
|
||||
igBegin("Another Window", &show_another_window, 0); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
||||
igText("Hello from another window!");
|
||||
ImVec2 buttonSize;
|
||||
buttonSize.x = 0; buttonSize.y = 0;
|
||||
if (igButton("Close Me", buttonSize))
|
||||
show_another_window = false;
|
||||
igEnd();
|
||||
}
|
||||
|
||||
// Rendering
|
||||
igRender();
|
||||
ImDrawData* draw_data = igGetDrawData();
|
||||
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
|
||||
|
||||
SDL_GPUCommandBuffer* command_buffer = SDL_AcquireGPUCommandBuffer(gpu_device); // Acquire a GPU command buffer
|
||||
|
||||
SDL_GPUTexture* swapchain_texture;
|
||||
SDL_AcquireGPUSwapchainTexture(command_buffer, window, &swapchain_texture, NULL, NULL); // Acquire a swapchain texture
|
||||
|
||||
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);
|
||||
|
||||
// Setup and start a render pass
|
||||
SDL_GPUColorTargetInfo target_info ;//= {};
|
||||
target_info.texture = swapchain_texture;
|
||||
target_info.clear_color.r = clear_color.x;
|
||||
target_info.clear_color.g = clear_color.y;
|
||||
target_info.clear_color.b = clear_color.z;
|
||||
target_info.clear_color.a = clear_color.w;
|
||||
target_info.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||
target_info.store_op = SDL_GPU_STOREOP_STORE;
|
||||
target_info.mip_level = 0;
|
||||
target_info.layer_or_depth_plane = 0;
|
||||
target_info.cycle = false;
|
||||
target_info.resolve_texture = NULL;
|
||||
target_info.resolve_mip_level = 0;
|
||||
target_info.resolve_layer = 0;
|
||||
target_info.cycle_resolve_texture = false;
|
||||
target_info.padding1 = 0;
|
||||
target_info.padding2 = 0;
|
||||
SDL_GPURenderPass* render_pass = SDL_BeginGPURenderPass(command_buffer, &target_info, 1, NULL);
|
||||
|
||||
// Render ImGui
|
||||
ImGui_ImplSDLGPU3_RenderDrawData(draw_data, command_buffer, render_pass, NULL);
|
||||
|
||||
SDL_EndGPURenderPass(render_pass);
|
||||
}
|
||||
|
||||
// Submit the command buffer
|
||||
SDL_SubmitGPUCommandBuffer(command_buffer);
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
// [If using SDL_MAIN_USE_CALLBACKS: all code below would likely be your SDL_AppQuit() function]
|
||||
SDL_WaitForGPUIdle(gpu_device);
|
||||
ImGui_ImplSDL3_Shutdown();
|
||||
ImGui_ImplSDLGPU3_Shutdown();
|
||||
igDestroyContext(NULL);
|
||||
|
||||
SDL_ReleaseWindowFromGPUDevice(gpu_device, window);
|
||||
SDL_DestroyGPUDevice(gpu_device);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
1
cimconfig.h
Normal file
1
cimconfig.h
Normal file
@@ -0,0 +1 @@
|
||||
#undef NDEBUG
|
1334
cimgui.cpp
1334
cimgui.cpp
File diff suppressed because it is too large
Load Diff
46
cimgui_impl.cpp
Normal file
46
cimgui_impl.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "./imgui/imgui.h"
|
||||
#ifdef IMGUI_ENABLE_FREETYPE
|
||||
#include "./imgui/misc/freetype/imgui_freetype.h"
|
||||
#endif
|
||||
#include "./imgui/imgui_internal.h"
|
||||
#include "cimgui.h"
|
||||
|
||||
|
||||
#ifdef CIMGUI_USE_GLFW
|
||||
#include "imgui_impl_glfw.h"
|
||||
#endif
|
||||
|
||||
#ifdef CIMGUI_USE_OPENGL3
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#endif
|
||||
|
||||
#ifdef CIMGUI_USE_OPENGL2
|
||||
#include "imgui_impl_opengl2.h"
|
||||
#endif
|
||||
|
||||
#ifdef CIMGUI_USE_SDL2
|
||||
#include "imgui_impl_sdl2.h"
|
||||
#endif
|
||||
|
||||
#ifdef CIMGUI_USE_SDL3
|
||||
#include "imgui_impl_sdl3.h"
|
||||
#endif
|
||||
|
||||
#ifdef CIMGUI_USE_VULKAN
|
||||
#include "imgui_impl_vulkan.h"
|
||||
#endif
|
||||
|
||||
#include "cimgui_impl.h"
|
||||
|
||||
#ifdef CIMGUI_USE_VULKAN
|
||||
|
||||
CIMGUI_API ImGui_ImplVulkanH_Window* ImGui_ImplVulkanH_Window_ImGui_ImplVulkanH_Window()
|
||||
{
|
||||
return IM_NEW(ImGui_ImplVulkanH_Window)();
|
||||
}
|
||||
CIMGUI_API void ImGui_ImplVulkanH_Window_Construct(ImGui_ImplVulkanH_Window* self)
|
||||
{
|
||||
IM_PLACEMENT_NEW(self) ImGui_ImplVulkanH_Window();
|
||||
}
|
||||
|
||||
#endif
|
202
cimgui_impl.h
Normal file
202
cimgui_impl.h
Normal file
@@ -0,0 +1,202 @@
|
||||
#ifndef CIMGUI_IMPL_DEFINED
|
||||
#define CIMGUI_IMPL_DEFINED
|
||||
#ifdef CIMGUI_USE_GLFW
|
||||
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
|
||||
typedef struct GLFWwindow GLFWwindow;
|
||||
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_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);
|
||||
|
||||
#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 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 void ImGui_ImplOpenGL2_UpdateTexture(ImTextureData* tex);
|
||||
|
||||
#endif
|
||||
#ifdef CIMGUI_USE_SDL2
|
||||
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
|
||||
typedef struct SDL_Window SDL_Window;
|
||||
typedef struct SDL_Renderer SDL_Renderer;
|
||||
typedef struct _SDL_GameController _SDL_GameController;
|
||||
struct SDL_Window;
|
||||
struct SDL_Renderer;
|
||||
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 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_InitForOther(SDL_Window* window);
|
||||
CIMGUI_API void ImGui_ImplSDL2_Shutdown(void);
|
||||
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);
|
||||
|
||||
#endif
|
||||
#ifdef CIMGUI_USE_SDL3
|
||||
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
|
||||
typedef struct SDL_Window SDL_Window;
|
||||
typedef struct SDL_Renderer SDL_Renderer;
|
||||
typedef struct SDL_Gamepad SDL_Gamepad;
|
||||
struct SDL_Window;
|
||||
struct SDL_Renderer;
|
||||
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_InitForOther(SDL_Window* window);
|
||||
CIMGUI_API void ImGui_ImplSDL3_Shutdown(void);
|
||||
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);
|
||||
|
||||
#endif
|
||||
#ifdef CIMGUI_USE_VULKAN
|
||||
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
|
||||
typedef struct ImGui_ImplVulkanH_Frame ImGui_ImplVulkanH_Frame;
|
||||
typedef struct ImGui_ImplVulkanH_Window ImGui_ImplVulkanH_Window;
|
||||
typedef struct ImGui_ImplVulkan_InitInfo ImGui_ImplVulkan_InitInfo;
|
||||
struct ImGui_ImplVulkan_InitInfo
|
||||
{
|
||||
uint32_t ApiVersion;
|
||||
VkInstance Instance;
|
||||
VkPhysicalDevice PhysicalDevice;
|
||||
VkDevice Device;
|
||||
uint32_t QueueFamily;
|
||||
VkQueue Queue;
|
||||
VkDescriptorPool DescriptorPool;
|
||||
VkRenderPass RenderPass;
|
||||
uint32_t MinImageCount;
|
||||
uint32_t ImageCount;
|
||||
VkSampleCountFlagBits MSAASamples;
|
||||
VkPipelineCache PipelineCache;
|
||||
uint32_t Subpass;
|
||||
uint32_t DescriptorPoolSize;
|
||||
bool UseDynamicRendering;
|
||||
VkPipelineRenderingCreateInfoKHR PipelineRenderingCreateInfo;
|
||||
const VkAllocationCallbacks* Allocator;
|
||||
void (*CheckVkResultFn)(VkResult err);
|
||||
VkDeviceSize MinAllocationSize;
|
||||
};
|
||||
typedef struct ImGui_ImplVulkan_RenderState ImGui_ImplVulkan_RenderState;
|
||||
struct ImGui_ImplVulkan_RenderState
|
||||
{
|
||||
VkCommandBuffer CommandBuffer;
|
||||
VkPipeline Pipeline;
|
||||
VkPipelineLayout PipelineLayout;
|
||||
};
|
||||
struct ImGui_ImplVulkanH_Frame;
|
||||
struct ImGui_ImplVulkanH_Window;
|
||||
struct ImGui_ImplVulkanH_Frame
|
||||
{
|
||||
VkCommandPool CommandPool;
|
||||
VkCommandBuffer CommandBuffer;
|
||||
VkFence Fence;
|
||||
VkImage Backbuffer;
|
||||
VkImageView BackbufferView;
|
||||
VkFramebuffer Framebuffer;
|
||||
};
|
||||
typedef struct ImGui_ImplVulkanH_FrameSemaphores ImGui_ImplVulkanH_FrameSemaphores;
|
||||
struct ImGui_ImplVulkanH_FrameSemaphores
|
||||
{
|
||||
VkSemaphore ImageAcquiredSemaphore;
|
||||
VkSemaphore RenderCompleteSemaphore;
|
||||
};
|
||||
typedef struct ImVector_ImGui_ImplVulkanH_Frame {int Size;int Capacity;ImGui_ImplVulkanH_Frame* Data;} ImVector_ImGui_ImplVulkanH_Frame;
|
||||
|
||||
typedef struct ImVector_ImGui_ImplVulkanH_FrameSemaphores {int Size;int Capacity;ImGui_ImplVulkanH_FrameSemaphores* Data;} ImVector_ImGui_ImplVulkanH_FrameSemaphores;
|
||||
|
||||
struct ImGui_ImplVulkanH_Window
|
||||
{
|
||||
int Width;
|
||||
int Height;
|
||||
VkSwapchainKHR Swapchain;
|
||||
VkSurfaceKHR Surface;
|
||||
VkSurfaceFormatKHR SurfaceFormat;
|
||||
VkPresentModeKHR PresentMode;
|
||||
VkRenderPass RenderPass;
|
||||
bool UseDynamicRendering;
|
||||
bool ClearEnable;
|
||||
VkClearValue ClearValue;
|
||||
uint32_t FrameIndex;
|
||||
uint32_t ImageCount;
|
||||
uint32_t SemaphoreCount;
|
||||
uint32_t SemaphoreIndex;
|
||||
ImVector_ImGui_ImplVulkanH_Frame Frames;
|
||||
ImVector_ImGui_ImplVulkanH_FrameSemaphores FrameSemaphores;
|
||||
};
|
||||
#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
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_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);
|
||||
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_Window_ImGui_ImplVulkanH_Window(void);
|
||||
|
||||
#endif
|
||||
#endif //CIMGUI_IMPL_DEFINED
|
23
generator/cimgui_impl_template.cpp
Normal file
23
generator/cimgui_impl_template.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "./imgui/imgui.h"
|
||||
#ifdef IMGUI_ENABLE_FREETYPE
|
||||
#include "./imgui/misc/freetype/imgui_freetype.h"
|
||||
#endif
|
||||
#include "./imgui/imgui_internal.h"
|
||||
#include "cimgui.h"
|
||||
|
||||
GENERATED_PLACEHOLDER
|
||||
|
||||
#include "cimgui_impl.h"
|
||||
|
||||
#ifdef CIMGUI_USE_VULKAN
|
||||
|
||||
CIMGUI_API ImGui_ImplVulkanH_Window* ImGui_ImplVulkanH_Window_ImGui_ImplVulkanH_Window()
|
||||
{
|
||||
return IM_NEW(ImGui_ImplVulkanH_Window)();
|
||||
}
|
||||
CIMGUI_API void ImGui_ImplVulkanH_Window_Construct(ImGui_ImplVulkanH_Window* self)
|
||||
{
|
||||
IM_PLACEMENT_NEW(self) ImGui_ImplVulkanH_Window();
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,16 +1,5 @@
|
||||
#ifdef IMGUI_ENABLE_FREETYPE
|
||||
#ifndef CIMGUI_FREETYPE
|
||||
#error "IMGUI_FREETYPE should be defined for Freetype linking"
|
||||
#endif
|
||||
#else
|
||||
#ifdef CIMGUI_FREETYPE
|
||||
#error "IMGUI_FREETYPE should not be defined without freetype generated cimgui"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "./imgui/imgui.h"
|
||||
#ifdef IMGUI_ENABLE_FREETYPE
|
||||
#include "./imgui/misc/freetype/imgui_freetype.h"
|
||||
#endif
|
||||
#include "./imgui/imgui_internal.h"
|
||||
#include "cimgui.h"
|
||||
|
||||
@@ -20,21 +9,12 @@
|
||||
|
||||
|
||||
/////////////////////////////manual written functions
|
||||
CIMGUI_API void igLogText(CONST char *fmt, ...)
|
||||
{
|
||||
char buffer[256];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buffer, 256, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
ImGui::LogText("%s", buffer);
|
||||
}
|
||||
CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...)
|
||||
CIMGUI_API void ImGuiTextBuffer_appendf(ImGuiTextBuffer *self, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
buffer->appendfv(fmt, args);
|
||||
self->appendfv(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@@ -89,7 +69,7 @@ CimguiStorage& GetCimguiStorage()
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (io.BackendLanguageUserData == NULL)
|
||||
{
|
||||
io.BackendLanguageUserData = new CimguiStorage();
|
||||
io.BackendLanguageUserData = IM_NEW(CimguiStorage)();
|
||||
}
|
||||
|
||||
return *(CimguiStorage*)io.BackendLanguageUserData;
|
||||
|
@@ -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"
|
||||
@@ -46,10 +52,8 @@ typedef union SDL_Event SDL_Event;
|
||||
#include "auto_funcs.h"
|
||||
|
||||
/////////////////////////hand written functions
|
||||
//no LogTextV
|
||||
CIMGUI_API void igLogText(CONST char *fmt, ...);
|
||||
//no appendfV
|
||||
CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...);
|
||||
CIMGUI_API void ImGuiTextBuffer_appendf(ImGuiTextBuffer *self, const char *fmt, ...);
|
||||
//for getting FLT_MAX in bindings
|
||||
CIMGUI_API float igGET_FLT_MAX(void);
|
||||
//for getting FLT_MIN in bindings
|
||||
@@ -61,6 +65,10 @@ CIMGUI_API void ImVector_ImWchar_destroy(ImVector_ImWchar* self);
|
||||
CIMGUI_API void ImVector_ImWchar_Init(ImVector_ImWchar* p);
|
||||
CIMGUI_API void ImVector_ImWchar_UnInit(ImVector_ImWchar* p);
|
||||
|
||||
#ifdef IMGUI_HAS_DOCK
|
||||
CIMGUI_API void ImGuiPlatformIO_Set_Platform_GetWindowPos(ImGuiPlatformIO* platform_io, void(*user_callback)(ImGuiViewport* vp, ImVec2* out_pos));
|
||||
CIMGUI_API void ImGuiPlatformIO_Set_Platform_GetWindowSize(ImGuiPlatformIO* platform_io, void(*user_callback)(ImGuiViewport* vp, ImVec2* out_size));
|
||||
#endif
|
||||
|
||||
#endif //CIMGUI_INCLUDED
|
||||
|
||||
|
@@ -175,6 +175,7 @@ local function check_template(code)
|
||||
te = te:gsub("%-","less")
|
||||
te = te:gsub("%s","_")
|
||||
te = te:gsub("%*","Ptr")
|
||||
te = te:gsub("::","_")
|
||||
|
||||
code2 = code:gsub("(<[%w_%*%s]+>)([^%s%*])","%1 %2")
|
||||
code2 = code2:gsub("<([^<>]-)>","_"..te)
|
||||
@@ -202,6 +203,8 @@ local function parse_enum_value(value, allenums,dontpost)
|
||||
if allenums[clean(value)] then return allenums[clean(value)] end
|
||||
--must be several and operators
|
||||
------------precedence order (hope not ())
|
||||
--delete (int)
|
||||
value = value:gsub("%(int%)","")
|
||||
--first drop outer ()
|
||||
value = value:gsub("^(%()",""):gsub("(%))$","")
|
||||
assert(not value:match("[%(%)]"),value)
|
||||
@@ -317,6 +320,9 @@ local function getRE()
|
||||
function_re = "^([^;{}]+%b()[\n%s]*;)%s*",
|
||||
function_re = "^([^;{}=]+%b()[\n%s%w]*;)", --const at the end
|
||||
function_re = "^([^;{}=]+%b()[\n%s%w%(%)_]*;)", --attribute(deprecated)
|
||||
--we need to skip = as function because of "var = f()" initialization in struct fields
|
||||
-- but we don want operator== to appear as a var and as we should skip this kind of function solution is:
|
||||
operator_re = "^([^;{}]+operator[^;{}]+%b()[\n%s%w%(%)_]*;)",
|
||||
struct_re = "^([^;{}]-struct[^;{}]-%b{}[%s%w_%(%)]*;)",
|
||||
enum_re = "^([^;{}]-enum[^;{}]-%b{}[%s%w_%(%)]*;)",
|
||||
union_re = "^([^;{}]-union[^;{}]-%b{}[%s%w_%(%)]*;)",
|
||||
@@ -341,7 +347,7 @@ local function getRE()
|
||||
}
|
||||
|
||||
local resN = {"comment2_re","comment_re","emptyline_re",
|
||||
"functypedef_re","functype_re","function_re","functionD_re","typedef_st_re","struct_re","enum_re","union_re","namespace_re","class_re","typedef_re","vardef_re"}
|
||||
"functypedef_re","functype_re","function_re","functionD_re","operator_re","typedef_st_re","struct_re","enum_re","union_re","namespace_re","class_re","typedef_re","vardef_re"}
|
||||
|
||||
return res,resN
|
||||
end
|
||||
@@ -429,20 +435,15 @@ local function parseItems(txt,linenumdict, itparent, dumpit)
|
||||
loca = table.remove(loca,1)
|
||||
end
|
||||
if not loca then
|
||||
print("not loca",string.format("%q , %q ",itemold,itemfirstline),#itemfirstline)
|
||||
-- for k,v in pairs(linenumdict) do
|
||||
-- if k:match(itemfirstline) then
|
||||
-- print(string.format("%q",k),#k)
|
||||
-- end
|
||||
-- end
|
||||
--error"no entry in linenumdict"
|
||||
--take locat from parent
|
||||
if itparent and itparent.locat then
|
||||
loca = itparent.locat
|
||||
print("parent loca",string.format("%q , %q ",itemold,itemfirstline),#itemfirstline,loca)
|
||||
else
|
||||
loca = 0
|
||||
--error"no entry in linenumdict"
|
||||
print("not loca",string.format("%q , %q ",itemold,itemfirstline),#itemfirstline,loca)
|
||||
end
|
||||
|
||||
end
|
||||
else
|
||||
error"no linenumdict"
|
||||
@@ -478,7 +479,7 @@ local function parseItems(txt,linenumdict, itparent, dumpit)
|
||||
end
|
||||
return itemarr,items
|
||||
end
|
||||
M.parseItems = parseItems
|
||||
--M.parseItems = parseItems
|
||||
local function name_overloadsAlgo(v)
|
||||
|
||||
local aa = {} -- args
|
||||
@@ -602,7 +603,7 @@ local function clean_names_from_signature(self,signat)
|
||||
return result
|
||||
end
|
||||
local function clean_functypedef(line)
|
||||
local first, args = line:match("(typedef .-%(%*[_%w]+%))%s*(%b())")
|
||||
local first, args = line:match("(typedef .-%(%*%s*[_%w]+%))%s*(%b())")
|
||||
|
||||
if not args then
|
||||
print"not getting args in"
|
||||
@@ -670,14 +671,18 @@ local function CleanImU32(def)
|
||||
for i=1,#bb do res = res + bb[i] end
|
||||
return res
|
||||
end
|
||||
local function moveptr(line)
|
||||
line = line:gsub("%s*%*","%*")
|
||||
line = line:gsub("%*([%w_])","%* %1")
|
||||
line = line:gsub("(%(%*)%s","%1")
|
||||
return line
|
||||
end
|
||||
local function parseFunction(self,stname,itt,namespace,locat)
|
||||
|
||||
local lineorig,comment = split_comment(itt.item)
|
||||
line = clean_spaces(lineorig)
|
||||
--move *
|
||||
line = line:gsub("%s*%*","%*")
|
||||
line = line:gsub("%*([%w_])","%* %1")
|
||||
line = line:gsub("(%(%*)%s","%1")
|
||||
line = moveptr(line)
|
||||
|
||||
--print(line)
|
||||
--clean implemetation
|
||||
@@ -716,6 +721,21 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
||||
error"parseFunction not getting args"
|
||||
end
|
||||
|
||||
--get manuals args and ret
|
||||
local cname = self.getCname(stname,funcname, namespace) --cimguiname
|
||||
local manpars = self.manuals[cname]
|
||||
local ismanual
|
||||
if manpars then
|
||||
if type(manpars) == "boolean" then
|
||||
print("warning: unable to get args and ret from "..cname)
|
||||
print("did you forgot to use set_manuals? ")
|
||||
else
|
||||
ismanual = true
|
||||
args, ret = manpars.args, manpars.ret
|
||||
args = moveptr(args)
|
||||
ret = moveptr(ret)
|
||||
end
|
||||
end
|
||||
|
||||
local argsp = args:sub(2,-2)..","
|
||||
local argsTa = {}
|
||||
@@ -731,6 +751,8 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
||||
argsTa[#argsTa+1] = tynam
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- templates in args
|
||||
for i,ar in ipairs(argsTa) do
|
||||
--TODO several diferent templates
|
||||
@@ -744,13 +766,17 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
||||
end
|
||||
argsTa[i] = te and code2 or ar --ar:gsub("<([%w_%*%s]+)>",te) --ImVector
|
||||
end
|
||||
|
||||
|
||||
--get typ, name and defaults
|
||||
local functype_re = "^%s*[%w%s%*]+%(%*%s*[%w_]+%)%([^%(%)]*%)"
|
||||
local functype_reex = "^(%s*[%w%s%*]+)%(%*%s*([%w_]+)%)(%([^%(%)]*%))"
|
||||
local argsTa2 = {}
|
||||
local noname_counter = 0
|
||||
for i,ar in ipairs(argsTa) do
|
||||
--avoid var name without space type&name -> type& name
|
||||
-- also do type &name -> type& name
|
||||
--ar = ar:gsub("(%S)&(%S)","%1& %2")
|
||||
ar = ar:gsub("(%S)%s*&(%S)","%1& %2")
|
||||
local typ,name,retf,sigf,reftoptr,defa,ar1
|
||||
local has_cdecl = ar:match"__cdecl"
|
||||
if has_cdecl then ar = ar:gsub("__cdecl","") end
|
||||
@@ -802,6 +828,7 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local argsArr = argsTa2
|
||||
|
||||
--recreate argscsinpars, call_args and signature from argsArr
|
||||
@@ -833,7 +860,7 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
||||
caar = "()"
|
||||
signat = "()" .. (extraconst or "")
|
||||
end
|
||||
|
||||
--if ismanual then print("manual",asp, caar, signat) end
|
||||
------------------------------
|
||||
|
||||
if not ret and stname then --must be constructors
|
||||
@@ -866,6 +893,9 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
||||
ar.default = nil
|
||||
end
|
||||
end
|
||||
|
||||
--if ismanual then M.prtable(argsArr) end
|
||||
|
||||
defT.templated = self.typenames[stname] and true
|
||||
defT.namespace = namespace
|
||||
defT.cimguiname = cimguiname
|
||||
@@ -896,6 +926,7 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
||||
-- end
|
||||
end
|
||||
defsT[cimguiname][signat] = defT
|
||||
|
||||
end
|
||||
local function itemsCount(items)
|
||||
print"------------items"
|
||||
@@ -908,8 +939,8 @@ end
|
||||
|
||||
local function AdjustArguments(FP)
|
||||
for fun,defs in pairs(FP.defsT) do
|
||||
--struct function but no constructors or static functions
|
||||
if defs[1].stname~="" and defs[1].ret and not defs[1].is_static_function then
|
||||
--struct function but no constructors or static functions or manuals
|
||||
if defs[1].stname~="" and defs[1].ret and not defs[1].is_static_function and not defs[1].manual then
|
||||
--print("adjusting",fun)
|
||||
for i,def in ipairs(defs) do
|
||||
local empty = def.args:match("^%(%)") --no args
|
||||
@@ -920,6 +951,32 @@ local function AdjustArguments(FP)
|
||||
end
|
||||
end
|
||||
end
|
||||
local function REPLACE_TEXTUREID(FP)
|
||||
local defsT = FP.defsT
|
||||
for numcdef,t in ipairs(FP.funcdefs) do
|
||||
assert(t.cimguiname)
|
||||
local cimf = defsT[t.cimguiname]
|
||||
local defT = cimf[t.signature]
|
||||
local hasTextureID = false
|
||||
for i,arg in ipairs(defT.argsT) do
|
||||
if arg.type == "ImTextureID" then print(t.cimguiname,t.signature);hasTextureID = true; break end
|
||||
end
|
||||
if hasTextureID then
|
||||
for i,v in ipairs(defT.argsT) do
|
||||
v.type = (v.type == "ImTextureID") and "ImTextureUserID" or v.type
|
||||
end
|
||||
--defaults table
|
||||
for k,v in pairs(defT.defaults) do
|
||||
if v:match"ImTextureID" then
|
||||
error"default ImTextureID not implemented"
|
||||
end
|
||||
end
|
||||
defT.args = defT.args:gsub("ImTextureID","ImTextureUserID")
|
||||
defT.signature = defT.signature:gsub("ImTextureID","ImTextureUserID")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function ADDIMSTR_S(FP)
|
||||
local defsT = FP.defsT
|
||||
local newcdefs = {}
|
||||
@@ -1016,7 +1073,39 @@ local function ADDIMSTR_S(FP)
|
||||
end
|
||||
FP.funcdefs = newcdefs
|
||||
end
|
||||
--this creates defsBystruct in case you need to list by struct container
|
||||
local function DefsByStruct(FP)
|
||||
local structs = {}
|
||||
for fun,defs in pairs(FP.defsT) do
|
||||
local stname = defs[1].stname
|
||||
structs[stname] = structs[stname] or {}
|
||||
table.insert(structs[stname],defs)--fun)
|
||||
end
|
||||
return structs
|
||||
end
|
||||
local function get_nonPOD(FP)
|
||||
local defbystruct = DefsByStruct(FP)
|
||||
--M.prtable(defbystruct)
|
||||
local nonPOD = {}
|
||||
for k,defs in pairs(defbystruct) do
|
||||
if k~="" then
|
||||
for i, ww in ipairs(defs) do
|
||||
-- print(k,i,ww)
|
||||
-- M.prtable(ww)
|
||||
if not ww[1].ret then --constructor
|
||||
nonPOD[k] = true
|
||||
break;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
FP.structs_and_enums_table.nonPOD = nonPOD
|
||||
return nonPOD
|
||||
end
|
||||
local function ADDnonUDT(FP)
|
||||
local nonPOD = get_nonPOD(FP)
|
||||
--print"nonPOD"
|
||||
--M.prtable(nonPOD)
|
||||
local defsT = FP.defsT
|
||||
--local newcdefs = {}
|
||||
for numcdef,t in ipairs(FP.funcdefs) do
|
||||
@@ -1030,10 +1119,17 @@ local function ADDnonUDT(FP)
|
||||
end
|
||||
--if UDT return generate nonUDT version
|
||||
local isUDT = false
|
||||
for _,udt_ret in ipairs(FP.UDTs) do
|
||||
if udt_ret == defT.ret then isUDT=true;break end
|
||||
--isUDT = FP.structs_and_enums_table.structs[defT.ret] and true or false
|
||||
isUDT = nonPOD[defT.ret] and true or false
|
||||
--inherited
|
||||
if (not isUDT) and FP.cimgui_inherited and FP.cimgui_inherited.nonPOD[defT.ret] then
|
||||
isUDT = true
|
||||
end
|
||||
--if defT.ret=="ImVec2" or defT.ret=="ImVec4" or defT.ret=="ImColor" then
|
||||
for _,udt_ret in ipairs(FP.UDTs) do
|
||||
if udt_ret == defT.ret then isUDT=true; break end
|
||||
end
|
||||
|
||||
|
||||
if isUDT then
|
||||
--passing as a pointer arg
|
||||
local defT2 = {}
|
||||
@@ -1106,14 +1202,15 @@ local function ADDdestructors(FP)
|
||||
error"names should be equal"
|
||||
end
|
||||
local def = {}
|
||||
local isrealdestructor = keep_dest_locat[defT[1].stname] and true
|
||||
def.stname = defT[1].stname
|
||||
def.templated = defT[1].templated
|
||||
def.location = keep_dest_locat[defT[1].stname]
|
||||
def.location = keep_dest_locat[defT[1].stname] or defT[1].location
|
||||
def.ret = "void"
|
||||
def.ov_cimguiname = def.stname.."_destroy"
|
||||
def.cimguiname = def.ov_cimguiname
|
||||
def.destructor = true
|
||||
def.realdestructor = def.location and true
|
||||
def.realdestructor = isrealdestructor
|
||||
def.args = "("..def.stname.."* self)"
|
||||
def.call_args = "(self)"
|
||||
def.signature = "("..def.stname.."*)"
|
||||
@@ -1173,6 +1270,7 @@ local function printItems(items)
|
||||
end
|
||||
end
|
||||
-------------
|
||||
local numerr = 0 --for popen error file
|
||||
function M.Parser()
|
||||
local par = {}
|
||||
local cdefs ={}
|
||||
@@ -1216,7 +1314,9 @@ function M.Parser()
|
||||
if self.COMMENTS_GENERATION then
|
||||
cmd_line = cmd_line .. (compiler=="cl" and " /C " or " -C ")
|
||||
end
|
||||
local pipe,err = io.popen(cmd_line,"r")
|
||||
numerr = numerr + 1
|
||||
local errfile = "err"..numerr..".txt"
|
||||
local pipe,err = io.popen(cmd_line.." 2>"..errfile,"r")
|
||||
if not pipe then
|
||||
error("could not execute COMPILER "..err)
|
||||
end
|
||||
@@ -1226,8 +1326,18 @@ function M.Parser()
|
||||
self:insert(line, tostring(loca)..":"..tostring(loca2))
|
||||
table.insert(preprocessed,line)--
|
||||
end
|
||||
save_data("preprocesed.h",table.concat(preprocessed,"\n"))
|
||||
pipe:close()
|
||||
--print(#preprocessed, "lines processed")
|
||||
save_data("preprocesed.h",table.concat(preprocessed,"\n"))
|
||||
|
||||
local f = assert(io.open(errfile,"r"))
|
||||
local errstr = f:read"*a"
|
||||
f:close()
|
||||
--print(#errstr,"errstr")
|
||||
print(errstr)
|
||||
--try to guess a compiler error
|
||||
assert(not errstr:match" error")
|
||||
os.remove(errfile)
|
||||
return defines
|
||||
end
|
||||
function par:do_parse()
|
||||
@@ -1265,7 +1375,7 @@ function M.Parser()
|
||||
self.typedefs_dict[key] = linet
|
||||
elseif not line:match"typedef%s*struct" then --discard typedef struct
|
||||
print("typedef not found")
|
||||
print(key,value,line)
|
||||
print(key,value,line,cdef[1],cdef[2])
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1285,6 +1395,15 @@ function M.Parser()
|
||||
function par:parseItemsR2(txt, itparent)
|
||||
local itsarr,its = parseItems(txt,self.linenumdict,itparent)
|
||||
for i,it in ipairs(itsarr) do
|
||||
--clean class
|
||||
if it.re_name == "class_re" then
|
||||
it.name = it.item:match("class%s+(%S+)")
|
||||
print("cleaning class",it.name)
|
||||
it.item = it.item:gsub("private:.+};$","};")
|
||||
--it.item = it.item:gsub("private:","")
|
||||
it.item = it.item:gsub("public:","")
|
||||
it.item = it.item:gsub("enum%s*class","enum")
|
||||
end
|
||||
if not isLeaf(it.re_name) then
|
||||
local inner = strip_end(it.item:match("%b{}"):sub(2,-2))
|
||||
it.childs = par:parseItemsR2(inner, it)
|
||||
@@ -1307,6 +1426,8 @@ function M.Parser()
|
||||
end
|
||||
elseif it.re_name == "namespace_re" then
|
||||
it.name = it.item:match("namespace%s+(%S+)")
|
||||
elseif it.re_name == "class_re" then
|
||||
--it.name = it.item:match("class%s+(%S+)")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1328,11 +1449,12 @@ function M.Parser()
|
||||
return table.concat(txtclean)
|
||||
end
|
||||
function par:parseItems()
|
||||
self:initTypedefsDict()
|
||||
--self:initTypedefsDict()
|
||||
|
||||
self.linenumdict = {}
|
||||
local cdefs2 = {}
|
||||
for i,cdef in ipairs(cdefs) do
|
||||
cdef[1] = cdef[1]:gsub("enum%s*class","enum") --clean class
|
||||
local cdef1 = clean_comments(cdef[1])
|
||||
if self.linenumdict[cdef1] then
|
||||
--print("linenumdict already defined for", cdef[1],type(self.linenumdict[cdef[1]]))
|
||||
@@ -1342,7 +1464,6 @@ function M.Parser()
|
||||
table.insert(self.linenumdict[cdef1],cdef[2])
|
||||
end
|
||||
else
|
||||
--print("nuevo linenumdict es",cdef[1],cdef[2])
|
||||
self.linenumdict[cdef1]=cdef[2]
|
||||
end
|
||||
table.insert(cdefs2,cdef[1])
|
||||
@@ -1354,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
|
||||
@@ -1387,12 +1510,27 @@ function M.Parser()
|
||||
--save_data("./preparse"..tostring(self):gsub("table: ","")..".c",txt)
|
||||
--]]
|
||||
self.itemsarr = par:parseItemsR2(txt)
|
||||
--save_data("./itemsarr.lua",ToStr(self.itemsarr))
|
||||
itemsarr = self.itemsarr
|
||||
end
|
||||
|
||||
function par:printItems()
|
||||
printItems(items)
|
||||
end
|
||||
function par:set_manuals(manuals, modulen, erase)
|
||||
erase = erase or {"CIMGUI_API"}
|
||||
local moddata = read_data("./"..modulen.."_template.h")
|
||||
for k,v in pairs(manuals) do
|
||||
local ret = moddata:match("([^%(%):,\n;]+[%*%s])%s?~?"..k.."%b()")
|
||||
for i,ww in ipairs(erase) do
|
||||
ret = ret:gsub(ww,"")
|
||||
end
|
||||
local args = moddata:match(k.."%s*(%b())")
|
||||
manuals[k] = {args = args, ret = ret}
|
||||
--print(k,args,ret)
|
||||
end
|
||||
self.manuals = manuals
|
||||
end
|
||||
par.parseFunction = parseFunction
|
||||
local uniques = {}
|
||||
local function check_unique_typedefs(l,uniques)
|
||||
@@ -1419,13 +1557,21 @@ function M.Parser()
|
||||
local predeclare = ""
|
||||
--local iner = strip_end(stru:match("%b{}"):sub(2,-2))
|
||||
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
|
||||
stname,derived = inistruct:match"struct%s*([^%s:]+):(.+)"
|
||||
--print(inistruct,stname,derived)
|
||||
derived = derived:match"(%S+)$"
|
||||
else
|
||||
stname = inistruct:match"struct%s(%S+)"
|
||||
if itst.re_name == "struct_re" then
|
||||
stname = inistruct:match"struct%s(%S+)"
|
||||
elseif itst.re_name == "class_re" then
|
||||
stname = inistruct:match"class%s(%S+)"
|
||||
end
|
||||
end
|
||||
|
||||
if derived then print(stname,"derived from",derived) end
|
||||
@@ -1435,6 +1581,7 @@ function M.Parser()
|
||||
stname = stru:match("%b{}%s*(%S+)%s*;")
|
||||
end
|
||||
|
||||
|
||||
local is_nested
|
||||
if not stname then
|
||||
is_nested = itst.parent and (itst.parent.re_name == "struct_re")
|
||||
@@ -1472,12 +1619,14 @@ function M.Parser()
|
||||
--local ttype,template = it.item:match("([^%s,%(%)]+)%s*<(.+)>")
|
||||
local ttype,template,te,code2 = check_template(it2) --it.item:match"([^%s,%(%)]+)%s*<(.+)>"
|
||||
if template then
|
||||
if self.typenames[ttype] ~= template then --rule out T (template typename)
|
||||
--print("not doheader",ttype,template,te, self.typenames[ttype])
|
||||
if self.typenames[ttype] ~= template and self.typenames[ttype].."*" ~= template then --rule out T (template typename)
|
||||
self.templates[ttype] = self.templates[ttype] or {}
|
||||
self.templates[ttype][template] = te
|
||||
it2=code2
|
||||
end
|
||||
if doheader then
|
||||
|
||||
local templatetypedef = self:gentemplatetypedef(ttype, template,self.templates[ttype][template])
|
||||
predeclare = predeclare .. templatetypedef
|
||||
end
|
||||
@@ -1533,7 +1682,7 @@ function M.Parser()
|
||||
end
|
||||
elseif it.re_name == "enum_re" then
|
||||
--nop
|
||||
elseif it.re_name ~= "functionD_re" and it.re_name ~= "function_re" then
|
||||
elseif it.re_name ~= "functionD_re" and it.re_name ~= "function_re" and it.re_name ~= "operator_re" then
|
||||
print(it.re_name,"not processed clean_struct in",stname,it.item:sub(1,24))
|
||||
--M.prtable(it)
|
||||
end
|
||||
@@ -1562,8 +1711,9 @@ function M.Parser()
|
||||
if parnam~="" then parnam = parnam:sub(1,-3) end
|
||||
return parnam
|
||||
end
|
||||
|
||||
|
||||
function par:header_text_insert(tab,txt,it)
|
||||
table.insert(tab, txt)
|
||||
end
|
||||
function par:gen_structs_and_enums()
|
||||
print"--------------gen_structs_and_enums"
|
||||
--M.prtable(self.typenames)
|
||||
@@ -1591,25 +1741,31 @@ function M.Parser()
|
||||
|
||||
local tdt = self:gentemplatetypedef(ttype,template,te)
|
||||
it2 = tdt..code2
|
||||
elseif it2:match"%w+::" then
|
||||
print("clean namespace typedef",it2)
|
||||
it2 = it2:gsub("%w+::","")
|
||||
end
|
||||
elseif it.re_name == "functypedef_re" then
|
||||
it2 = clean_functypedef(it2)
|
||||
else
|
||||
assert(it.re_name == "vardef_re")
|
||||
it2 = it2:gsub("constexpr","static const")
|
||||
if it2:match"enum" then
|
||||
print("--skip enum forward declaration:",it2)
|
||||
it2 = ""
|
||||
end
|
||||
end
|
||||
--table.insert(outtabpre,it2)
|
||||
table.insert(outtab,it2)
|
||||
--table.insert(outtab,it2)
|
||||
self:header_text_insert(outtab, it2, it)
|
||||
-- add typedef after struct name
|
||||
if it.re_name == "vardef_re" and it.item:match"^%s*struct" then
|
||||
local stname = it.item:match("struct%s*(%S+)%s*;")
|
||||
--table.insert(typedefs_table,"typedef struct "..stname.." "..stname..";\n")
|
||||
local tst = "\ntypedef struct "..stname.." "..stname..";"
|
||||
if check_unique_typedefs(tst,uniques) then
|
||||
table.insert(outtabpre,tst)
|
||||
--table.insert(outtabpre,tst)
|
||||
self:header_text_insert(outtabpre ,tst, it)
|
||||
end
|
||||
self.typedefs_dict[stname]="struct "..stname
|
||||
if it.parent then --must be struct name; inside namespace
|
||||
@@ -1635,24 +1791,31 @@ function M.Parser()
|
||||
end
|
||||
end
|
||||
enumbody = "{"..enumbody.."\n}"
|
||||
table.insert(outtab,"\ntypedef enum ".. enumbody..enumname..";"..extraenums)
|
||||
--table.insert(outtab,"\ntypedef enum ".. enumbody..enumname..";"..extraenums)
|
||||
local it2 = "\ntypedef enum ".. enumbody..enumname..";"..extraenums
|
||||
self:header_text_insert(outtab, it2, it)
|
||||
else
|
||||
local enumbody = it.item:match"(%b{})"
|
||||
enumbody = clean_comments(enumbody)
|
||||
table.insert(outtab,"\ntypedef enum ".. enumbody..enumname..";")
|
||||
--table.insert(outtab,"\ntypedef enum ".. enumbody..enumname..";")
|
||||
local it2 = "\ntypedef enum ".. enumbody..enumname..";"
|
||||
self:header_text_insert(outtab, it2, it)
|
||||
end
|
||||
if it.parent then
|
||||
if it.parent.re_name == "namespace_re" then
|
||||
local namespace = it.parent.item:match("namespace%s+(%S+)")
|
||||
self.embeded_enums[enumname] = namespace.."::"..enumname
|
||||
else
|
||||
self.embeded_enums[enumname] = it.parent.name.."::"..enumname
|
||||
end
|
||||
end
|
||||
else --unamed enum just repeat declaration
|
||||
local cl_item = clean_comments(it.item)
|
||||
table.insert(outtab,cl_item)
|
||||
--table.insert(outtab,cl_item)
|
||||
self:header_text_insert(outtab, cl_item, it)
|
||||
print("unnamed enum",cl_item)
|
||||
end
|
||||
elseif it.re_name == "struct_re" or it.re_name == "typedef_st_re" then
|
||||
elseif it.re_name == "struct_re" or it.re_name == "typedef_st_re" or it.re_name == "class_re" then
|
||||
local cleanst,structname,strtab,comstab,predec = self:clean_structR1(it,true)
|
||||
if not structname then print("NO NAME",cleanst,it.item) end
|
||||
--if not void stname or templated
|
||||
@@ -1661,12 +1824,14 @@ function M.Parser()
|
||||
--table.insert(typedefs_table,"typedef struct "..structname.." "..structname..";\n")
|
||||
local tst = "\ntypedef struct "..structname.." "..structname..";"
|
||||
if check_unique_typedefs(tst,uniques) then
|
||||
table.insert(outtab,tst)
|
||||
--table.insert(outtab,tst)
|
||||
self:header_text_insert(outtab, tst, it)
|
||||
end
|
||||
self.typedefs_dict[structname]="struct "..structname
|
||||
--dont insert child structs as they are inserted before parent struct
|
||||
if not (it.parent and it.parent.re_name == "struct_re") then
|
||||
table.insert(outtab,predec .. cleanst)
|
||||
--table.insert(outtab,predec .. cleanst)
|
||||
self:header_text_insert(outtab, predec .. cleanst, it)
|
||||
end
|
||||
end
|
||||
if it.parent then --and (it.parent.re_name == "struct_re" or it.parent.re_name == "typedef_st_re" then
|
||||
@@ -1689,7 +1854,7 @@ function M.Parser()
|
||||
local stname = ""
|
||||
local namespace
|
||||
if it.parent then
|
||||
if it.parent.re_name == "struct_re" or it.parent.re_name == "typedef_st_re" 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
|
||||
@@ -1699,7 +1864,9 @@ function M.Parser()
|
||||
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,vT)
|
||||
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
|
||||
@@ -1707,7 +1874,9 @@ function M.Parser()
|
||||
self:parseFunction(stname,it,namespace,it.locat)
|
||||
end
|
||||
else
|
||||
if it.re_name~="operator_re" then
|
||||
print("not processed gen",it.re_name,it.item:sub(1,20))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1775,7 +1944,8 @@ function M.Parser()
|
||||
end
|
||||
local unnamed_enum_counter = 0
|
||||
local function enums_for_table(it, outtab, enumsordered)
|
||||
local enumname = it.item:match"^%s*enum%s+([^%s;{}]+)"
|
||||
--local enumname = it.item:match"^%s*enum%s+([^%s;{}]+)"
|
||||
local enumname = it.item:match"^[^;{}]-enum%s+([^%s;{}]+)"
|
||||
if not enumname then
|
||||
unnamed_enum_counter = unnamed_enum_counter + 1
|
||||
enumname = "unnamed"..unnamed_enum_counter
|
||||
@@ -1838,7 +2008,7 @@ function M.Parser()
|
||||
function par:gen_structs_and_enums_table()
|
||||
print"--------------gen_structs_and_enums_table"
|
||||
local outtab = {enums={},structs={},locations={},enumtypes={},struct_comments={},enum_comments={}}
|
||||
self.typedefs_table = {}
|
||||
--self.typedefs_table = {}
|
||||
local enumsordered = {}
|
||||
unnamed_enum_counter = 0
|
||||
self.templated_structs = {}
|
||||
@@ -1861,11 +2031,35 @@ function M.Parser()
|
||||
if it.re_name == "typedef_re" and not it.parent then
|
||||
local typedefdef,typedefname = it.item:match"typedef(.+)%s([^%s;]+);$"
|
||||
typedefname = strip(typedefname)
|
||||
self.typedefs_table[typedefname] = strip(typedefdef)
|
||||
--self.typedefs_table[typedefname] = strip(typedefdef)
|
||||
self.typedefs_dict[typedefname] = strip(typedefdef)
|
||||
elseif it.re_name == "functypedef_re" then
|
||||
-- "^\n*%s*(typedef[%w%s%*_]+%([^*]*%*?%s*[%w_]+%s*%)%s*%b()%s*;)"
|
||||
local key = it.item:match("%(%*%s*([%w_]+)%)%s*%([^%(%)]*%)")
|
||||
if key then
|
||||
local linet = it.item
|
||||
linet = linet:gsub("[\n%s]+typedef ","")
|
||||
linet = linet:gsub("%(%*("..key..")%)","(*)")
|
||||
self.typedefs_dict[key] = linet
|
||||
--print("functypedef_re",1,linet)--,clean_functypedef(line))
|
||||
else
|
||||
--try function typedef
|
||||
key = it.item:match("%(([%w_]+)%)%([^%(%)]*%)")
|
||||
if key then
|
||||
local linet = it.item
|
||||
linet = linet:gsub("typedef ","")
|
||||
linet = linet:gsub("%(("..key..")%)","()")
|
||||
self.typedefs_dict[key] = linet
|
||||
print("functypedef_re",2, it.item)
|
||||
else
|
||||
print("func typedef not found")
|
||||
print(it.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif it.re_name == "enum_re" then
|
||||
enums_for_table(it, outtab, enumsordered)
|
||||
elseif it.re_name == "struct_re" or it.re_name == "typedef_st_re" then
|
||||
elseif it.re_name == "struct_re" or it.re_name == "typedef_st_re" or it.re_name == "class_re" then
|
||||
local cleanst,structname,strtab,comstab = self:clean_structR1(it)
|
||||
--if not void stname or templated
|
||||
if not structname then print("NO NAME",cleanst,it.item) end
|
||||
@@ -1892,7 +2086,7 @@ 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" then
|
||||
elseif it.re_name ~= "functionD_re" and it.re_name ~= "function_re" and it.re_name ~= "operator_re" then
|
||||
print("not processed gen table",it.re_name)
|
||||
end
|
||||
end
|
||||
@@ -1964,7 +2158,13 @@ function M.Parser()
|
||||
function par:dump_alltypes()
|
||||
for k,v in pairs(self.alltypes) do print(k, typetoStr(k) ) end
|
||||
end
|
||||
|
||||
function par:compute_overloads()
|
||||
-- if self.IMGUI_HAS_TEXTURES then
|
||||
-- print"----------replacing ImTextureID with ImTextureUserID"
|
||||
-- REPLACE_TEXTUREID(self)
|
||||
-- print"----------end replacing ImTextureID with ImTextureUserID"
|
||||
-- end
|
||||
ADDIMSTR_S(self)
|
||||
local strt = {}
|
||||
local numoverloaded = 0
|
||||
@@ -2137,6 +2337,7 @@ function M.Parser()
|
||||
return self:gen_template_typedef_auto(ttype,te,newte)
|
||||
end
|
||||
function par:gen_template_typedef_auto(ttype,te,newte)
|
||||
--M.prtable(self.templated_structs)
|
||||
assert(self.templated_structs[ttype],ttype)
|
||||
local defi = self.templated_structs[ttype]
|
||||
local Targ = strsplit(self.typenames[ttype],",")
|
||||
@@ -2180,7 +2381,111 @@ function M.Parser()
|
||||
end
|
||||
return par
|
||||
end
|
||||
-- more compact serialization
|
||||
local function basicSerialize (o)
|
||||
if type(o) == "number" then
|
||||
return string.format("%.17g", o)
|
||||
elseif type(o)=="boolean" then
|
||||
return tostring(o)
|
||||
elseif type(o) == "string" then
|
||||
return string.format("%q", o)
|
||||
elseif pcall(function() return o.__serialize end) then
|
||||
return o.__serialize(o)
|
||||
elseif type(o)=="cdata" then
|
||||
return cdataSerialize(o)
|
||||
else
|
||||
return tostring(o) --"nil"
|
||||
end
|
||||
end
|
||||
-- very readable and now suited for cyclic tables
|
||||
local kw = {['and'] = true, ['break'] = true, ['do'] = true, ['else'] = true,
|
||||
['elseif'] = true, ['end'] = true, ['false'] = true, ['for'] = true,
|
||||
['function'] = true, ['goto'] = true, ['if'] = true, ['in'] = true,
|
||||
['local'] = true, ['nil'] = true, ['not'] = true, ['or'] = true,
|
||||
['repeat'] = true, ['return'] = true, ['then'] = true, ['true'] = true,
|
||||
['until'] = true, ['while'] = true}
|
||||
function tb2st_serialize(t,options)
|
||||
options = options or {}
|
||||
local function sorter(a,b)
|
||||
if type(a)==type(b) then
|
||||
return a<b
|
||||
elseif type(a)=="number" then
|
||||
return true
|
||||
else
|
||||
assert(type(b)=="number")
|
||||
return false
|
||||
end
|
||||
end
|
||||
local function serialize_key(val, dodot, pretty)
|
||||
local dot = dodot and "." or ""
|
||||
if type(val)=="string" then
|
||||
if val:match '^[_%a][_%w]*$' and not kw[val] then
|
||||
return dot..tostring(val)
|
||||
else
|
||||
return "[\""..tostring(val).."\"]"
|
||||
end
|
||||
elseif (not pretty) and (not dodot) and (type(val) == "number") and (math.floor(val)==val) then
|
||||
return --array index
|
||||
else
|
||||
return "["..tostring(val).."]"
|
||||
end
|
||||
end
|
||||
local function serialize_key_name(val)
|
||||
return serialize_key(val, true)
|
||||
end
|
||||
local insert = table.insert
|
||||
local function _tb2st(t,saved,sref,level,name)
|
||||
saved = saved or {} -- initial value
|
||||
level = level or 0
|
||||
sref = sref or {}
|
||||
name = name or "t"
|
||||
if type(t)=="table" then
|
||||
if saved[t] then
|
||||
sref[#sref+1] = {saved[t],name}
|
||||
return"nil"
|
||||
else
|
||||
saved[t] = name
|
||||
|
||||
local ordered_keys = {}
|
||||
for k,v in pairs(t) do
|
||||
insert(ordered_keys,k)
|
||||
end
|
||||
table.sort(ordered_keys,sorter)
|
||||
|
||||
local str2 = {}
|
||||
insert(str2,"{")
|
||||
if options.pretty then insert(str2,"\n") end
|
||||
for _,k in ipairs(ordered_keys) do
|
||||
if options.pretty then insert(str2,(" "):rep(level+1)) end
|
||||
local v = t[k]
|
||||
local kser = serialize_key(k, nil, options.pretty)
|
||||
insert(str2, (kser and (kser .."=") or ""))
|
||||
if type(v)~="table" then
|
||||
insert(str2, basicSerialize(v))
|
||||
else
|
||||
local name2 = name .. serialize_key_name(k)
|
||||
insert(str2,_tb2st(v,saved,sref,level+1,name2))
|
||||
end
|
||||
if options.pretty then insert(str2,",\n") else insert(str2, ",") end
|
||||
end
|
||||
str2[#str2] = "}"
|
||||
if level == 0 then
|
||||
--insert(str2, 1,"local ffi = require'ffi'\nlocal t=")
|
||||
insert(str2, 1,"local t=")
|
||||
for i,v in ipairs(sref) do
|
||||
insert(str2, "\n"..v[2].."="..v[1])
|
||||
end
|
||||
insert(str2,"\n return t")
|
||||
end
|
||||
return table.concat(str2)
|
||||
end
|
||||
else
|
||||
return basicSerialize(t)
|
||||
end
|
||||
end
|
||||
return(_tb2st(t))
|
||||
end
|
||||
M.tb2st_serialize = tb2st_serialize
|
||||
------serializeTable("anyname",table) gives a string that recreates the table with dofile(generated_string)
|
||||
local function serializeTable(name, value, saved)
|
||||
|
||||
@@ -2242,10 +2547,11 @@ local function serializeTable(name, value, saved)
|
||||
|
||||
return table.concat(string_table)
|
||||
end
|
||||
M.serializeTable = serializeTable
|
||||
M.serializeTableF = function(t)
|
||||
return M.serializeTable("defs",t).."\nreturn defs"
|
||||
end
|
||||
-- M.serializeTable = serializeTable
|
||||
-- M.serializeTableF = function(t)
|
||||
-- return M.serializeTable("defs",t).."\nreturn defs"
|
||||
-- end
|
||||
M.serializeTableF = function(t) return tb2st_serialize(t,{pretty=true}) end --new serialization more compact
|
||||
--iterates lines from a gcc/clang -E in a specific location
|
||||
local function location(file,locpathT,defines,COMPILER,keepemptylines)
|
||||
local define_re = "^#define%s+([^%s]+)%s+(.+)$"
|
||||
@@ -2332,7 +2638,23 @@ local function location(file,locpathT,defines,COMPILER,keepemptylines)
|
||||
end
|
||||
M.location = location
|
||||
---------------------- C writing functions
|
||||
local function ImGui_f_implementation(outtab,def)
|
||||
local function paramListWithoutDots(params)
|
||||
i, j = string.find(params, "%.%.%.")
|
||||
while i > 1 do
|
||||
i = i - 1
|
||||
c = string.sub(params,i,i)
|
||||
if c == "," then
|
||||
return string.sub(params, 1, i-1) .. params:sub(j+1)
|
||||
elseif c == "(" then
|
||||
return string.sub(params, 1, i) .. params:sub(j+1)
|
||||
end
|
||||
end
|
||||
|
||||
error("paramListWithoutDots failed")
|
||||
return "()"
|
||||
end
|
||||
local function ImGui_f_implementation(def)
|
||||
local outtab = {}
|
||||
local ptret = def.retref and "&" or ""
|
||||
table.insert(outtab,"CIMGUI_API".." "..def.ret.." "..def.ov_cimguiname..def.args.."\n")
|
||||
table.insert(outtab,"{\n")
|
||||
@@ -2351,16 +2673,28 @@ local function ImGui_f_implementation(outtab,def)
|
||||
if def.ret~="void" then
|
||||
table.insert(outtab," return ret;\n")
|
||||
end
|
||||
table.insert(outtab,"}\n")
|
||||
-- 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, "{\n")
|
||||
table.insert(outtab, " return "..def.ov_cimguiname..paramListWithoutDots(def.call_args)..";\n")
|
||||
table.insert(outtab, "}\n")
|
||||
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")
|
||||
end
|
||||
table.insert(outtab,"}\n")
|
||||
else --standard ImGui
|
||||
table.insert(outtab," return "..ptret..namespace..def.funcname..def.call_args..";\n")
|
||||
table.insert(outtab,"}\n")
|
||||
end
|
||||
table.insert(outtab,"}\n")
|
||||
--table.insert(outtab,"}\n")
|
||||
return table.concat(outtab, "")
|
||||
end
|
||||
local function struct_f_implementation(outtab,def)
|
||||
local function struct_f_implementation(def)
|
||||
local outtab = {}
|
||||
local empty = def.args:match("^%(%)") --no args
|
||||
local ptret = def.retref and "&" or ""
|
||||
|
||||
@@ -2389,6 +2723,7 @@ local function struct_f_implementation(outtab,def)
|
||||
table.insert(outtab," return "..ptret.."self->"..def.funcname..def.call_args..";\n")
|
||||
end
|
||||
table.insert(outtab,"}\n")
|
||||
return table.concat(outtab, "")
|
||||
end
|
||||
local function func_implementation(FP)
|
||||
|
||||
@@ -2406,25 +2741,38 @@ local function func_implementation(FP)
|
||||
local manual = FP.get_manuals(def)
|
||||
if not custom and not manual and not def.templated and not FP.get_skipped(def) then
|
||||
if def.constructor then
|
||||
local tab = {}
|
||||
assert(def.stname ~= "","constructor without struct")
|
||||
local empty = def.args:match("^%(%)") --no args
|
||||
table.insert(outtab,"CIMGUI_API "..def.stname.."* "..def.ov_cimguiname..(empty and "(void)" or def.args).."\n")
|
||||
table.insert(outtab,"{\n")
|
||||
table.insert(outtab," return IM_NEW("..def.stname..")"..def.call_args..";\n")
|
||||
table.insert(outtab,"}\n")
|
||||
table.insert(tab,"CIMGUI_API "..def.stname.."* "..def.ov_cimguiname..(empty and "(void)" or def.args).."\n")
|
||||
table.insert(tab,"{\n")
|
||||
table.insert(tab," return IM_NEW("..def.stname..")"..def.call_args..";\n")
|
||||
table.insert(tab,"}\n")
|
||||
if FP.CONSTRUCTORS_GENERATION then
|
||||
table.insert(tab,"CIMGUI_API void "..def.ov_cimguiname.."_Construct("..def.stname.."* self"..(empty and "" or ","..def.args:sub(2,-2))..")\n")
|
||||
table.insert(tab,"{\n")
|
||||
table.insert(tab," IM_PLACEMENT_NEW(self)"..def.stname..def.call_args..";\n")
|
||||
table.insert(tab,"}\n")
|
||||
end
|
||||
table.insert(outtab, table.concat(tab, ""))
|
||||
elseif def.destructor then
|
||||
local tab = {}
|
||||
local args = "("..def.stname.."* self)"
|
||||
local fname = def.stname.."_destroy"
|
||||
table.insert(outtab,"CIMGUI_API void "..fname..args.."\n")
|
||||
table.insert(outtab,"{\n")
|
||||
table.insert(outtab," IM_DELETE(self);\n")
|
||||
table.insert(outtab,"}\n")
|
||||
table.insert(tab,"CIMGUI_API void "..fname..args.."\n")
|
||||
table.insert(tab,"{\n")
|
||||
table.insert(tab," IM_DELETE(self);\n")
|
||||
table.insert(tab,"}\n")
|
||||
table.insert(outtab, table.concat(tab, ""))
|
||||
elseif def.stname == "" or def.is_static_function then
|
||||
ImGui_f_implementation(outtab,def)
|
||||
table.insert(outtab, ImGui_f_implementation(def))
|
||||
else -- stname
|
||||
struct_f_implementation(outtab,def)
|
||||
table.insert(outtab, struct_f_implementation(def))
|
||||
end
|
||||
end
|
||||
if FP.custom_function_post then
|
||||
FP:custom_function_post(outtab, def)
|
||||
end
|
||||
until true
|
||||
end
|
||||
return table.concat(outtab)
|
||||
@@ -2447,13 +2795,16 @@ local function func_header_generate_structs(FP)
|
||||
|
||||
local outtab = {}
|
||||
|
||||
table_do_sorted(FP.embeded_structs,function(k,v) table.insert(outtab,"typedef "..v.." "..k..";\n") end)
|
||||
table_do_sorted(FP.embeded_structs,function(k,v)
|
||||
table.insert(outtab,"typedef "..v.." "..k..";\n")
|
||||
end)
|
||||
|
||||
table_do_sorted(FP.embeded_enums,function(k,v) table.insert(outtab,"typedef "..v.." "..k..";\n") end)
|
||||
|
||||
table_do_sorted(FP.templates,function(ttype,v)
|
||||
table_do_sorted(v,function(ttypein,te)
|
||||
table.insert(outtab,"typedef "..ttype.."<"..ttypein.."> "..ttype.."_"..te..";\n")
|
||||
local ttype2 = ttype:gsub("::","_") --std::string
|
||||
table.insert(outtab,"typedef "..ttype.."<"..ttypein.."> "..ttype2.."_"..te..";\n")
|
||||
end)
|
||||
end)
|
||||
return outtab
|
||||
@@ -2482,20 +2833,33 @@ local function func_header_generate_funcs(FP)
|
||||
if def.constructor then
|
||||
assert(def.stname ~= "","constructor without struct")
|
||||
table.insert(outtab,"CIMGUI_API "..def.stname.."* "..def.ov_cimguiname ..(empty and "(void)" or def.args)..";"..addcoment.."\n")
|
||||
if FP.CONSTRUCTORS_GENERATION then
|
||||
outtab[#outtab] = outtab[#outtab].."\nCIMGUI_API void "..def.ov_cimguiname.."_Construct("..def.stname.."* self"..(empty and "" or ","..def.args:sub(2,-2))..");\n"
|
||||
end
|
||||
elseif def.destructor then
|
||||
table.insert(outtab,"CIMGUI_API void "..def.ov_cimguiname..def.args..";"..addcoment.."\n")
|
||||
else --not constructor
|
||||
|
||||
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")
|
||||
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, "#endif\n")
|
||||
end
|
||||
else
|
||||
table.insert(outtab,"CIMGUI_API "..def.ret.." "..def.ov_cimguiname..def.args..";"..addcoment.."\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
if FP.custom_function_post then
|
||||
FP:custom_function_post(outtab, def)
|
||||
end
|
||||
else --not cimguiname
|
||||
table.insert(outtab,t.comment:gsub("%%","%%%%").."\n")-- %% substitution for gsub
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return outtab
|
||||
|
@@ -15,10 +15,12 @@ set PATH=%PATH%;C:\anima;C:\mingws\i686-7.2.0-release-posix-dwarf-rt_v5-rev1\min
|
||||
:: set PATH=%PATH%;C:\luaGL\sources\luajit-master\luajit-master\bin\mingw32;C:\mingw32\bin;
|
||||
::process files
|
||||
:: arg[1] compiler name gcc, clang or cl
|
||||
:: arg[2] options as words in one string: internal for imgui_internal generation, freetype for freetype generation, comments for comments generation, nochar to skip char* function version, noimstrv to skip imstrv
|
||||
:: examples: "" "internal" "internal freetype comments"
|
||||
:: arg[3..n] name of implementations to generate and/or CFLAGS (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32)
|
||||
luajit ./generator.lua gcc "internal noimstrv" glfw opengl3 opengl2 sdl2 %*
|
||||
:: arg[2] options as words in one string: internal for imgui_internal generation, comments for comments generation, nochar to skip char* function version, noimstrv to skip imstrv
|
||||
:: "constructors" adds the _Construct version of constructors
|
||||
:: examples: "" "internal" "internal comments"
|
||||
:: arg[3..n] name of implementations to generate and/or CFLAGS (e.g. -DIMGUI_USER_CONFIG)
|
||||
::-DIMGUI_USE_WCHAR32 should not be used (is discarded)
|
||||
luajit ./generator.lua gcc "internal noimstrv" glfw opengl3 opengl2 sdl2 sdl3 vulkan %*
|
||||
|
||||
::leave console open
|
||||
cmd /k
|
||||
|
@@ -7,17 +7,22 @@ assert(bit,"Must use LuaJIT")
|
||||
local script_args = {...}
|
||||
local COMPILER = script_args[1]
|
||||
local INTERNAL_GENERATION = script_args[2]:match("internal") and true or false
|
||||
local FREETYPE_GENERATION = script_args[2]:match("freetype") and true or false
|
||||
local FREETYPE_GENERATION = true --script_args[2]:match("freetype") and true or false
|
||||
local COMMENTS_GENERATION = script_args[2]:match("comments") and true or false
|
||||
local CONSTRUCTORS_GENERATION = script_args[2]:match("constructors") and true or false
|
||||
local NOCHAR = script_args[2]:match("nochar") and true or false
|
||||
local NOIMSTRV = script_args[2]:match("noimstrv") and true or false
|
||||
local IMGUI_PATH = os.getenv"IMGUI_PATH" or "../imgui"
|
||||
local CONFIG_GENERATOR_PATH = os.getenv"CONFIG_GENERATOR_PATH" or "./config_generator.lua"
|
||||
local CFLAGS = ""
|
||||
local CPRE,CTEST
|
||||
--get implementations
|
||||
local implementations = {}
|
||||
for i=3,#script_args do
|
||||
if script_args[i]:match(COMPILER == "cl" and "^/" or "^%-") then
|
||||
if script_args[i]:match("IMGUI_USE_WCHAR32") then
|
||||
script_args[i] = "" --dont use this define
|
||||
end
|
||||
local key, value = script_args[i]:match("^(.+)=(.+)$")
|
||||
if key and value then
|
||||
CFLAGS = CFLAGS .. " " .. key .. "=\"" .. value:gsub("\"", "\\\"") .. "\"";
|
||||
@@ -30,11 +35,11 @@ for i=3,#script_args do
|
||||
end
|
||||
|
||||
if FREETYPE_GENERATION then
|
||||
CFLAGS = CFLAGS .. " -DIMGUI_ENABLE_FREETYPE "
|
||||
CFLAGS = CFLAGS .. " -DIMGUI_ENABLE_FREETYPE -DIMGUI_ENABLE_STB_TRUETYPE" --both builders
|
||||
end
|
||||
|
||||
if COMPILER == "gcc" or COMPILER == "clang" or COMPILER == "zig cc" then
|
||||
CPRE = COMPILER..[[ -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ]] .. CFLAGS
|
||||
CPRE = COMPILER..[[ -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ]] .. CFLAGS
|
||||
CTEST = COMPILER.." --version"
|
||||
elseif COMPILER == "cl" then
|
||||
CPRE = COMPILER..[[ /E /DIMGUI_DISABLE_OBSOLETE_FUNCTIONS /DIMGUI_DEBUG_PARANOID /DIMGUI_API="" /DIMGUI_IMPL_API="" ]] .. CFLAGS
|
||||
@@ -67,12 +72,13 @@ print("HAVE_COMPILER",HAVE_COMPILER)
|
||||
print("INTERNAL_GENERATION",INTERNAL_GENERATION)
|
||||
print("FREETYPE_GENERATION",FREETYPE_GENERATION)
|
||||
print("COMMENTS_GENERATION",COMMENTS_GENERATION)
|
||||
print("CONSTRUCTORS_GENERATION",CONSTRUCTORS_GENERATION)
|
||||
print("CPRE",CPRE)
|
||||
--------------------------------------------------------------------------
|
||||
--this table has the functions to be skipped in generation
|
||||
--------------------------------------------------------------------------
|
||||
local cimgui_manuals = {
|
||||
igLogText = true,
|
||||
-- igLogText = true,
|
||||
ImGuiTextBuffer_appendf = true,
|
||||
--igColorConvertRGBtoHSV = true,
|
||||
--igColorConvertHSVtoRGB = true
|
||||
@@ -86,6 +92,10 @@ local cimgui_skipped = {
|
||||
--desired name
|
||||
---------------------------------------------------------------------------
|
||||
local cimgui_overloads = {
|
||||
-- igGetIO = {
|
||||
-- ["()"] = "igGetIO",
|
||||
-- ["(ImGuiContext*)"] = "igGetIOEx",
|
||||
-- },
|
||||
--igPushID = {
|
||||
--["(const char*)"] = "igPushIDStr",
|
||||
--["(const char*,const char*)"] = "igPushIDRange",
|
||||
@@ -119,16 +129,18 @@ local function func_header_impl_generate(FP)
|
||||
local cimf = FP.defsT[t.cimguiname]
|
||||
local def = cimf[t.signature]
|
||||
local addcoment = def.comment or ""
|
||||
local empty = def.args:match("^%(%)") --no args
|
||||
if def.constructor then
|
||||
-- it happens with vulkan impl but constructor ImGui_ImplVulkanH_Window is not needed
|
||||
--assert(def.stname ~= "","constructor without struct")
|
||||
--table.insert(outtab,"CIMGUI_API "..def.stname.."* "..def.ov_cimguiname ..(empty and "(void)" or --def.args)..";"..addcoment.."\n")
|
||||
-- only vulkan is manually created
|
||||
assert(def.ov_cimguiname=="ImGui_ImplVulkanH_Window_ImGui_ImplVulkanH_Window" or
|
||||
def.ov_cimguiname=="ImGui_ImplVulkanH_Window_Construct", "not cpp for "..def.ov_cimguiname)
|
||||
assert(def.stname ~= "","constructor without struct")
|
||||
table.insert(outtab,"CIMGUI_API "..def.stname.."* "..def.ov_cimguiname ..(empty and "(void)" or def.args)..";"..addcoment.."\n")
|
||||
elseif def.destructor then
|
||||
--table.insert(outtab,"CIMGUI_API void "..def.ov_cimguiname..def.args..";"..addcoment.."\n")
|
||||
else
|
||||
|
||||
if def.stname == "" then --ImGui namespace or top level
|
||||
local empty = def.args:match("^%(%)") --no args
|
||||
table.insert(outtab,"CIMGUI_API".." "..def.ret.." "..def.ov_cimguiname..(empty and "(void)" or def.args)..";"..addcoment.."\n")
|
||||
else
|
||||
cpp2ffi.prtable(def)
|
||||
@@ -212,6 +224,27 @@ local function DefsByStruct(FP)
|
||||
FP.defsBystruct = structs
|
||||
end
|
||||
|
||||
local function colapse_defines(str, define)
|
||||
local num = 1
|
||||
while num > 0 do
|
||||
str,num = str:gsub("(#ifdef "..define..".+)".."(#endif\n+#ifdef "..define.."\n)", "%1")
|
||||
end
|
||||
return str
|
||||
end
|
||||
local wchardefine =
|
||||
[[
|
||||
|
||||
#ifdef IMGUI_USE_WCHAR32
|
||||
typedef ImWchar32 ImWchar;
|
||||
#else
|
||||
typedef ImWchar16 ImWchar;
|
||||
#endif
|
||||
#ifdef IMGUI_USE_WCHAR32
|
||||
#define IM_UNICODE_CODEPOINT_MAX 0x10FFFF
|
||||
#else
|
||||
#define IM_UNICODE_CODEPOINT_MAX 0xFFFF
|
||||
#endif
|
||||
]]
|
||||
|
||||
--generate cimgui.cpp cimgui.h
|
||||
local function cimgui_generation(parser)
|
||||
@@ -259,18 +292,27 @@ local function cimgui_generation(parser)
|
||||
end
|
||||
end
|
||||
|
||||
cstructsstr = colapse_defines(cstructsstr, "IMGUI_ENABLE_FREETYPE")
|
||||
|
||||
hstrfile = hstrfile:gsub([[#include "imgui_structs%.h"]],cstructsstr)
|
||||
local cfuncsstr = func_header_generate(parser)
|
||||
cfuncsstr = colapse_defines(cfuncsstr, "IMGUI_ENABLE_FREETYPE")
|
||||
hstrfile = hstrfile:gsub([[#include "auto_funcs%.h"]],cfuncsstr)
|
||||
--patch hstrfile for ImWchar
|
||||
local num
|
||||
hstrfile, num = hstrfile:gsub("typedef ImWchar16 ImWchar;", wchardefine)
|
||||
assert(num == 1)
|
||||
hstrfile, num = hstrfile:gsub("kPagesMap%[%(0xFFFF", "kPagesMap[(IM_UNICODE_CODEPOINT_MAX")
|
||||
assert(num == 1, "kPagesMap[(IM_UNICODE_CODEPOINT_MAX not found or found more than once")
|
||||
save_data("./output/cimgui.h",cimgui_header,hstrfile)
|
||||
|
||||
--merge it in cimgui_template.cpp to cimgui.cpp
|
||||
local cimplem = func_implementation(parser)
|
||||
|
||||
cimplem = colapse_defines(cimplem, "IMGUI_ENABLE_FREETYPE")
|
||||
local hstrfile = read_data"./cimgui_template.cpp"
|
||||
|
||||
hstrfile = hstrfile:gsub([[#include "auto_funcs%.cpp"]],cimplem)
|
||||
local ftdef = FREETYPE_GENERATION and "#define IMGUI_ENABLE_FREETYPE\n" or ""
|
||||
local ftdef = "" --FREETYPE_GENERATION and "#define IMGUI_ENABLE_FREETYPE\n" or ""
|
||||
save_data("./output/cimgui.cpp",cimgui_header, ftdef, hstrfile)
|
||||
|
||||
end
|
||||
@@ -279,8 +321,8 @@ 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"}
|
||||
--cpp2ffi.prtable(gdefines)
|
||||
gdefines = get_defines{"IMGUI_VERSION","IMGUI_VERSION_NUM","FLT_MAX","FLT_MIN","IMGUI_HAS_DOCK","IMGUI_HAS_IMSTR","ImDrawCallback_ResetRenderState","IMGUI_HAS_TEXTURES"}
|
||||
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
|
||||
|
||||
@@ -300,11 +342,26 @@ if gdefines.IMGUI_HAS_DOCK then
|
||||
end
|
||||
assert(not NOCHAR or not NOIMSTRV,"nochar and noimstrv cant be set at the same time")
|
||||
print("IMGUI_HAS_IMSTR",gdefines.IMGUI_HAS_IMSTR)
|
||||
print("IMGUI_HAS_TEXTURES",gdefines.IMGUI_HAS_TEXTURES and true)
|
||||
print("NOCHAR",NOCHAR)
|
||||
print("NOIMSTRV",NOIMSTRV)
|
||||
print("IMGUI_HAS_DOCK",gdefines.IMGUI_HAS_DOCK)
|
||||
print("IMGUI_VERSION",gdefines.IMGUI_VERSION)
|
||||
|
||||
local function custom_function_post(self, outtab, def)
|
||||
assert(def.location)
|
||||
if def.location:match("imgui_freetype") then
|
||||
outtab[#outtab] = "#ifdef IMGUI_ENABLE_FREETYPE\n"..outtab[#outtab].."\n#endif\n"
|
||||
end
|
||||
end
|
||||
local function header_text_insert(self, outtab, txt, it)
|
||||
assert(it.locat)
|
||||
if it.locat:match("imgui_freetype") then
|
||||
table.insert(outtab, "\n#ifdef IMGUI_ENABLE_FREETYPE"..txt.."\n#endif")
|
||||
else
|
||||
table.insert(outtab, txt)
|
||||
end
|
||||
end
|
||||
|
||||
--funtion for parsing imgui headers
|
||||
local function parseImGuiHeader(header,names)
|
||||
@@ -316,13 +373,18 @@ local function parseImGuiHeader(header,names)
|
||||
return pre..funcname
|
||||
end
|
||||
parser.cname_overloads = cimgui_overloads
|
||||
parser.manuals = cimgui_manuals
|
||||
--parser.manuals = cimgui_manuals
|
||||
parser:set_manuals(cimgui_manuals, "cimgui")
|
||||
parser.skipped = cimgui_skipped
|
||||
parser.UDTs = {"ImVec2","ImVec4","ImColor","ImRect"}
|
||||
--parser.gen_template_typedef = gen_template_typedef --use auto
|
||||
parser.COMMENTS_GENERATION = COMMENTS_GENERATION
|
||||
parser.CONSTRUCTORS_GENERATION = CONSTRUCTORS_GENERATION
|
||||
parser.NOCHAR = NOCHAR
|
||||
parser.NOIMSTRV = NOIMSTRV
|
||||
parser.IMGUI_HAS_TEXTURES = gdefines.IMGUI_HAS_TEXTURES
|
||||
parser.custom_function_post = custom_function_post
|
||||
parser.header_text_insert = header_text_insert
|
||||
local defines = parser:take_lines(CPRE..header,names,COMPILER)
|
||||
|
||||
return parser
|
||||
@@ -393,11 +455,19 @@ local parser2
|
||||
|
||||
if #implementations > 0 then
|
||||
print("------------------implementations generation with "..COMPILER.."------------------------")
|
||||
--parser2 for function defs
|
||||
--parser3 for separated structs and enums in cimgui_impl.h
|
||||
parser2 = cpp2ffi.Parser()
|
||||
|
||||
local config = require"config_generator"
|
||||
local impl_str = ""
|
||||
local config = dofile(CONFIG_GENERATOR_PATH) --"./config_generator.lua"
|
||||
local impl_str = "#ifndef CIMGUI_IMPL_DEFINED\n#define CIMGUI_IMPL_DEFINED\n"
|
||||
local impl_str_cpp = {}
|
||||
for i,impl in ipairs(implementations) do
|
||||
print("------------implementation:",impl)
|
||||
table.insert(impl_str_cpp, "\n#ifdef CIMGUI_USE_" .. string.upper(impl))
|
||||
table.insert(impl_str_cpp, [[#include "imgui_impl_]]..impl..[[.h"]])
|
||||
table.insert(impl_str_cpp, "#endif")
|
||||
|
||||
local source = backends_folder .. [[imgui_impl_]].. impl .. ".h "
|
||||
local locati = [[imgui_impl_]].. impl
|
||||
|
||||
@@ -411,27 +481,43 @@ if #implementations > 0 then
|
||||
extra_includes = extra_includes .. include_cmd .. inc .. " "
|
||||
end
|
||||
end
|
||||
|
||||
parser2.cimgui_inherited = dofile([[./output/structs_and_enums.lua]])
|
||||
local defines = parser2:take_lines(CPRE..extra_defines..extra_includes..source, {locati}, COMPILER)
|
||||
|
||||
local parser3 = cpp2ffi.Parser()
|
||||
parser3.cimgui_inherited = dofile([[./output/structs_and_enums.lua]])
|
||||
parser3:take_lines(CPRE..extra_defines..extra_includes..source, {locati}, COMPILER)
|
||||
parser3:do_parse()
|
||||
local cfuncsstr = func_header_impl_generate(parser3)
|
||||
local cstructstr1,cstructstr2 = parser3.structs_and_enums[1], parser3.structs_and_enums[2]
|
||||
impl_str = impl_str .. "#ifdef CIMGUI_USE_".. string.upper(impl).."\n" .. cstructstr1 .. cstructstr2 .. cfuncsstr .. "\n#endif\n"
|
||||
local cstru = cstructstr1 .. cstructstr2
|
||||
if cstru ~="" then
|
||||
cstru = "#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n"..cstru .."\n#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n"
|
||||
end
|
||||
impl_str = impl_str .. "#ifdef CIMGUI_USE_".. string.upper(impl).."\n".. cstru
|
||||
local outtab = cpp2ffi.func_header_generate_structs(parser3)
|
||||
if #outtab > 0 then
|
||||
table.insert(outtab, 1, "#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n")
|
||||
table.insert(outtab,"#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n")
|
||||
end
|
||||
impl_str = impl_str.. table.concat(outtab)..cfuncsstr .. "\n#endif\n"
|
||||
end
|
||||
|
||||
impl_str = impl_str .. "#endif //CIMGUI_IMPL_DEFINED\n"
|
||||
parser2:do_parse()
|
||||
|
||||
-- save ./cimgui_impl.h
|
||||
--local cfuncsstr = func_header_impl_generate(parser2)
|
||||
--local cstructstr1,cstructstr2 = parser2.structs_and_enums[1], parser2.structs_and_enums[2]
|
||||
--save_data("./output/cimgui_impl.h",cstructstr1,cstructstr2,cfuncsstr)
|
||||
save_data("./output/cimgui_impl.h",impl_str)
|
||||
|
||||
----------save fundefs in impl_definitions.lua for using in bindings
|
||||
save_data("./output/impl_definitions.lua",serializeTableF(parser2.defsT))
|
||||
--impl cpp
|
||||
impl_str_cpp = table.concat(impl_str_cpp, "\n")
|
||||
local cppstr = read_data"./cimgui_impl_template.cpp"
|
||||
cppstr = cppstr:gsub("GENERATED_PLACEHOLDER", impl_str_cpp)
|
||||
save_data("./output/cimgui_impl.cpp",cppstr)
|
||||
|
||||
copyfile("./output/cimgui_impl.h", "../cimgui_impl.h")
|
||||
copyfile("./output/cimgui_impl.cpp", "../cimgui_impl.cpp")
|
||||
os.remove("./output/cimgui_impl.h")
|
||||
os.remove("./output/cimgui_impl.cpp")
|
||||
|
||||
end -- #implementations > 0 then
|
||||
|
||||
|
@@ -13,9 +13,11 @@
|
||||
|
||||
#process files
|
||||
# arg[1] compiler name gcc, clang, or cl
|
||||
# arg[2] options as words in one string: internal for imgui_internal generation, freetype for freetype generation, comments for comments generation, nochar to skip char* function version, noimstrv to skip imstrv
|
||||
# examples: "" "internal" "internal freetype" "comments internal"
|
||||
# arg[3..n] name of implementations to generate and/or CLFLAGS (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32)
|
||||
# arg[2] options as words in one string: internal for imgui_internal generation, comments for comments generation, nochar to skip char* function version, noimstrv to skip imstrv
|
||||
# "constructors" adds the _Construct version of constructors
|
||||
# examples: "" "internal" "comments internal"
|
||||
# arg[3..n] name of implementations to generate and/or CLFLAGS (e.g. -DIMGUI_USER_CONFIG)
|
||||
# -DIMGUI_USE_WCHAR32 should not be used as it is generated for both ImWchar
|
||||
#
|
||||
|
||||
# parse command line arguments
|
||||
@@ -23,7 +25,7 @@
|
||||
POSITIONAL_ARGS=()
|
||||
|
||||
TARGETS="internal noimstrv"
|
||||
CFLAGS="glfw opengl3 opengl2 sdl2"
|
||||
CFLAGS="glfw opengl3 opengl2 sdl2 sdl3"
|
||||
|
||||
help() {
|
||||
cat <<EOF
|
||||
|
@@ -1,66 +0,0 @@
|
||||
#ifdef CIMGUI_USE_GLFW
|
||||
|
||||
typedef struct GLFWwindow GLFWwindow;
|
||||
typedef struct GLFWmonitor GLFWmonitor;
|
||||
struct GLFWwindow;
|
||||
struct GLFWmonitor;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_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);
|
||||
|
||||
#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_CreateFontsTexture(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_DestroyFontsTexture(void);
|
||||
CIMGUI_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(void);
|
||||
|
||||
#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_CreateFontsTexture(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_DestroyFontsTexture(void);
|
||||
CIMGUI_API bool ImGui_ImplOpenGL2_CreateDeviceObjects(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_DestroyDeviceObjects(void);
|
||||
|
||||
#endif
|
||||
#ifdef CIMGUI_USE_SDL2
|
||||
|
||||
typedef struct SDL_Window SDL_Window;
|
||||
typedef struct SDL_Renderer SDL_Renderer;
|
||||
typedef struct _SDL_GameController _SDL_GameController;
|
||||
struct SDL_Window;
|
||||
struct SDL_Renderer;
|
||||
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;CIMGUI_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window,void* sdl_gl_context);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForVulkan(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_InitForOther(SDL_Window* window);
|
||||
CIMGUI_API void ImGui_ImplSDL2_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplSDL2_NewFrame(void);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
||||
CIMGUI_API void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode,struct _SDL_GameController** manual_gamepads_array,int manual_gamepads_count);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ ImColor_ImColor 5
|
||||
5 nil ImColor_ImColor_U32 (ImU32)
|
||||
ImDrawList_AddText 2
|
||||
1 void ImDrawList_AddText_Vec2 (const ImVec2,ImU32,const char*,const char*)
|
||||
2 void ImDrawList_AddText_FontPtr (const ImFont*,float,const ImVec2,ImU32,const char*,const char*,float,const ImVec4*)
|
||||
2 void ImDrawList_AddText_FontPtr (ImFont*,float,const ImVec2,ImU32,const char*,const char*,float,const ImVec4*)
|
||||
ImGuiPtrOrIndex_ImGuiPtrOrIndex 2
|
||||
1 nil ImGuiPtrOrIndex_ImGuiPtrOrIndex_Ptr (void*)
|
||||
2 nil ImGuiPtrOrIndex_ImGuiPtrOrIndex_Int (int)
|
||||
@@ -56,12 +56,18 @@ ImSpan_end 2
|
||||
ImSpan_set 2
|
||||
1 void ImSpan_set_Int (T*,int)
|
||||
2 void ImSpan_set_TPtr (T*,T*)
|
||||
ImTextureRef_ImTextureRef 2
|
||||
1 nil ImTextureRef_ImTextureRef_Nil ()
|
||||
2 nil ImTextureRef_ImTextureRef_TextureID (ImTextureID)
|
||||
ImVec1_ImVec1 2
|
||||
1 nil ImVec1_ImVec1_Nil ()
|
||||
2 nil ImVec1_ImVec1_Float (float)
|
||||
ImVec2_ImVec2 2
|
||||
1 nil ImVec2_ImVec2_Nil ()
|
||||
2 nil ImVec2_ImVec2_Float (float,float)
|
||||
ImVec2i_ImVec2i 2
|
||||
1 nil ImVec2i_ImVec2i_Nil ()
|
||||
2 nil ImVec2i_ImVec2i_Int (int,int)
|
||||
ImVec2ih_ImVec2ih 3
|
||||
1 nil ImVec2ih_ImVec2ih_Nil ()
|
||||
2 nil ImVec2ih_ImVec2ih_short (short,short)
|
||||
@@ -108,27 +114,30 @@ igCombo 3
|
||||
1 bool igCombo_Str_arr (const char*,int*,const char* const[],int,int)
|
||||
2 bool igCombo_Str (const char*,int*,const char*,int)
|
||||
3 bool igCombo_FnStrPtr (const char*,int*,const char*(*)(void*,int),void*,int,int)
|
||||
igGetBackgroundDrawList 2
|
||||
1 ImDrawList* igGetBackgroundDrawList_Nil ()
|
||||
2 ImDrawList* igGetBackgroundDrawList_ViewportPtr (ImGuiViewport*)
|
||||
igGetColorU32 3
|
||||
1 ImU32 igGetColorU32_Col (ImGuiCol,float)
|
||||
2 ImU32 igGetColorU32_Vec4 (const ImVec4)
|
||||
3 ImU32 igGetColorU32_U32 (ImU32,float)
|
||||
igGetForegroundDrawList 3
|
||||
1 ImDrawList* igGetForegroundDrawList_Nil ()
|
||||
2 ImDrawList* igGetForegroundDrawList_ViewportPtr (ImGuiViewport*)
|
||||
3 ImDrawList* igGetForegroundDrawList_WindowPtr (ImGuiWindow*)
|
||||
igGetID 3
|
||||
igGetForegroundDrawList 2
|
||||
1 ImDrawList* igGetForegroundDrawList_ViewportPtr (ImGuiViewport*)
|
||||
2 ImDrawList* igGetForegroundDrawList_WindowPtr (ImGuiWindow*)
|
||||
igGetID 4
|
||||
1 ImGuiID igGetID_Str (const char*)
|
||||
2 ImGuiID igGetID_StrStr (const char*,const char*)
|
||||
3 ImGuiID igGetID_Ptr (const void*)
|
||||
4 ImGuiID igGetID_Int (int)
|
||||
igGetIDWithSeed 2
|
||||
1 ImGuiID igGetIDWithSeed_Str (const char*,const char*,ImGuiID)
|
||||
2 ImGuiID igGetIDWithSeed_Int (int,ImGuiID)
|
||||
igGetIO 2
|
||||
1 ImGuiIO* igGetIO_Nil ()
|
||||
2 ImGuiIO* igGetIO_ContextPtr (ImGuiContext*)
|
||||
igGetKeyData 2
|
||||
1 ImGuiKeyData* igGetKeyData_ContextPtr (ImGuiContext*,ImGuiKey)
|
||||
2 ImGuiKeyData* igGetKeyData_Key (ImGuiKey)
|
||||
igGetPlatformIO 2
|
||||
1 ImGuiPlatformIO* igGetPlatformIO_Nil ()
|
||||
2 ImGuiPlatformIO* igGetPlatformIO_ContextPtr (ImGuiContext*)
|
||||
igImAbs 3
|
||||
1 int igImAbs_Int (int)
|
||||
2 float igImAbs_Float (float)
|
||||
@@ -229,6 +238,9 @@ igRadioButton 2
|
||||
igSelectable 2
|
||||
1 bool igSelectable_Bool (const char*,bool,ImGuiSelectableFlags,const ImVec2)
|
||||
2 bool igSelectable_BoolPtr (const char*,bool*,ImGuiSelectableFlags,const ImVec2)
|
||||
igSetItemKeyOwner 2
|
||||
1 void igSetItemKeyOwner_Nil (ImGuiKey)
|
||||
2 void igSetItemKeyOwner_InputFlags (ImGuiKey,ImGuiInputFlags)
|
||||
igSetScrollFromPosX 2
|
||||
1 void igSetScrollFromPosX_Float (float,float)
|
||||
2 void igSetScrollFromPosX_WindowPtr (ImGuiWindow*,float,float)
|
||||
@@ -259,6 +271,9 @@ igSetWindowSize 3
|
||||
igShortcut 2
|
||||
1 bool igShortcut_Nil (ImGuiKeyChord,ImGuiInputFlags)
|
||||
2 bool igShortcut_ID (ImGuiKeyChord,ImGuiInputFlags,ImGuiID)
|
||||
igTabBarQueueFocus 2
|
||||
1 void igTabBarQueueFocus_TabItemPtr (ImGuiTabBar*,ImGuiTabItem*)
|
||||
2 void igTabBarQueueFocus_Str (ImGuiTabBar*,const char*)
|
||||
igTabItemCalcSize 2
|
||||
1 ImVec2 igTabItemCalcSize_Str (const char*,bool)
|
||||
2 ImVec2 igTabItemCalcSize_WindowPtr (ImGuiWindow*)
|
||||
@@ -290,4 +305,4 @@ igValue 4
|
||||
2 void igValue_Int (const char*,int)
|
||||
3 void igValue_Uint (const char*,unsigned int)
|
||||
4 void igValue_Float (const char*,float,const char*)
|
||||
203 overloaded
|
||||
213 overloaded
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"ImBitArrayForNamedKeys": "ImBitArray<ImGuiKey_NamedKey_COUNT,-ImGuiKey_NamedKey_BEGIN>",
|
||||
"ImBitArrayForNamedKeys": "ImBitArray<ImGuiKey_NamedKey_COUNT, -ImGuiKey_NamedKey_BEGIN>",
|
||||
"ImBitArrayPtr": "ImU32*",
|
||||
"ImBitVector": "struct ImBitVector",
|
||||
"ImColor": "struct ImColor",
|
||||
"ImDrawCallback": "void(*)(const ImDrawList* parent_list,const ImDrawCmd* cmd);",
|
||||
"ImDrawCallback": "void (*)(const ImDrawList* parent_list, const ImDrawCmd* cmd);",
|
||||
"ImDrawChannel": "struct ImDrawChannel",
|
||||
"ImDrawCmd": "struct ImDrawCmd",
|
||||
"ImDrawCmdHeader": "struct ImDrawCmdHeader",
|
||||
@@ -19,14 +19,22 @@
|
||||
"ImFileHandle": "FILE*",
|
||||
"ImFont": "struct ImFont",
|
||||
"ImFontAtlas": "struct ImFontAtlas",
|
||||
"ImFontAtlasCustomRect": "struct ImFontAtlasCustomRect",
|
||||
"ImFontAtlasBuilder": "struct ImFontAtlasBuilder",
|
||||
"ImFontAtlasFlags": "int",
|
||||
"ImFontBuilderIO": "struct ImFontBuilderIO",
|
||||
"ImFontAtlasPostProcessData": "struct ImFontAtlasPostProcessData",
|
||||
"ImFontAtlasRect": "struct ImFontAtlasRect",
|
||||
"ImFontAtlasRectEntry": "struct ImFontAtlasRectEntry",
|
||||
"ImFontAtlasRectId": "int",
|
||||
"ImFontBaked": "struct ImFontBaked",
|
||||
"ImFontConfig": "struct ImFontConfig",
|
||||
"ImFontFlags": "int",
|
||||
"ImFontGlyph": "struct ImFontGlyph",
|
||||
"ImFontGlyphRangesBuilder": "struct ImFontGlyphRangesBuilder",
|
||||
"ImFontLoader": "struct ImFontLoader",
|
||||
"ImFontStackData": "struct ImFontStackData",
|
||||
"ImGuiActivateFlags": "int",
|
||||
"ImGuiBackendFlags": "int",
|
||||
"ImGuiBoxSelectState": "struct ImGuiBoxSelectState",
|
||||
"ImGuiButtonFlags": "int",
|
||||
"ImGuiChildFlags": "int",
|
||||
"ImGuiCol": "int",
|
||||
@@ -38,26 +46,27 @@
|
||||
"ImGuiConfigFlags": "int",
|
||||
"ImGuiContext": "struct ImGuiContext",
|
||||
"ImGuiContextHook": "struct ImGuiContextHook",
|
||||
"ImGuiContextHookCallback": "void(*)(ImGuiContext* ctx,ImGuiContextHook* hook);",
|
||||
"ImGuiContextHookCallback": "void (*)(ImGuiContext* ctx, ImGuiContextHook* hook);",
|
||||
"ImGuiDataAuthority": "int",
|
||||
"ImGuiDataType": "int",
|
||||
"ImGuiDataTypeInfo": "struct ImGuiDataTypeInfo",
|
||||
"ImGuiDataTypeTempStorage": "struct ImGuiDataTypeTempStorage",
|
||||
"ImGuiDataVarInfo": "struct ImGuiDataVarInfo",
|
||||
"ImGuiDataTypeStorage": "struct ImGuiDataTypeStorage",
|
||||
"ImGuiDeactivatedItemData": "struct ImGuiDeactivatedItemData",
|
||||
"ImGuiDebugAllocEntry": "struct ImGuiDebugAllocEntry",
|
||||
"ImGuiDebugAllocInfo": "struct ImGuiDebugAllocInfo",
|
||||
"ImGuiDebugLogFlags": "int",
|
||||
"ImGuiDir": "int",
|
||||
"ImGuiDockContext": "struct ImGuiDockContext",
|
||||
"ImGuiDockNode": "struct ImGuiDockNode",
|
||||
"ImGuiDockNodeFlags": "int",
|
||||
"ImGuiDockNodeSettings": "struct ImGuiDockNodeSettings",
|
||||
"ImGuiDockRequest": "struct ImGuiDockRequest",
|
||||
"ImGuiDragDropFlags": "int",
|
||||
"ImGuiErrorLogCallback": "void(*)(void* user_data,const char* fmt,...);",
|
||||
"ImGuiErrorCallback": "void (*)(ImGuiContext* ctx, void* user_data, const char* msg);",
|
||||
"ImGuiErrorRecoveryState": "struct ImGuiErrorRecoveryState",
|
||||
"ImGuiFocusRequestFlags": "int",
|
||||
"ImGuiFocusScopeData": "struct ImGuiFocusScopeData",
|
||||
"ImGuiFocusedFlags": "int",
|
||||
"ImGuiFreeTypeLoaderFlags": "unsigned int",
|
||||
"ImGuiGroupData": "struct ImGuiGroupData",
|
||||
"ImGuiHoveredFlags": "int",
|
||||
"ImGuiID": "unsigned int",
|
||||
@@ -72,7 +81,7 @@
|
||||
"ImGuiInputEventMouseWheel": "struct ImGuiInputEventMouseWheel",
|
||||
"ImGuiInputEventText": "struct ImGuiInputEventText",
|
||||
"ImGuiInputFlags": "int",
|
||||
"ImGuiInputTextCallback": "int(*)(ImGuiInputTextCallbackData* data);",
|
||||
"ImGuiInputTextCallback": "int (*)(ImGuiInputTextCallbackData* data);",
|
||||
"ImGuiInputTextCallbackData": "struct ImGuiInputTextCallbackData",
|
||||
"ImGuiInputTextDeactivateData": "struct ImGuiInputTextDeactivateData",
|
||||
"ImGuiInputTextDeactivatedState": "struct ImGuiInputTextDeactivatedState",
|
||||
@@ -92,16 +101,20 @@
|
||||
"ImGuiListClipperData": "struct ImGuiListClipperData",
|
||||
"ImGuiListClipperRange": "struct ImGuiListClipperRange",
|
||||
"ImGuiLocEntry": "struct ImGuiLocEntry",
|
||||
"ImGuiMemAllocFunc": "void*(*)(size_t sz,void* user_data);",
|
||||
"ImGuiMemFreeFunc": "void(*)(void* ptr,void* user_data);",
|
||||
"ImGuiLogFlags": "int",
|
||||
"ImGuiMemAllocFunc": "void* (*)(size_t sz, void* user_data);",
|
||||
"ImGuiMemFreeFunc": "void (*)(void* ptr, void* user_data);",
|
||||
"ImGuiMenuColumns": "struct ImGuiMenuColumns",
|
||||
"ImGuiMetricsConfig": "struct ImGuiMetricsConfig",
|
||||
"ImGuiMouseButton": "int",
|
||||
"ImGuiMouseCursor": "int",
|
||||
"ImGuiNavHighlightFlags": "int",
|
||||
"ImGuiMultiSelectFlags": "int",
|
||||
"ImGuiMultiSelectIO": "struct ImGuiMultiSelectIO",
|
||||
"ImGuiMultiSelectState": "struct ImGuiMultiSelectState",
|
||||
"ImGuiMultiSelectTempData": "struct ImGuiMultiSelectTempData",
|
||||
"ImGuiNavItemData": "struct ImGuiNavItemData",
|
||||
"ImGuiNavMoveFlags": "int",
|
||||
"ImGuiNavTreeNodeData": "struct ImGuiNavTreeNodeData",
|
||||
"ImGuiNavRenderCursorFlags": "int",
|
||||
"ImGuiNextItemData": "struct ImGuiNextItemData",
|
||||
"ImGuiNextItemDataFlags": "int",
|
||||
"ImGuiNextWindowData": "struct ImGuiNextWindowData",
|
||||
@@ -119,21 +132,23 @@
|
||||
"ImGuiPtrOrIndex": "struct ImGuiPtrOrIndex",
|
||||
"ImGuiScrollFlags": "int",
|
||||
"ImGuiSelectableFlags": "int",
|
||||
"ImGuiSelectionBasicStorage": "struct ImGuiSelectionBasicStorage",
|
||||
"ImGuiSelectionExternalStorage": "struct ImGuiSelectionExternalStorage",
|
||||
"ImGuiSelectionRequest": "struct ImGuiSelectionRequest",
|
||||
"ImGuiSelectionUserData": "ImS64",
|
||||
"ImGuiSeparatorFlags": "int",
|
||||
"ImGuiSettingsHandler": "struct ImGuiSettingsHandler",
|
||||
"ImGuiShrinkWidthItem": "struct ImGuiShrinkWidthItem",
|
||||
"ImGuiSizeCallback": "void(*)(ImGuiSizeCallbackData* data);",
|
||||
"ImGuiSizeCallback": "void (*)(ImGuiSizeCallbackData* data);",
|
||||
"ImGuiSizeCallbackData": "struct ImGuiSizeCallbackData",
|
||||
"ImGuiSliderFlags": "int",
|
||||
"ImGuiSortDirection": "int",
|
||||
"ImGuiStackLevelInfo": "struct ImGuiStackLevelInfo",
|
||||
"ImGuiStackSizes": "struct ImGuiStackSizes",
|
||||
"ImGuiStorage": "struct ImGuiStorage",
|
||||
"ImGuiStoragePair": "struct ImGuiStoragePair",
|
||||
"ImGuiStyle": "struct ImGuiStyle",
|
||||
"ImGuiStyleMod": "struct ImGuiStyleMod",
|
||||
"ImGuiStyleVar": "int",
|
||||
"ImGuiStyleVarInfo": "struct ImGuiStyleVarInfo",
|
||||
"ImGuiTabBar": "struct ImGuiTabBar",
|
||||
"ImGuiTabBarFlags": "int",
|
||||
"ImGuiTabItem": "struct ImGuiTabItem",
|
||||
@@ -162,6 +177,7 @@
|
||||
"ImGuiTextRange": "struct ImGuiTextRange",
|
||||
"ImGuiTooltipFlags": "int",
|
||||
"ImGuiTreeNodeFlags": "int",
|
||||
"ImGuiTreeNodeStackData": "struct ImGuiTreeNodeStackData",
|
||||
"ImGuiTypingSelectFlags": "int",
|
||||
"ImGuiTypingSelectRequest": "struct ImGuiTypingSelectRequest",
|
||||
"ImGuiTypingSelectState": "struct ImGuiTypingSelectState",
|
||||
@@ -182,23 +198,25 @@
|
||||
"ImS32": "signed int",
|
||||
"ImS64": "signed long long",
|
||||
"ImS8": "signed char",
|
||||
"ImTextureID": "void*",
|
||||
"ImStbTexteditState": "ImStb::STB_TexteditState",
|
||||
"ImTextureData": "struct ImTextureData",
|
||||
"ImTextureID": "ImU64",
|
||||
"ImTextureRect": "struct ImTextureRect",
|
||||
"ImTextureRef": "struct ImTextureRef",
|
||||
"ImU16": "unsigned short",
|
||||
"ImU32": "unsigned int",
|
||||
"ImU64": "unsigned long long",
|
||||
"ImU8": "unsigned char",
|
||||
"ImVec1": "struct ImVec1",
|
||||
"ImVec2": "struct ImVec2",
|
||||
"ImVec2i": "struct ImVec2i",
|
||||
"ImVec2ih": "struct ImVec2ih",
|
||||
"ImVec4": "struct ImVec4",
|
||||
"ImWchar": "ImWchar16",
|
||||
"ImWchar16": "unsigned short",
|
||||
"ImWchar32": "unsigned int",
|
||||
"STB_TexteditState": "struct STB_TexteditState",
|
||||
"StbTexteditRow": "struct StbTexteditRow",
|
||||
"StbUndoRecord": "struct StbUndoRecord",
|
||||
"StbUndoState": "struct StbUndoState",
|
||||
"const_iterator": "const value_type*",
|
||||
"iterator": "value_type*",
|
||||
"value_type": "T"
|
||||
"stbrp_context_opaque": "struct stbrp_context_opaque",
|
||||
"stbrp_node": "struct stbrp_node",
|
||||
"stbrp_node_im": "stbrp_node"
|
||||
}
|
@@ -1,205 +1,222 @@
|
||||
local defs = {}
|
||||
defs["ImBitArrayForNamedKeys"] = "ImBitArray<ImGuiKey_NamedKey_COUNT,-ImGuiKey_NamedKey_BEGIN>"
|
||||
defs["ImBitArrayPtr"] = "ImU32*"
|
||||
defs["ImBitVector"] = "struct ImBitVector"
|
||||
defs["ImColor"] = "struct ImColor"
|
||||
defs["ImDrawCallback"] = "void(*)(const ImDrawList* parent_list,const ImDrawCmd* cmd);"
|
||||
defs["ImDrawChannel"] = "struct ImDrawChannel"
|
||||
defs["ImDrawCmd"] = "struct ImDrawCmd"
|
||||
defs["ImDrawCmdHeader"] = "struct ImDrawCmdHeader"
|
||||
defs["ImDrawData"] = "struct ImDrawData"
|
||||
defs["ImDrawDataBuilder"] = "struct ImDrawDataBuilder"
|
||||
defs["ImDrawFlags"] = "int"
|
||||
defs["ImDrawIdx"] = "unsigned short"
|
||||
defs["ImDrawList"] = "struct ImDrawList"
|
||||
defs["ImDrawListFlags"] = "int"
|
||||
defs["ImDrawListSharedData"] = "struct ImDrawListSharedData"
|
||||
defs["ImDrawListSplitter"] = "struct ImDrawListSplitter"
|
||||
defs["ImDrawVert"] = "struct ImDrawVert"
|
||||
defs["ImFileHandle"] = "FILE*"
|
||||
defs["ImFont"] = "struct ImFont"
|
||||
defs["ImFontAtlas"] = "struct ImFontAtlas"
|
||||
defs["ImFontAtlasCustomRect"] = "struct ImFontAtlasCustomRect"
|
||||
defs["ImFontAtlasFlags"] = "int"
|
||||
defs["ImFontBuilderIO"] = "struct ImFontBuilderIO"
|
||||
defs["ImFontConfig"] = "struct ImFontConfig"
|
||||
defs["ImFontGlyph"] = "struct ImFontGlyph"
|
||||
defs["ImFontGlyphRangesBuilder"] = "struct ImFontGlyphRangesBuilder"
|
||||
defs["ImGuiActivateFlags"] = "int"
|
||||
defs["ImGuiBackendFlags"] = "int"
|
||||
defs["ImGuiButtonFlags"] = "int"
|
||||
defs["ImGuiChildFlags"] = "int"
|
||||
defs["ImGuiCol"] = "int"
|
||||
defs["ImGuiColorEditFlags"] = "int"
|
||||
defs["ImGuiColorMod"] = "struct ImGuiColorMod"
|
||||
defs["ImGuiComboFlags"] = "int"
|
||||
defs["ImGuiComboPreviewData"] = "struct ImGuiComboPreviewData"
|
||||
defs["ImGuiCond"] = "int"
|
||||
defs["ImGuiConfigFlags"] = "int"
|
||||
defs["ImGuiContext"] = "struct ImGuiContext"
|
||||
defs["ImGuiContextHook"] = "struct ImGuiContextHook"
|
||||
defs["ImGuiContextHookCallback"] = "void(*)(ImGuiContext* ctx,ImGuiContextHook* hook);"
|
||||
defs["ImGuiDataAuthority"] = "int"
|
||||
defs["ImGuiDataType"] = "int"
|
||||
defs["ImGuiDataTypeInfo"] = "struct ImGuiDataTypeInfo"
|
||||
defs["ImGuiDataTypeTempStorage"] = "struct ImGuiDataTypeTempStorage"
|
||||
defs["ImGuiDataVarInfo"] = "struct ImGuiDataVarInfo"
|
||||
defs["ImGuiDebugAllocEntry"] = "struct ImGuiDebugAllocEntry"
|
||||
defs["ImGuiDebugAllocInfo"] = "struct ImGuiDebugAllocInfo"
|
||||
defs["ImGuiDebugLogFlags"] = "int"
|
||||
defs["ImGuiDir"] = "int"
|
||||
defs["ImGuiDockContext"] = "struct ImGuiDockContext"
|
||||
defs["ImGuiDockNode"] = "struct ImGuiDockNode"
|
||||
defs["ImGuiDockNodeFlags"] = "int"
|
||||
defs["ImGuiDockNodeSettings"] = "struct ImGuiDockNodeSettings"
|
||||
defs["ImGuiDockRequest"] = "struct ImGuiDockRequest"
|
||||
defs["ImGuiDragDropFlags"] = "int"
|
||||
defs["ImGuiErrorLogCallback"] = "void(*)(void* user_data,const char* fmt,...);"
|
||||
defs["ImGuiFocusRequestFlags"] = "int"
|
||||
defs["ImGuiFocusScopeData"] = "struct ImGuiFocusScopeData"
|
||||
defs["ImGuiFocusedFlags"] = "int"
|
||||
defs["ImGuiGroupData"] = "struct ImGuiGroupData"
|
||||
defs["ImGuiHoveredFlags"] = "int"
|
||||
defs["ImGuiID"] = "unsigned int"
|
||||
defs["ImGuiIDStackTool"] = "struct ImGuiIDStackTool"
|
||||
defs["ImGuiIO"] = "struct ImGuiIO"
|
||||
defs["ImGuiInputEvent"] = "struct ImGuiInputEvent"
|
||||
defs["ImGuiInputEventAppFocused"] = "struct ImGuiInputEventAppFocused"
|
||||
defs["ImGuiInputEventKey"] = "struct ImGuiInputEventKey"
|
||||
defs["ImGuiInputEventMouseButton"] = "struct ImGuiInputEventMouseButton"
|
||||
defs["ImGuiInputEventMousePos"] = "struct ImGuiInputEventMousePos"
|
||||
defs["ImGuiInputEventMouseViewport"] = "struct ImGuiInputEventMouseViewport"
|
||||
defs["ImGuiInputEventMouseWheel"] = "struct ImGuiInputEventMouseWheel"
|
||||
defs["ImGuiInputEventText"] = "struct ImGuiInputEventText"
|
||||
defs["ImGuiInputFlags"] = "int"
|
||||
defs["ImGuiInputTextCallback"] = "int(*)(ImGuiInputTextCallbackData* data);"
|
||||
defs["ImGuiInputTextCallbackData"] = "struct ImGuiInputTextCallbackData"
|
||||
defs["ImGuiInputTextDeactivateData"] = "struct ImGuiInputTextDeactivateData"
|
||||
defs["ImGuiInputTextDeactivatedState"] = "struct ImGuiInputTextDeactivatedState"
|
||||
defs["ImGuiInputTextFlags"] = "int"
|
||||
defs["ImGuiInputTextState"] = "struct ImGuiInputTextState"
|
||||
defs["ImGuiItemFlags"] = "int"
|
||||
defs["ImGuiItemStatusFlags"] = "int"
|
||||
defs["ImGuiKeyChord"] = "int"
|
||||
defs["ImGuiKeyData"] = "struct ImGuiKeyData"
|
||||
defs["ImGuiKeyOwnerData"] = "struct ImGuiKeyOwnerData"
|
||||
defs["ImGuiKeyRoutingData"] = "struct ImGuiKeyRoutingData"
|
||||
defs["ImGuiKeyRoutingIndex"] = "ImS16"
|
||||
defs["ImGuiKeyRoutingTable"] = "struct ImGuiKeyRoutingTable"
|
||||
defs["ImGuiLastItemData"] = "struct ImGuiLastItemData"
|
||||
defs["ImGuiLayoutType"] = "int"
|
||||
defs["ImGuiListClipper"] = "struct ImGuiListClipper"
|
||||
defs["ImGuiListClipperData"] = "struct ImGuiListClipperData"
|
||||
defs["ImGuiListClipperRange"] = "struct ImGuiListClipperRange"
|
||||
defs["ImGuiLocEntry"] = "struct ImGuiLocEntry"
|
||||
defs["ImGuiMemAllocFunc"] = "void*(*)(size_t sz,void* user_data);"
|
||||
defs["ImGuiMemFreeFunc"] = "void(*)(void* ptr,void* user_data);"
|
||||
defs["ImGuiMenuColumns"] = "struct ImGuiMenuColumns"
|
||||
defs["ImGuiMetricsConfig"] = "struct ImGuiMetricsConfig"
|
||||
defs["ImGuiMouseButton"] = "int"
|
||||
defs["ImGuiMouseCursor"] = "int"
|
||||
defs["ImGuiNavHighlightFlags"] = "int"
|
||||
defs["ImGuiNavItemData"] = "struct ImGuiNavItemData"
|
||||
defs["ImGuiNavMoveFlags"] = "int"
|
||||
defs["ImGuiNavTreeNodeData"] = "struct ImGuiNavTreeNodeData"
|
||||
defs["ImGuiNextItemData"] = "struct ImGuiNextItemData"
|
||||
defs["ImGuiNextItemDataFlags"] = "int"
|
||||
defs["ImGuiNextWindowData"] = "struct ImGuiNextWindowData"
|
||||
defs["ImGuiNextWindowDataFlags"] = "int"
|
||||
defs["ImGuiOldColumnData"] = "struct ImGuiOldColumnData"
|
||||
defs["ImGuiOldColumnFlags"] = "int"
|
||||
defs["ImGuiOldColumns"] = "struct ImGuiOldColumns"
|
||||
defs["ImGuiOnceUponAFrame"] = "struct ImGuiOnceUponAFrame"
|
||||
defs["ImGuiPayload"] = "struct ImGuiPayload"
|
||||
defs["ImGuiPlatformIO"] = "struct ImGuiPlatformIO"
|
||||
defs["ImGuiPlatformImeData"] = "struct ImGuiPlatformImeData"
|
||||
defs["ImGuiPlatformMonitor"] = "struct ImGuiPlatformMonitor"
|
||||
defs["ImGuiPopupData"] = "struct ImGuiPopupData"
|
||||
defs["ImGuiPopupFlags"] = "int"
|
||||
defs["ImGuiPtrOrIndex"] = "struct ImGuiPtrOrIndex"
|
||||
defs["ImGuiScrollFlags"] = "int"
|
||||
defs["ImGuiSelectableFlags"] = "int"
|
||||
defs["ImGuiSelectionUserData"] = "ImS64"
|
||||
defs["ImGuiSeparatorFlags"] = "int"
|
||||
defs["ImGuiSettingsHandler"] = "struct ImGuiSettingsHandler"
|
||||
defs["ImGuiShrinkWidthItem"] = "struct ImGuiShrinkWidthItem"
|
||||
defs["ImGuiSizeCallback"] = "void(*)(ImGuiSizeCallbackData* data);"
|
||||
defs["ImGuiSizeCallbackData"] = "struct ImGuiSizeCallbackData"
|
||||
defs["ImGuiSliderFlags"] = "int"
|
||||
defs["ImGuiSortDirection"] = "int"
|
||||
defs["ImGuiStackLevelInfo"] = "struct ImGuiStackLevelInfo"
|
||||
defs["ImGuiStackSizes"] = "struct ImGuiStackSizes"
|
||||
defs["ImGuiStorage"] = "struct ImGuiStorage"
|
||||
defs["ImGuiStoragePair"] = "struct ImGuiStoragePair"
|
||||
defs["ImGuiStyle"] = "struct ImGuiStyle"
|
||||
defs["ImGuiStyleMod"] = "struct ImGuiStyleMod"
|
||||
defs["ImGuiStyleVar"] = "int"
|
||||
defs["ImGuiTabBar"] = "struct ImGuiTabBar"
|
||||
defs["ImGuiTabBarFlags"] = "int"
|
||||
defs["ImGuiTabItem"] = "struct ImGuiTabItem"
|
||||
defs["ImGuiTabItemFlags"] = "int"
|
||||
defs["ImGuiTable"] = "struct ImGuiTable"
|
||||
defs["ImGuiTableBgTarget"] = "int"
|
||||
defs["ImGuiTableCellData"] = "struct ImGuiTableCellData"
|
||||
defs["ImGuiTableColumn"] = "struct ImGuiTableColumn"
|
||||
defs["ImGuiTableColumnFlags"] = "int"
|
||||
defs["ImGuiTableColumnIdx"] = "ImS16"
|
||||
defs["ImGuiTableColumnSettings"] = "struct ImGuiTableColumnSettings"
|
||||
defs["ImGuiTableColumnSortSpecs"] = "struct ImGuiTableColumnSortSpecs"
|
||||
defs["ImGuiTableColumnsSettings"] = "struct ImGuiTableColumnsSettings"
|
||||
defs["ImGuiTableDrawChannelIdx"] = "ImU16"
|
||||
defs["ImGuiTableFlags"] = "int"
|
||||
defs["ImGuiTableHeaderData"] = "struct ImGuiTableHeaderData"
|
||||
defs["ImGuiTableInstanceData"] = "struct ImGuiTableInstanceData"
|
||||
defs["ImGuiTableRowFlags"] = "int"
|
||||
defs["ImGuiTableSettings"] = "struct ImGuiTableSettings"
|
||||
defs["ImGuiTableSortSpecs"] = "struct ImGuiTableSortSpecs"
|
||||
defs["ImGuiTableTempData"] = "struct ImGuiTableTempData"
|
||||
defs["ImGuiTextBuffer"] = "struct ImGuiTextBuffer"
|
||||
defs["ImGuiTextFilter"] = "struct ImGuiTextFilter"
|
||||
defs["ImGuiTextFlags"] = "int"
|
||||
defs["ImGuiTextIndex"] = "struct ImGuiTextIndex"
|
||||
defs["ImGuiTextRange"] = "struct ImGuiTextRange"
|
||||
defs["ImGuiTooltipFlags"] = "int"
|
||||
defs["ImGuiTreeNodeFlags"] = "int"
|
||||
defs["ImGuiTypingSelectFlags"] = "int"
|
||||
defs["ImGuiTypingSelectRequest"] = "struct ImGuiTypingSelectRequest"
|
||||
defs["ImGuiTypingSelectState"] = "struct ImGuiTypingSelectState"
|
||||
defs["ImGuiViewport"] = "struct ImGuiViewport"
|
||||
defs["ImGuiViewportFlags"] = "int"
|
||||
defs["ImGuiViewportP"] = "struct ImGuiViewportP"
|
||||
defs["ImGuiWindow"] = "struct ImGuiWindow"
|
||||
defs["ImGuiWindowClass"] = "struct ImGuiWindowClass"
|
||||
defs["ImGuiWindowDockStyle"] = "struct ImGuiWindowDockStyle"
|
||||
defs["ImGuiWindowFlags"] = "int"
|
||||
defs["ImGuiWindowRefreshFlags"] = "int"
|
||||
defs["ImGuiWindowSettings"] = "struct ImGuiWindowSettings"
|
||||
defs["ImGuiWindowStackData"] = "struct ImGuiWindowStackData"
|
||||
defs["ImGuiWindowTempData"] = "struct ImGuiWindowTempData"
|
||||
defs["ImPoolIdx"] = "int"
|
||||
defs["ImRect"] = "struct ImRect"
|
||||
defs["ImS16"] = "signed short"
|
||||
defs["ImS32"] = "signed int"
|
||||
defs["ImS64"] = "signed long long"
|
||||
defs["ImS8"] = "signed char"
|
||||
defs["ImTextureID"] = "void*"
|
||||
defs["ImU16"] = "unsigned short"
|
||||
defs["ImU32"] = "unsigned int"
|
||||
defs["ImU64"] = "unsigned long long"
|
||||
defs["ImU8"] = "unsigned char"
|
||||
defs["ImVec1"] = "struct ImVec1"
|
||||
defs["ImVec2"] = "struct ImVec2"
|
||||
defs["ImVec2ih"] = "struct ImVec2ih"
|
||||
defs["ImVec4"] = "struct ImVec4"
|
||||
defs["ImWchar"] = "ImWchar16"
|
||||
defs["ImWchar16"] = "unsigned short"
|
||||
defs["ImWchar32"] = "unsigned int"
|
||||
defs["STB_TexteditState"] = "struct STB_TexteditState"
|
||||
defs["StbTexteditRow"] = "struct StbTexteditRow"
|
||||
defs["StbUndoRecord"] = "struct StbUndoRecord"
|
||||
defs["StbUndoState"] = "struct StbUndoState"
|
||||
defs["const_iterator"] = "const value_type*"
|
||||
defs["iterator"] = "value_type*"
|
||||
defs["value_type"] = "T"
|
||||
|
||||
return defs
|
||||
local t={
|
||||
ImBitArrayForNamedKeys="ImBitArray<ImGuiKey_NamedKey_COUNT, -ImGuiKey_NamedKey_BEGIN>",
|
||||
ImBitArrayPtr="ImU32*",
|
||||
ImBitVector="struct ImBitVector",
|
||||
ImColor="struct ImColor",
|
||||
ImDrawCallback="void (*)(const ImDrawList* parent_list, const ImDrawCmd* cmd);",
|
||||
ImDrawChannel="struct ImDrawChannel",
|
||||
ImDrawCmd="struct ImDrawCmd",
|
||||
ImDrawCmdHeader="struct ImDrawCmdHeader",
|
||||
ImDrawData="struct ImDrawData",
|
||||
ImDrawDataBuilder="struct ImDrawDataBuilder",
|
||||
ImDrawFlags="int",
|
||||
ImDrawIdx="unsigned short",
|
||||
ImDrawList="struct ImDrawList",
|
||||
ImDrawListFlags="int",
|
||||
ImDrawListSharedData="struct ImDrawListSharedData",
|
||||
ImDrawListSplitter="struct ImDrawListSplitter",
|
||||
ImDrawVert="struct ImDrawVert",
|
||||
ImFileHandle="FILE*",
|
||||
ImFont="struct ImFont",
|
||||
ImFontAtlas="struct ImFontAtlas",
|
||||
ImFontAtlasBuilder="struct ImFontAtlasBuilder",
|
||||
ImFontAtlasFlags="int",
|
||||
ImFontAtlasPostProcessData="struct ImFontAtlasPostProcessData",
|
||||
ImFontAtlasRect="struct ImFontAtlasRect",
|
||||
ImFontAtlasRectEntry="struct ImFontAtlasRectEntry",
|
||||
ImFontAtlasRectId="int",
|
||||
ImFontBaked="struct ImFontBaked",
|
||||
ImFontConfig="struct ImFontConfig",
|
||||
ImFontFlags="int",
|
||||
ImFontGlyph="struct ImFontGlyph",
|
||||
ImFontGlyphRangesBuilder="struct ImFontGlyphRangesBuilder",
|
||||
ImFontLoader="struct ImFontLoader",
|
||||
ImFontStackData="struct ImFontStackData",
|
||||
ImGuiActivateFlags="int",
|
||||
ImGuiBackendFlags="int",
|
||||
ImGuiBoxSelectState="struct ImGuiBoxSelectState",
|
||||
ImGuiButtonFlags="int",
|
||||
ImGuiChildFlags="int",
|
||||
ImGuiCol="int",
|
||||
ImGuiColorEditFlags="int",
|
||||
ImGuiColorMod="struct ImGuiColorMod",
|
||||
ImGuiComboFlags="int",
|
||||
ImGuiComboPreviewData="struct ImGuiComboPreviewData",
|
||||
ImGuiCond="int",
|
||||
ImGuiConfigFlags="int",
|
||||
ImGuiContext="struct ImGuiContext",
|
||||
ImGuiContextHook="struct ImGuiContextHook",
|
||||
ImGuiContextHookCallback="void (*)(ImGuiContext* ctx, ImGuiContextHook* hook);",
|
||||
ImGuiDataAuthority="int",
|
||||
ImGuiDataType="int",
|
||||
ImGuiDataTypeInfo="struct ImGuiDataTypeInfo",
|
||||
ImGuiDataTypeStorage="struct ImGuiDataTypeStorage",
|
||||
ImGuiDeactivatedItemData="struct ImGuiDeactivatedItemData",
|
||||
ImGuiDebugAllocEntry="struct ImGuiDebugAllocEntry",
|
||||
ImGuiDebugAllocInfo="struct ImGuiDebugAllocInfo",
|
||||
ImGuiDebugLogFlags="int",
|
||||
ImGuiDockContext="struct ImGuiDockContext",
|
||||
ImGuiDockNode="struct ImGuiDockNode",
|
||||
ImGuiDockNodeFlags="int",
|
||||
ImGuiDockNodeSettings="struct ImGuiDockNodeSettings",
|
||||
ImGuiDockRequest="struct ImGuiDockRequest",
|
||||
ImGuiDragDropFlags="int",
|
||||
ImGuiErrorCallback="void (*)(ImGuiContext* ctx, void* user_data, const char* msg);",
|
||||
ImGuiErrorRecoveryState="struct ImGuiErrorRecoveryState",
|
||||
ImGuiFocusRequestFlags="int",
|
||||
ImGuiFocusScopeData="struct ImGuiFocusScopeData",
|
||||
ImGuiFocusedFlags="int",
|
||||
ImGuiFreeTypeLoaderFlags="unsigned int",
|
||||
ImGuiGroupData="struct ImGuiGroupData",
|
||||
ImGuiHoveredFlags="int",
|
||||
ImGuiID="unsigned int",
|
||||
ImGuiIDStackTool="struct ImGuiIDStackTool",
|
||||
ImGuiIO="struct ImGuiIO",
|
||||
ImGuiInputEvent="struct ImGuiInputEvent",
|
||||
ImGuiInputEventAppFocused="struct ImGuiInputEventAppFocused",
|
||||
ImGuiInputEventKey="struct ImGuiInputEventKey",
|
||||
ImGuiInputEventMouseButton="struct ImGuiInputEventMouseButton",
|
||||
ImGuiInputEventMousePos="struct ImGuiInputEventMousePos",
|
||||
ImGuiInputEventMouseViewport="struct ImGuiInputEventMouseViewport",
|
||||
ImGuiInputEventMouseWheel="struct ImGuiInputEventMouseWheel",
|
||||
ImGuiInputEventText="struct ImGuiInputEventText",
|
||||
ImGuiInputFlags="int",
|
||||
ImGuiInputTextCallback="int (*)(ImGuiInputTextCallbackData* data);",
|
||||
ImGuiInputTextCallbackData="struct ImGuiInputTextCallbackData",
|
||||
ImGuiInputTextDeactivateData="struct ImGuiInputTextDeactivateData",
|
||||
ImGuiInputTextDeactivatedState="struct ImGuiInputTextDeactivatedState",
|
||||
ImGuiInputTextFlags="int",
|
||||
ImGuiInputTextState="struct ImGuiInputTextState",
|
||||
ImGuiItemFlags="int",
|
||||
ImGuiItemStatusFlags="int",
|
||||
ImGuiKeyChord="int",
|
||||
ImGuiKeyData="struct ImGuiKeyData",
|
||||
ImGuiKeyOwnerData="struct ImGuiKeyOwnerData",
|
||||
ImGuiKeyRoutingData="struct ImGuiKeyRoutingData",
|
||||
ImGuiKeyRoutingIndex="ImS16",
|
||||
ImGuiKeyRoutingTable="struct ImGuiKeyRoutingTable",
|
||||
ImGuiLastItemData="struct ImGuiLastItemData",
|
||||
ImGuiLayoutType="int",
|
||||
ImGuiListClipper="struct ImGuiListClipper",
|
||||
ImGuiListClipperData="struct ImGuiListClipperData",
|
||||
ImGuiListClipperRange="struct ImGuiListClipperRange",
|
||||
ImGuiLocEntry="struct ImGuiLocEntry",
|
||||
ImGuiLogFlags="int",
|
||||
ImGuiMemAllocFunc="void* (*)(size_t sz, void* user_data);",
|
||||
ImGuiMemFreeFunc="void (*)(void* ptr, void* user_data);",
|
||||
ImGuiMenuColumns="struct ImGuiMenuColumns",
|
||||
ImGuiMetricsConfig="struct ImGuiMetricsConfig",
|
||||
ImGuiMouseButton="int",
|
||||
ImGuiMouseCursor="int",
|
||||
ImGuiMultiSelectFlags="int",
|
||||
ImGuiMultiSelectIO="struct ImGuiMultiSelectIO",
|
||||
ImGuiMultiSelectState="struct ImGuiMultiSelectState",
|
||||
ImGuiMultiSelectTempData="struct ImGuiMultiSelectTempData",
|
||||
ImGuiNavItemData="struct ImGuiNavItemData",
|
||||
ImGuiNavMoveFlags="int",
|
||||
ImGuiNavRenderCursorFlags="int",
|
||||
ImGuiNextItemData="struct ImGuiNextItemData",
|
||||
ImGuiNextItemDataFlags="int",
|
||||
ImGuiNextWindowData="struct ImGuiNextWindowData",
|
||||
ImGuiNextWindowDataFlags="int",
|
||||
ImGuiOldColumnData="struct ImGuiOldColumnData",
|
||||
ImGuiOldColumnFlags="int",
|
||||
ImGuiOldColumns="struct ImGuiOldColumns",
|
||||
ImGuiOnceUponAFrame="struct ImGuiOnceUponAFrame",
|
||||
ImGuiPayload="struct ImGuiPayload",
|
||||
ImGuiPlatformIO="struct ImGuiPlatformIO",
|
||||
ImGuiPlatformImeData="struct ImGuiPlatformImeData",
|
||||
ImGuiPlatformMonitor="struct ImGuiPlatformMonitor",
|
||||
ImGuiPopupData="struct ImGuiPopupData",
|
||||
ImGuiPopupFlags="int",
|
||||
ImGuiPtrOrIndex="struct ImGuiPtrOrIndex",
|
||||
ImGuiScrollFlags="int",
|
||||
ImGuiSelectableFlags="int",
|
||||
ImGuiSelectionBasicStorage="struct ImGuiSelectionBasicStorage",
|
||||
ImGuiSelectionExternalStorage="struct ImGuiSelectionExternalStorage",
|
||||
ImGuiSelectionRequest="struct ImGuiSelectionRequest",
|
||||
ImGuiSelectionUserData="ImS64",
|
||||
ImGuiSeparatorFlags="int",
|
||||
ImGuiSettingsHandler="struct ImGuiSettingsHandler",
|
||||
ImGuiShrinkWidthItem="struct ImGuiShrinkWidthItem",
|
||||
ImGuiSizeCallback="void (*)(ImGuiSizeCallbackData* data);",
|
||||
ImGuiSizeCallbackData="struct ImGuiSizeCallbackData",
|
||||
ImGuiSliderFlags="int",
|
||||
ImGuiStackLevelInfo="struct ImGuiStackLevelInfo",
|
||||
ImGuiStorage="struct ImGuiStorage",
|
||||
ImGuiStoragePair="struct ImGuiStoragePair",
|
||||
ImGuiStyle="struct ImGuiStyle",
|
||||
ImGuiStyleMod="struct ImGuiStyleMod",
|
||||
ImGuiStyleVar="int",
|
||||
ImGuiStyleVarInfo="struct ImGuiStyleVarInfo",
|
||||
ImGuiTabBar="struct ImGuiTabBar",
|
||||
ImGuiTabBarFlags="int",
|
||||
ImGuiTabItem="struct ImGuiTabItem",
|
||||
ImGuiTabItemFlags="int",
|
||||
ImGuiTable="struct ImGuiTable",
|
||||
ImGuiTableBgTarget="int",
|
||||
ImGuiTableCellData="struct ImGuiTableCellData",
|
||||
ImGuiTableColumn="struct ImGuiTableColumn",
|
||||
ImGuiTableColumnFlags="int",
|
||||
ImGuiTableColumnIdx="ImS16",
|
||||
ImGuiTableColumnSettings="struct ImGuiTableColumnSettings",
|
||||
ImGuiTableColumnSortSpecs="struct ImGuiTableColumnSortSpecs",
|
||||
ImGuiTableColumnsSettings="struct ImGuiTableColumnsSettings",
|
||||
ImGuiTableDrawChannelIdx="ImU16",
|
||||
ImGuiTableFlags="int",
|
||||
ImGuiTableHeaderData="struct ImGuiTableHeaderData",
|
||||
ImGuiTableInstanceData="struct ImGuiTableInstanceData",
|
||||
ImGuiTableRowFlags="int",
|
||||
ImGuiTableSettings="struct ImGuiTableSettings",
|
||||
ImGuiTableSortSpecs="struct ImGuiTableSortSpecs",
|
||||
ImGuiTableTempData="struct ImGuiTableTempData",
|
||||
ImGuiTextBuffer="struct ImGuiTextBuffer",
|
||||
ImGuiTextFilter="struct ImGuiTextFilter",
|
||||
ImGuiTextFlags="int",
|
||||
ImGuiTextIndex="struct ImGuiTextIndex",
|
||||
ImGuiTextRange="struct ImGuiTextRange",
|
||||
ImGuiTooltipFlags="int",
|
||||
ImGuiTreeNodeFlags="int",
|
||||
ImGuiTreeNodeStackData="struct ImGuiTreeNodeStackData",
|
||||
ImGuiTypingSelectFlags="int",
|
||||
ImGuiTypingSelectRequest="struct ImGuiTypingSelectRequest",
|
||||
ImGuiTypingSelectState="struct ImGuiTypingSelectState",
|
||||
ImGuiViewport="struct ImGuiViewport",
|
||||
ImGuiViewportFlags="int",
|
||||
ImGuiViewportP="struct ImGuiViewportP",
|
||||
ImGuiWindow="struct ImGuiWindow",
|
||||
ImGuiWindowClass="struct ImGuiWindowClass",
|
||||
ImGuiWindowDockStyle="struct ImGuiWindowDockStyle",
|
||||
ImGuiWindowFlags="int",
|
||||
ImGuiWindowRefreshFlags="int",
|
||||
ImGuiWindowSettings="struct ImGuiWindowSettings",
|
||||
ImGuiWindowStackData="struct ImGuiWindowStackData",
|
||||
ImGuiWindowTempData="struct ImGuiWindowTempData",
|
||||
ImPoolIdx="int",
|
||||
ImRect="struct ImRect",
|
||||
ImS16="signed short",
|
||||
ImS32="signed int",
|
||||
ImS64="signed long long",
|
||||
ImS8="signed char",
|
||||
ImStbTexteditState="ImStb::STB_TexteditState",
|
||||
ImTextureData="struct ImTextureData",
|
||||
ImTextureID="ImU64",
|
||||
ImTextureRect="struct ImTextureRect",
|
||||
ImTextureRef="struct ImTextureRef",
|
||||
ImU16="unsigned short",
|
||||
ImU32="unsigned int",
|
||||
ImU64="unsigned long long",
|
||||
ImU8="unsigned char",
|
||||
ImVec1="struct ImVec1",
|
||||
ImVec2="struct ImVec2",
|
||||
ImVec2i="struct ImVec2i",
|
||||
ImVec2ih="struct ImVec2ih",
|
||||
ImVec4="struct ImVec4",
|
||||
ImWchar="ImWchar16",
|
||||
ImWchar16="unsigned short",
|
||||
ImWchar32="unsigned int",
|
||||
STB_TexteditState="struct STB_TexteditState",
|
||||
stbrp_context_opaque="struct stbrp_context_opaque",
|
||||
stbrp_node="struct stbrp_node",
|
||||
stbrp_node_im="stbrp_node"}
|
||||
return t
|
@@ -31,3 +31,7 @@
|
||||
#ifdef ImDrawCallback_ResetRenderState
|
||||
#pragma message(CIMGUI_DEFSTRING(ImDrawCallback_ResetRenderState))
|
||||
#endif
|
||||
|
||||
#ifdef IMGUI_HAS_TEXTURES
|
||||
#pragma message(CIMGUI_DEFSTRING(IMGUI_HAS_TEXTURES))
|
||||
#endif
|
2
imgui
2
imgui
Submodule imgui updated: 2db79d0868...44aa9a4b3a
@@ -11,6 +11,8 @@
|
||||
#define igDebugCheckVersionAndDataLayout igDebugCheckVersionAndDataLayout_Str
|
||||
#endif
|
||||
|
||||
#define igGetIO igGetIO_Nil
|
||||
|
||||
int main(void)
|
||||
{
|
||||
assert(igDebugCheckVersionAndDataLayout(igGetVersion(), sizeof(ImGuiIO), sizeof(ImGuiStyle),
|
||||
@@ -20,9 +22,10 @@ int main(void)
|
||||
igCreateContext(NULL);
|
||||
ImGuiIO *io = igGetIO();
|
||||
|
||||
unsigned char *text_pixels = NULL;
|
||||
int text_w, text_h;
|
||||
ImFontAtlas_GetTexDataAsRGBA32(io->Fonts, &text_pixels, &text_w, &text_h, NULL);
|
||||
// unsigned char *text_pixels = NULL;
|
||||
// int text_w, text_h;
|
||||
// ImFontAtlas_GetTexDataAsRGBA32(io->Fonts, &text_pixels, &text_w, &text_h, NULL);
|
||||
io->BackendFlags |= ImGuiBackendFlags_RendererHasTextures;
|
||||
|
||||
for (int n = 0; n < 20; n++) {
|
||||
printf("NewFrame() %d\n", n);
|
||||
|
Reference in New Issue
Block a user