Skip to content

Commit

Permalink
Begin ImGui Swift API, context creation, adding fonts.
Browse files Browse the repository at this point in the history
Signed-off-by: furby™ <[email protected]>
  • Loading branch information
furby-tm committed Oct 28, 2024
1 parent d2bc1e8 commit 54ec15a
Show file tree
Hide file tree
Showing 11 changed files with 318 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
.vscode
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[submodule "glfw"]
path = glfw
url = https://github.com/glfw/glfw.git
[submodule "freetype"]
path = freetype
url = https://github.com/the-swift-collective/freetype.git
[submodule "imgui-cxx"]
path = imgui-cxx
url = https://github.com/the-swift-collective/imgui-cxx.git
22 changes: 0 additions & 22 deletions .vscode/launch.json

This file was deleted.

8 changes: 4 additions & 4 deletions Bundler.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
format_version = 2

[apps.example_glfw_metal]
identifier = 'foundation.wabi.example_glfw_metal'
product = 'example_glfw_metal'
[apps.GLFWMetalApp]
identifier = 'foundation.wabi.GLFWMetalApp'
product = 'GLFWMetalApp'
version = '1.0.0'
category = 'public.app-category.graphics-design'

[apps.example_glfw_metal.plist]
[apps.GLFWMetalApp.plist]
commit = '$(COMMIT_HASH)'
242 changes: 235 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ let package = Package(
name: "glfw",
targets: ["glfw"]
),
.library(
name: "freetype",
targets: ["freetype"]
),
.library(
name: "backend_glfw",
targets: ["backend_glfw"]
),
.library(
name: "imgui_freetype",
targets: ["imgui_freetype"]
),
] + Arch.addPlatformProducts(),
targets: [
.target(
Expand All @@ -41,7 +49,10 @@ let package = Package(
"imgui_widgets.cpp",
"imgui.cpp",
],
publicHeadersPath: "."
publicHeadersPath: ".",
cxxSettings: [
.define("IMGUI_ENABLE_FREETYPE", to: "1")
]
),

.target(
Expand Down Expand Up @@ -74,6 +85,177 @@ let package = Package(
]
),

.target(
name: "freetype",
path: "freetype",
exclude: [
"builds",
"devel",
"docs",
"objs",
"subprojects",
"tests",
"src/svg/module.mk",
"src/svg/rules.mk",
"src/pcf/module.mk",
"src/pcf/rules.mk",
"src/type1/module.mk",
"src/type1/rules.mk",
"src/dlg/rules.mk",
"src/sdf/module.mk",
"src/sdf/rules.mk",
"src/cache/rules.mk",
"src/sfnt/module.mk",
"src/sfnt/rules.mk",
"src/winfonts/module.mk",
"src/winfonts/rules.mk",
"src/bdf/module.mk",
"src/bdf/rules.mk",
"src/smooth/module.mk",
"src/smooth/rules.mk",
"src/type42/module.mk",
"src/type42/rules.mk",
"src/cff/module.mk",
"src/cff/rules.mk",
"src/gzip/rules.mk",
"src/lzw/rules.mk",
"src/gxvalid/module.mk",
"src/gxvalid/rules.mk",
"src/psaux/module.mk",
"src/psaux/rules.mk",
"src/cid/module.mk",
"src/cid/rules.mk",
"src/pfr/module.mk",
"src/pfr/rules.mk",
"src/otvalid/module.mk",
"src/otvalid/rules.mk",
"src/autofit/module.mk",
"src/autofit/rules.mk",
"src/pshinter/module.mk",
"src/pshinter/rules.mk",
"src/truetype/module.mk",
"src/truetype/rules.mk",
"src/raster/module.mk",
"src/raster/rules.mk",
"src/psnames/module.mk",
"src/psnames/rules.mk",
"src/base/rules.mk",
"src/bzip2/rules.mk",
"src/tools",
"src/pcf/README",
"src/tools/ftrandom/README",
"src/bdf/README",
"src/gxvalid/README",
"src/gzip/patches/freetype-zlib.diff",
"src/base/ftver.rc",
"src/autofit/afblue.hin",
"src/autofit/afblue.dat",
"src/autofit/afblue.cin",
"src/gzip/README.freetype",
"src/autofit/afblue.c",
"src/autofit/afcjk.c",
"src/autofit/afdummy.c",
"src/autofit/afglobal.c",
"src/autofit/afhints.c",
"src/autofit/afindic.c",
"src/autofit/aflatin.c",
"src/autofit/afloader.c",
"src/autofit/afmodule.c",
"src/autofit/afranges.c",
"src/autofit/afshaper.c",
"src/base/ftadvanc.c",
"src/base/ftbdf.c",
"src/base/ftcid.c",
"src/base/ftfstype.c",
"src/base/ftgasp.c",
"src/base/ftgxval.c",
"src/base/ftotval.c",
"src/base/ftpatent.c",
"src/base/ftpfr.c",
"src/base/ftstroke.c",
"src/base/fttype1.c",
"src/base/ftwinfnt.c",
"src/base/ftcalc.c",
"src/base/ftcolor.c",
"src/base/ftdbgmem.c",
"src/base/fterrors.c",
"src/base/ftfntfmt.c",
"src/base/ftgloadr.c",
"src/base/fthash.c",
"src/base/ftlcdfil.c",
"src/base/ftmac.c",
"src/base/ftobjs.c",
"src/base/ftoutln.c",
"src/base/ftpsprop.c",
"src/base/ftrfork.c",
"src/base/ftsnames.c",
"src/base/ftstream.c",
"src/base/fttrigon.c",
"src/base/ftutil.c",
"src/sdf/ftsdfrend.c",
"src/sdf/ftsdfcommon.c",
"src/sdf/ftbsdf.c",
"src/sdf/ftsdf.c",
"src/smooth/ftgrays.c",
"src/smooth/ftsmooth.c",
"src/psnames/psmodule.c",
"src/psaux/afmparse.c",
"src/psaux/psauxmod.c",
"src/psaux/t1cmap.c",
"src/truetype/ttdriver.c",
"src/pshinter/pshalgo.c",
"src/cache/ftcbasic.c",
"src/cache/ftcsbits.c",
"src/cache/ftcimage.c",
"src/cache/ftcglyph.c",
"src/cache/ftccmap.c",
"src/svg/ftsvg.c",
"src/raster/ftrend1.c",
"src/type42/t42drivr.c",
"src/truetype/ttdriver.c",
"src/sfnt/sfdriver.c",
"src/cff/cffdrivr.c",
"src/lzw/ftzopen.c",
"src/pshinter/pshmod.c",
"src/sfnt/pngshim.c",
"src/sfnt/sfobjs.c",
"src/sfnt/sfwoff.c",
"src/sfnt/sfwoff2.c",
"src/sfnt/ttbdf.c",
"src/sfnt/ttcolr.c",
"src/sfnt/ttcpal.c",
"src/sfnt/ttsvg.c",
"src/sfnt/ttgpos.c",
"src/sfnt/ttkern.c",
"src/sfnt/ttload.c",
"src/sfnt/ttsbit.c",
"src/sfnt/woff2tags.c",
"src/bdf/bdfdrivr.c",
"src/pfr/pfrdrivr.c",
"src/cid/cidriver.c",
"src/gxvalid/gxvmod.c",
"src/otvalid/otvmod.c",
"src/raster/ftrend1.c",
"src/cff/cffdrivr.c",
"src/cff/cffcmap.c",
"src/pfr/pfrcmap.c",
"src/pcf/pcfdrivr.c",
"src/sfnt/ttcmap.c",
"src/truetype/ttdriver.c",
"src/raster/ftraster.c",
"src/type1/t1driver.c",
"src/gxvalid/gxvfgen.c"
],
sources: [
"src"
],
publicHeadersPath: "include",
cSettings: [
.headerSearchPath("src"),
.define("FT_USE_AUTOFIT", to: "1")
]
),

.target(
name: "backend_glfw",
dependencies: [
Expand All @@ -87,10 +269,33 @@ let package = Package(
publicHeadersPath: "."
),

.target(
name: "imgui_freetype",
dependencies: [
.target(name: "imgui_cxx"),
.target(name: "freetype")
],
path: "imgui-cxx",
exclude: [
"misc/freetype/README.md"
],
sources: [
"misc/freetype"
],
publicHeadersPath: ".",
cxxSettings: [
.headerSearchPath("misc/freetype")
]
),

.target(
name: "ImGui",
dependencies: [
.target(name: "imgui_cxx")
.target(name: "imgui_cxx"),
.target(name: "imgui_freetype")
],
cxxSettings: [
.define("IMGUI_ENABLE_FREETYPE", to: "1"),
],
swiftSettings: [
.interoperabilityMode(.Cxx)
Expand All @@ -100,6 +305,9 @@ let package = Package(
.testTarget(
name: "ImGuiTests",
dependencies: ["ImGui"],
cxxSettings: [
.define("IMGUI_ENABLE_FREETYPE", to: "1"),
],
swiftSettings: [
.interoperabilityMode(.Cxx)
]
Expand Down Expand Up @@ -166,10 +374,14 @@ enum Arch {
name: "backend_metal",
targets: ["backend_metal"]
),
.executable(
.library(
name: "example_glfw_metal",
targets: ["example_glfw_metal"]
),
.executable(
name: "GLFWMetalApp",
targets: ["GLFWMetalApp"]
)
]
#else
[
Expand All @@ -184,7 +396,7 @@ enum Arch {
.target(
name: "backend_metal",
dependencies: [
.target(name: "imgui_cxx")
.target(name: "ImGui")
],
path: "imgui-cxx/backends",
sources: [
Expand All @@ -193,17 +405,33 @@ enum Arch {
publicHeadersPath: "."
),

.executableTarget(
.target(
name: "example_glfw_metal",
dependencies: [
.target(name: "imgui_cxx"),
.target(name: "ImGui"),
.target(name: "backend_glfw"),
.target(
name: "backend_metal",
condition: .when(platforms: [.macOS, .iOS, .visionOS, .tvOS, .watchOS])),
],
path: "imgui-cxx/examples/example_glfw_metal"
path: "imgui-cxx/examples/example_glfw_metal",
cxxSettings: [
.define("IMGUI_ENABLE_FREETYPE", to: "1"),
]
),

.executableTarget(
name: "GLFWMetalApp",
dependencies: [
.target(name: "example_glfw_metal")
],
resources: [
.copy("Resources/fonts")
],
swiftSettings: [
.interoperabilityMode(.Cxx)
]
)
]
#else
[
Expand Down
Loading

0 comments on commit 54ec15a

Please sign in to comment.