diff --git a/README.md b/README.md index 2c2a1ef..289f2e1 100644 --- a/README.md +++ b/README.md @@ -56,11 +56,25 @@ ImGui/CimGui version **1.91.3dock** (2024/10) --- -- Windows10 OS or later -- Linux Mint 22 (Ubuntu/Debian families ?): Work in progress. -- Now using zig-windows-x86_64-0.14.0-dev.1743 +- Zig version +Now using zig-windows-x86_64-0.14.0-dev.1743 Probably [zig-windows-x86_64-0.14.0-dev.xxxx+yyyy...](https://ziglang.org/download/) might be ok. (-:) -- MSys2/MinGW basic commands (make, rm, cp, strip ...) +- WindowsOS + - Windows10 or later + - MSys2/MinGW basic commands (make, rm, cp, strip ...) +- Linux OS +Linux Mint 22 (or Ubuntu/Debian families ?) + + ```sh + $ sudo apt install xorg-dev libopengl-dev libgl1-mesa-dev + ``` + + and for glfw3 and sdl2, + + ```sh + $ sudo apt install libglfw3 libglfw3-dev + $ sudo apt install libsdl2-dev + ``` ## Build and run @@ -80,13 +94,7 @@ Probably [zig-windows-x86_64-0.14.0-dev.xxxx+yyyy...](https://ziglang.org/downlo 1. Build and Run ```sh - make run - ``` - - or - - ```sh - zig build --release=fast run + make run # or zig build --release=fast run ``` ## Examples screen shots @@ -240,11 +248,17 @@ https://github.com/JBetz/build-sdl3-win32 --- -- Make: GNU Make 4.4.1 -- Zig: 0.14.0.dev -- SDL2 ver.2.30.8 -- SDL3 3.1.3 -- Git version 2.46.0.windows.1 +- Windows11 (main) + - Zig: 0.14.0.dev + - Make: GNU Make 4.4.1 + - SDL2 ver.2.30.8 + - SDL3 3.1.3 + - Git version 2.46.0.windows.1 +- Linux Mint 22 (sub) + - Zig: 0.14.0-dev.1831+ce5a5c361 + - Make: GNU Make 4.3 + - SDL2 ver.2.30.0 + - Git version 2.43.0 ## Similar project diff --git a/examples/makefile.common.mk b/examples/makefile.common.mk index 69512f4..5013022 100644 --- a/examples/makefile.common.mk +++ b/examples/makefile.common.mk @@ -1,6 +1,7 @@ +# Use zig-0.14.0 # Use zig-0.12.0 # by dinau (2024/06) -# + # #OPT += --release=fast #OPT += --release=small @@ -14,7 +15,7 @@ all: .PHONY: run gen cleanall cleanexe trans run: all - (cd $(ZIG_BIN_DIR); ./$(TARGET).exe) + (cd $(ZIG_BIN_DIR); ./$(TARGET)$(EXE)) cp $(ZIG_BIN_DIR)/imgui.ini . gen: diff --git a/examples/sdl2_opengl3/build.zig b/examples/sdl2_opengl3/build.zig index 94d07a7..5a70510 100644 --- a/examples/sdl2_opengl3/build.zig +++ b/examples/sdl2_opengl3/build.zig @@ -53,7 +53,16 @@ pub fn build(b: *std.Build) void { //--------------- // [imlibs] --- Include paths //--------------- - imlibs.addIncludePath(b.path(b.pathJoin(&.{sdl2_path, "include/SDL2"}))); + // + if (builtin.target.os.tag == .windows){ + imlibs.addIncludePath(b.path(b.pathJoin(&.{sdl2_path, "include/SDL2"}))); + }else if (builtin.target.os.tag == .linux){ + const sdl2_inc_path: std.Build.LazyPath = .{ + .cwd_relative = "/usr/include/SDL2" + }; + imlibs.addIncludePath(sdl2_inc_path); + } + // ImGui/CImGui imlibs.addIncludePath(b.path("../../libs/cimgui/imgui")); imlibs.addIncludePath(b.path("../../libs/cimgui/imgui/backends")); @@ -161,7 +170,7 @@ pub fn build(b: *std.Build) void { }else if (builtin.target.os.tag == .linux){ exe.linkSystemLibrary("glfw3"); exe.linkSystemLibrary("GL"); - exe.linkSystemLibrary("SDL2"); + exe.linkSystemLibrary("sdl2"); } // sdl2 diff --git a/examples/utils/compile_flags.txt b/examples/utils/compile_flags.txt new file mode 100644 index 0000000..fc08dd3 --- /dev/null +++ b/examples/utils/compile_flags.txt @@ -0,0 +1,41 @@ +-I./ +-I./fonticon +-I../../libs/sdl/SDL2-2.30.3/i686-w64-mingw32/include/SDL2 +-I../../libs/sdl/sdl3/32/SDL3-2024-06-02/SDL3/include +-I../../libs/cimplot +-I../../libs/cimplot/implot +-I../../libs/cimgui +-I../../libs/cimgui/imgui + +-Wno-stringop-overflow +-DCIMGUI_USE_GLFW +-DCIMGUI_USE_OPENGL3 +-I../../libs/glfw/glfw-3.3.9.bin.WIN32/include +-I../../libs/glfw/glfw-3.3.9.bin.WIN64/include +-static +-Wall +-Wno-unused-function +-O2 +-Ilibs/cimgui +-I../../libs/imgui +-I. +-I../../libs/imgui/backends +-Iutils +-Iutils/fonticon +-I../../libs/stb +-DCIMGUI_DEFINE_ENUMS_AND_STRUCTS +-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1 +-DImDrawIdx=unsigned int +-DIMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS +-fno-exceptions +-fno-rtti +-std=c++11 + + +# See +# clangdで別ディレクトリのヘッダーを指定したい +# https://qiita.com/sudo00/items/99d9619de38574830f65 +# +# Compiledb +# https://github.com/nickdiego/compiledb +# $ compiledb make diff --git a/examples/utils/setupFonts.c b/examples/utils/setupFonts.c index 78d4730..e2883b6 100644 --- a/examples/utils/setupFonts.c +++ b/examples/utils/setupFonts.c @@ -11,18 +11,24 @@ #define ImGui_GetIO igGetIO const char* IconFontPath = "../utils/fonticon/fa6/fa-solid-900.ttf"; -const char* JpFontName = "meiryo.ttc"; char sBufFontPath[2048]; /*----------------- * getFontPath() *----------------*/ -char* getFontPath(char* sBuf, int bufSize, const char* fontName) { +const char* WinJpFontName = "meiryo.ttc"; + +char* getWinFontPath(char* sBuf, int bufSize, const char* fontName) { char* sWinDir = getenv("windir"); if (sWinDir == NULL) return NULL; snprintf(sBuf, bufSize, "%s\\Fonts\\%s", sWinDir, fontName); return sBuf; } +/*----------------- + * getLinuxFontPath() + *----------------*/ +// For Linux Mint 22 (Ubuntu/Debian family ok ?) +char* LinuxJpFontName = "/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc"; // ,"Noto Sans CJK",12.0) # Linux Mint /*------------ * point2px() @@ -35,7 +41,7 @@ float point2px(float point) { const ImFontConfig config = {.FontDataOwnedByAtlas = true , .FontNo = 0 , .OversampleH = 3 - , .OversampleV = 1 + , .OversampleV = 2 , .PixelSnapH = false , .GlyphMaxAdvanceX = FLT_MAX , .RasterizerMultiply = 1.0 @@ -49,12 +55,19 @@ const ImWchar ranges_icon_fonts[] = {(ImWchar)ICON_MIN_FA, (ImWchar)ICON_MAX_FA void setupFonts(void) { ImGuiIO* pio = ImGui_GetIO(); ImFontAtlas_AddFontDefault(pio->Fonts, NULL); - ImFontAtlas_AddFontFromFileTTF(pio->Fonts, IconFontPath, point2px(10), &config - , ranges_icon_fonts); - char* fontPath = getFontPath(sBufFontPath, sizeof(sBufFontPath), JpFontName); - if (false == existsFile(fontPath)) { - printf("Error!: Not found JpFontPath: [%s] in %s\n", fontPath, __FILE__); - return; + ImFontAtlas_AddFontFromFileTTF(pio->Fonts, IconFontPath, point2px(10), &config , ranges_icon_fonts); + + char* fontPath = getWinFontPath(sBufFontPath, sizeof(sBufFontPath), WinJpFontName); + if (existsFile(fontPath)) { + // ok + }else{ + fontPath = LinuxJpFontName; + if (existsFile(LinuxJpFontName)) { + // ok + }else{ + printf("Error!: Not found FontPath: [%s] in %s\n", fontPath, __FILE__); + return; + } } printf("Found JpFontPath: [%s]\n",fontPath);