Skip to content

Commit

Permalink
Adding freetype capabilities to cimgui (#6)
Browse files Browse the repository at this point in the history
* Some initial freetype  work

* Added freetype

* Regenerated the bindings, added scripts to help with that, adjust output dir.

* Deleted unneeded dlls

* Moved where the DLLs live.
  • Loading branch information
playmer authored Oct 13, 2021
1 parent 10538fb commit 56a6ecc
Show file tree
Hide file tree
Showing 25 changed files with 493 additions and 878 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/.dub/
lib/
build/
build_x64/
build_x86/
.dub/
.vscode/

Expand All @@ -17,10 +19,6 @@ bindbc-imgui-test.exe
libbindbc-imgui.so
libbindbc-imgui.a

SDL2.dll
cimgui.dll
bindbc-imgui.lib
cimgui.dylib
imgui.ini

.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "deps/cimgui"]
path = deps/cimgui
url = https://github.com/Inochi2D/cimgui.git
[submodule "deps/freetype"]
path = deps/freetype
url = https://github.com/freetype/freetype.git
11 changes: 11 additions & 0 deletions BuildDependencies.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cd deps
mkdir build_x64
cd build_x64
cmake -G "Visual Studio 16 2019" -Ax64 ..
cmake --build . --config Release
cd ..
mkdir build_x86
cd build_x86
cmake -G "Visual Studio 16 2019" -AWin32 ..
cmake --build . --config Release
cd ../../
3 changes: 3 additions & 0 deletions CleanAndBuildDependencies.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rmdir /s /q deps\build

BuildDependencies.bat
2 changes: 2 additions & 0 deletions GenerateBindings.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GenerateCImGuiBindings.bat
GenerateDBindings.bat
4 changes: 4 additions & 0 deletions GenerateCImGuiBindings.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

cd ./deps/cimgui/generator
luajit ./generator.lua cl "internal freetype" glfw opengl3 opengl2 sdl
cd ../../../
1 change: 1 addition & 0 deletions GenerateDBindings.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rdmd ./generator/generator.d
Binary file added bindbc-imgui.lib
Binary file not shown.
51 changes: 44 additions & 7 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,59 @@ set(CMAKE_DEBUG_POSTFIX "")

add_subdirectory(SDL)

set(OutputDirectory ${CMAKE_CURRENT_LIST_DIR}/../lib)
# This needs to be augmented to detect ARM vs x86
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PlatformArchitecture x86_64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(PlatformArchitecture x86)
endif()

if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(PlatformFolder "win32")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(PlatformFolder "darwin")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(PlatformFolder "linux")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Android")
set(PlatformFolder "android")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(PlatformFolder "bsd")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "MSYS")
set(PlatformFolder "win32")
else ()
set(PlatformFolder "Unknown")
endif()

set(OutputDirectory ${CMAKE_CURRENT_LIST_DIR}/../libs/${PlatformArchitecture}/${PlatformFolder})

option(BUILD_SHARED_LIBS "Build shared instead of static libraries." ON)

add_subdirectory(freetype)

set(IMGUI_FREETYPE_IN_TREE "yes" CACHE STRING "freetype library is being build in-tree")
set(IMGUI_FREETYPE "yes" CACHE STRING "Build with freetype library")
set(IMGUI_SDL_IN_TREE "yes" CACHE STRING "SDL library is built in-tree")
set(IMGUI_SDL "yes" CACHE STRING "Build with SDL")
set(IMGUI_OPENGL3 "yes" CACHE STRING "Build with OpenGL3")
add_subdirectory(cimgui)

set_target_properties(cimgui PROPERTIES DEBUG_POSTFIX "")
set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX "")

set_target_properties(cimgui PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${aLibraryDirectory}
LIBRARY_OUTPUT_DIRECTORY ${aLibraryDirectory}
RUNTIME_OUTPUT_DIRECTORY ${OutputDirectory})
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})

set_target_properties(SDL2 PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})

set_target_properties(freetype PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})

set_target_properties(cimgui PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${OutputDirectory})

set_target_properties(SDL2 PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${OutputDirectory}
LIBRARY_OUTPUT_DIRECTORY ${OutputDirectory}
RUNTIME_OUTPUT_DIRECTORY ${OutputDirectory})
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${OutputDirectory})

set_target_properties(freetype PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${OutputDirectory})
1 change: 1 addition & 0 deletions deps/freetype
Submodule freetype added at 5d27b1
8 changes: 6 additions & 2 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ homepage ""
authors "Joshua T. Fisher" "Luna Nielsen"
license "Boost"

copyFiles "libs/x86_64/cimgui.dll" platform="windows-x86_64"
copyFiles "libs/x86_64/SDL2.dll" platform="windows-x86_64"
copyFiles "libs/x86_64/win32/cimgui.dll" platform="windows-x86_64"
copyFiles "libs/x86_64/win32/SDL2.dll" platform="windows-x86_64"
copyFiles "libs/x86_64/win32/freetype.dll" platform="windows-x86_64"
copyFiles "libs/x86/win32/cimgui.dll" platform="windows-x86"
copyFiles "libs/x86/win32/SDL2.dll" platform="windows-x86"
copyFiles "libs/x86/win32/freetype.dll" platform="windows-x86"
copyFiles "libs/arm64/cimgui.dylib" platform="osx-aarch64"
//copyFiles "libs/x86_64/imgui.ini"

Expand Down
4 changes: 3 additions & 1 deletion generator/generator.d
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ shared static this()
"signed short*": "short*",
"signed int*": "int*",
"int64_t" : "long",
"signed __int64" : "long",
"unsigned __int64" : "ulong",
"uint64_t" : "ulong",
"union { int BackupInt[2]; float BackupFloat[2];}": "union { int[2] BackupInt; float[2] BackupFloat;}",
"const char*" : "const(char)*",
Expand Down Expand Up @@ -94,7 +96,7 @@ shared static this()
"ImGui_ImplGlfw" :BackendData(
"ImGui_ImplGlfw",
"Glfw",
"import bindbc.sdl;",
"import bindbc.glfw;",
"USE_GLFW"
),
"ImGui_ImplOpenGL2" :BackendData(
Expand Down
Binary file added libs/x86/win32/SDL2.dll
Binary file not shown.
Binary file added libs/x86/win32/cimgui.dll
Binary file not shown.
Binary file added libs/x86/win32/freetype.dll
Binary file not shown.
Binary file removed libs/x86_64/cimgui.dll
Binary file not shown.
Empty file removed libs/x86_64/libs_go_here.txt
Empty file.
Binary file renamed libs/x86_64/SDL2.dll → libs/x86_64/win32/SDL2.dll
Binary file not shown.
Binary file added libs/x86_64/win32/cimgui.dll
Binary file not shown.
Binary file added libs/x86_64/win32/freetype.dll
Binary file not shown.
Loading

0 comments on commit 56a6ecc

Please sign in to comment.