|
|
@ -1,18 +1,7 @@ |
|
|
|
(import &comptime-only "Dependencies.cake" "CHelpers.cake") |
|
|
|
|
|
|
|
;; (c-import &with-decls "imgui.h") |
|
|
|
(c-import "imgui.h") |
|
|
|
|
|
|
|
(add-c-search-directory-module "Dependencies/imgui") |
|
|
|
(add-cpp-build-dependency "imgui.cpp" |
|
|
|
"imgui_draw.cpp" |
|
|
|
"imgui_tables.cpp" |
|
|
|
"imgui_widgets.cpp") |
|
|
|
|
|
|
|
(add-dependency-git-submodule clone-imgui "https://github.com/ocornut/imgui" |
|
|
|
"Dependencies/imgui" |
|
|
|
"docking") |
|
|
|
|
|
|
|
(defmacro imgui-call (function symbol &rest &optional arguments any) |
|
|
|
(if arguments |
|
|
|
(tokenize-push output |
|
|
@ -21,116 +10,6 @@ |
|
|
|
(call (in ImGui (token-splice function))))) |
|
|
|
(return true)) |
|
|
|
|
|
|
|
(defun imgui-set-style-red-dark () |
|
|
|
;; copied and modified from https://github.com/ocornut/imgui/issues/707 |
|
|
|
(var colors (* ImVec4) (field (imgui-call GetStyle) Colors)) |
|
|
|
(set (at ImGuiCol_Text colors) (ImVec4 0.75f 0.75f 0.75f 1.00f)) |
|
|
|
(set (at ImGuiCol_TextDisabled colors) (ImVec4 0.35f 0.35f 0.35f 1.00f)) |
|
|
|
(set (at ImGuiCol_WindowBg colors) (ImVec4 0.00f 0.00f 0.00f 0.94f)) |
|
|
|
(set (at ImGuiCol_ChildBg colors) (ImVec4 0.00f 0.00f 0.00f 0.00f)) |
|
|
|
(set (at ImGuiCol_PopupBg colors) (ImVec4 0.08f 0.08f 0.08f 0.94f)) |
|
|
|
(set (at ImGuiCol_Border colors) (ImVec4 0.00f 0.00f 0.00f 0.50f)) |
|
|
|
(set (at ImGuiCol_BorderShadow colors) (ImVec4 0.00f 0.00f 0.00f 0.00f)) |
|
|
|
(set (at ImGuiCol_FrameBg colors) (ImVec4 0.25f 0.25f 0.25f 0.54f)) |
|
|
|
(set (at ImGuiCol_FrameBgHovered colors) (ImVec4 0.37f 0.14f 0.14f 0.67f)) |
|
|
|
(set (at ImGuiCol_FrameBgActive colors) (ImVec4 0.39f 0.20f 0.20f 0.67f)) |
|
|
|
(set (at ImGuiCol_TitleBg colors) (ImVec4 0.04f 0.04f 0.04f 1.00f)) |
|
|
|
(set (at ImGuiCol_TitleBgActive colors) (ImVec4 0.48f 0.16f 0.16f 1.00f)) |
|
|
|
(set (at ImGuiCol_TitleBgCollapsed colors) (ImVec4 0.48f 0.16f 0.16f 1.00f)) |
|
|
|
(set (at ImGuiCol_MenuBarBg colors) (ImVec4 0.14f 0.14f 0.14f 1.00f)) |
|
|
|
(set (at ImGuiCol_ScrollbarBg colors) (ImVec4 0.02f 0.02f 0.02f 0.53f)) |
|
|
|
(set (at ImGuiCol_ScrollbarGrab colors) (ImVec4 0.31f 0.31f 0.31f 1.00f)) |
|
|
|
(set (at ImGuiCol_ScrollbarGrabHovered colors) (ImVec4 0.41f 0.41f 0.41f 1.00f)) |
|
|
|
(set (at ImGuiCol_ScrollbarGrabActive colors) (ImVec4 0.51f 0.51f 0.51f 1.00f)) |
|
|
|
(set (at ImGuiCol_CheckMark colors) (ImVec4 0.56f 0.10f 0.10f 1.00f)) |
|
|
|
(set (at ImGuiCol_SliderGrab colors) (ImVec4 1.00f 0.19f 0.19f 0.40f)) |
|
|
|
(set (at ImGuiCol_SliderGrabActive colors) (ImVec4 0.89f 0.00f 0.19f 1.00f)) |
|
|
|
(set (at ImGuiCol_Button colors) (ImVec4 1.00f 0.19f 0.19f 0.40f)) |
|
|
|
(set (at ImGuiCol_ButtonHovered colors) (ImVec4 0.80f 0.17f 0.00f 1.00f)) |
|
|
|
(set (at ImGuiCol_ButtonActive colors) (ImVec4 0.89f 0.00f 0.19f 1.00f)) |
|
|
|
(set (at ImGuiCol_Header colors) (ImVec4 0.33f 0.35f 0.36f 0.53f)) |
|
|
|
(set (at ImGuiCol_HeaderHovered colors) (ImVec4 0.76f 0.28f 0.44f 0.67f)) |
|
|
|
(set (at ImGuiCol_HeaderActive colors) (ImVec4 0.47f 0.47f 0.47f 0.67f)) |
|
|
|
(set (at ImGuiCol_Separator colors) (ImVec4 0.32f 0.32f 0.32f 1.00f)) |
|
|
|
(set (at ImGuiCol_SeparatorHovered colors) (ImVec4 0.32f 0.32f 0.32f 1.00f)) |
|
|
|
(set (at ImGuiCol_SeparatorActive colors) (ImVec4 0.32f 0.32f 0.32f 1.00f)) |
|
|
|
(set (at ImGuiCol_ResizeGrip colors) (ImVec4 1.00f 1.00f 1.00f 0.85f)) |
|
|
|
(set (at ImGuiCol_ResizeGripHovered colors) (ImVec4 1.00f 1.00f 1.00f 0.60f)) |
|
|
|
(set (at ImGuiCol_ResizeGripActive colors) (ImVec4 1.00f 1.00f 1.00f 0.90f)) |
|
|
|
(set (at ImGuiCol_Tab colors) (ImVec4 0.07f 0.07f 0.07f 0.51f)) |
|
|
|
(set (at ImGuiCol_TabHovered colors) (ImVec4 0.86f 0.23f 0.43f 0.67f)) |
|
|
|
(set (at ImGuiCol_TabActive colors) (ImVec4 0.19f 0.19f 0.19f 0.57f)) |
|
|
|
(set (at ImGuiCol_TabUnfocused colors) (ImVec4 0.05f 0.05f 0.05f 0.90f)) |
|
|
|
(set (at ImGuiCol_TabUnfocusedActive colors) (ImVec4 0.13f 0.13f 0.13f 0.74f)) |
|
|
|
(set (at ImGuiCol_DockingPreview colors) (ImVec4 0.47f 0.47f 0.47f 0.47f)) |
|
|
|
(set (at ImGuiCol_DockingEmptyBg colors) (ImVec4 0.20f 0.20f 0.20f 1.00f)) |
|
|
|
(set (at ImGuiCol_PlotLines colors) (ImVec4 0.61f 0.61f 0.61f 1.00f)) |
|
|
|
(set (at ImGuiCol_PlotLinesHovered colors) (ImVec4 1.00f 0.43f 0.35f 1.00f)) |
|
|
|
(set (at ImGuiCol_PlotHistogram colors) (ImVec4 0.90f 0.70f 0.00f 1.00f)) |
|
|
|
(set (at ImGuiCol_PlotHistogramHovered colors) (ImVec4 1.00f 0.60f 0.00f 1.00f)) |
|
|
|
(set (at ImGuiCol_TableHeaderBg colors) (ImVec4 0.19f 0.19f 0.20f 1.00f)) |
|
|
|
(set (at ImGuiCol_TableBorderStrong colors) (ImVec4 0.31f 0.31f 0.35f 1.00f)) |
|
|
|
(set (at ImGuiCol_TableBorderLight colors) (ImVec4 0.23f 0.23f 0.25f 1.00f)) |
|
|
|
(set (at ImGuiCol_TableRowBg colors) (ImVec4 0.00f 0.00f 0.00f 0.00f)) |
|
|
|
(set (at ImGuiCol_TableRowBgAlt colors) (ImVec4 1.00f 1.00f 1.00f 0.07f)) |
|
|
|
(set (at ImGuiCol_TextSelectedBg colors) (ImVec4 0.26f 0.59f 0.98f 0.35f)) |
|
|
|
(set (at ImGuiCol_DragDropTarget colors) (ImVec4 1.00f 1.00f 0.00f 0.90f)) |
|
|
|
(set (at ImGuiCol_NavHighlight colors) (ImVec4 0.26f 0.59f 0.98f 1.00f)) |
|
|
|
(set (at ImGuiCol_NavWindowingHighlight colors) (ImVec4 1.00f 1.00f 1.00f 0.70f)) |
|
|
|
(set (at ImGuiCol_NavWindowingDimBg colors) (ImVec4 0.80f 0.80f 0.80f 0.20f)) |
|
|
|
(set (at ImGuiCol_ModalWindowDimBg colors) (ImVec4 0.80f 0.80f 0.80f 0.35f))) |
|
|
|
|
|
|
|
(comptime-cond |
|
|
|
('auto-test |
|
|
|
(imgui-use-sdl-gl3) |
|
|
|
|
|
|
|
(c-import "<cstdio>") |
|
|
|
|
|
|
|
(make-imgui-sdl-gl3-application ;; If you want your own entry point, check this macro's body |
|
|
|
test--imgui-main |
|
|
|
"GameLib ImGui test" |
|
|
|
(scope (fprintf stderr "Initializing\n")) ;; Initialization |
|
|
|
(scope ;; Once per frame |
|
|
|
(imgui-call ShowDemoWindow)) |
|
|
|
(scope (fprintf stderr "Shut down\n"))))) ;; Shutdown |
|
|
|
|
|
|
|
;; Different loaders are available. Loader selection is done via macro to allow that flexibility |
|
|
|
(defmacro imgui-use-sdl-gl3 () |
|
|
|
(tokenize-push output |
|
|
|
(import "OpenGL.cake") |
|
|
|
(import "SDL.cake") |
|
|
|
(c-import "SDL.h" |
|
|
|
"imgui_impl_sdl.h" ;; Platform (inputs etc.) |
|
|
|
"imgui_impl_opengl3.h") ;; Rendering |
|
|
|
;; From ImGuiSDLOpenGL.cpp |
|
|
|
(declare-extern-function ImGuiSDLOpenGL_SetAttributes (glsl-version (* (* (const char))))) |
|
|
|
(declare-extern-function ImGuiSDLOpenGL_InitializeGLLoader (&return bool)) |
|
|
|
(declare-extern-function ImGuiSDLOpenGL_ClearWindow (io (* ImGuiIO) clear-color ImVec4)) |
|
|
|
|
|
|
|
;; TODO This is a hack: add build output dir as search directory. Should be built in? |
|
|
|
(defun-comptime add-search-build-directory (manager (& ModuleManager) module (* Module) |
|
|
|
&return bool) |
|
|
|
(call-on push_back (path module > cSearchDirectories) |
|
|
|
(call-on c_str (field manager buildOutputDir))) |
|
|
|
(return true)) |
|
|
|
(add-compile-time-hook-module pre-build add-search-build-directory) |
|
|
|
|
|
|
|
(add-c-search-directory-module |
|
|
|
"Dependencies/gamelib/src" |
|
|
|
"Dependencies/imgui" |
|
|
|
"Dependencies/imgui/backends") |
|
|
|
(add-cpp-build-dependency "imgui_demo.cpp" "imgui_impl_sdl.cpp" |
|
|
|
"ImGuiSDLOpenGL.cpp" "imgui_impl_opengl3.cpp") |
|
|
|
|
|
|
|
(comptime-cond |
|
|
|
('Unix |
|
|
|
(add-library-dependency "GL" "dl")) |
|
|
|
('Windows |
|
|
|
(add-linker-options "opengl32.lib"))) |
|
|
|
|
|
|
|
(module-use-sdl-build-options)) |
|
|
|
(return true)) |
|
|
|
|
|
|
|
;; When you just don't care about the details and want a ImGui window |
|
|
|
(defmacro make-imgui-sdl-gl3-application (entry-point-name symbol |
|
|
|
window-name string |
|
|
@ -269,3 +148,124 @@ |
|
|
|
(sdl-shutdown window) |
|
|
|
(return 0))) |
|
|
|
(return true)) |
|
|
|
|
|
|
|
(defun imgui-set-style-red-dark () |
|
|
|
;; copied and modified from https://github.com/ocornut/imgui/issues/707 |
|
|
|
(var colors (* ImVec4) (field (imgui-call GetStyle) Colors)) |
|
|
|
(set (at ImGuiCol_Text colors) (ImVec4 0.75f 0.75f 0.75f 1.00f)) |
|
|
|
(set (at ImGuiCol_TextDisabled colors) (ImVec4 0.35f 0.35f 0.35f 1.00f)) |
|
|
|
(set (at ImGuiCol_WindowBg colors) (ImVec4 0.00f 0.00f 0.00f 0.94f)) |
|
|
|
(set (at ImGuiCol_ChildBg colors) (ImVec4 0.00f 0.00f 0.00f 0.00f)) |
|
|
|
(set (at ImGuiCol_PopupBg colors) (ImVec4 0.08f 0.08f 0.08f 0.94f)) |
|
|
|
(set (at ImGuiCol_Border colors) (ImVec4 0.00f 0.00f 0.00f 0.50f)) |
|
|
|
(set (at ImGuiCol_BorderShadow colors) (ImVec4 0.00f 0.00f 0.00f 0.00f)) |
|
|
|
(set (at ImGuiCol_FrameBg colors) (ImVec4 0.25f 0.25f 0.25f 0.54f)) |
|
|
|
(set (at ImGuiCol_FrameBgHovered colors) (ImVec4 0.37f 0.14f 0.14f 0.67f)) |
|
|
|
(set (at ImGuiCol_FrameBgActive colors) (ImVec4 0.39f 0.20f 0.20f 0.67f)) |
|
|
|
(set (at ImGuiCol_TitleBg colors) (ImVec4 0.04f 0.04f 0.04f 1.00f)) |
|
|
|
(set (at ImGuiCol_TitleBgActive colors) (ImVec4 0.48f 0.16f 0.16f 1.00f)) |
|
|
|
(set (at ImGuiCol_TitleBgCollapsed colors) (ImVec4 0.48f 0.16f 0.16f 1.00f)) |
|
|
|
(set (at ImGuiCol_MenuBarBg colors) (ImVec4 0.14f 0.14f 0.14f 1.00f)) |
|
|
|
(set (at ImGuiCol_ScrollbarBg colors) (ImVec4 0.02f 0.02f 0.02f 0.53f)) |
|
|
|
(set (at ImGuiCol_ScrollbarGrab colors) (ImVec4 0.31f 0.31f 0.31f 1.00f)) |
|
|
|
(set (at ImGuiCol_ScrollbarGrabHovered colors) (ImVec4 0.41f 0.41f 0.41f 1.00f)) |
|
|
|
(set (at ImGuiCol_ScrollbarGrabActive colors) (ImVec4 0.51f 0.51f 0.51f 1.00f)) |
|
|
|
(set (at ImGuiCol_CheckMark colors) (ImVec4 0.56f 0.10f 0.10f 1.00f)) |
|
|
|
(set (at ImGuiCol_SliderGrab colors) (ImVec4 1.00f 0.19f 0.19f 0.40f)) |
|
|
|
(set (at ImGuiCol_SliderGrabActive colors) (ImVec4 0.89f 0.00f 0.19f 1.00f)) |
|
|
|
(set (at ImGuiCol_Button colors) (ImVec4 1.00f 0.19f 0.19f 0.40f)) |
|
|
|
(set (at ImGuiCol_ButtonHovered colors) (ImVec4 0.80f 0.17f 0.00f 1.00f)) |
|
|
|
(set (at ImGuiCol_ButtonActive colors) (ImVec4 0.89f 0.00f 0.19f 1.00f)) |
|
|
|
(set (at ImGuiCol_Header colors) (ImVec4 0.33f 0.35f 0.36f 0.53f)) |
|
|
|
(set (at ImGuiCol_HeaderHovered colors) (ImVec4 0.76f 0.28f 0.44f 0.67f)) |
|
|
|
(set (at ImGuiCol_HeaderActive colors) (ImVec4 0.47f 0.47f 0.47f 0.67f)) |
|
|
|
(set (at ImGuiCol_Separator colors) (ImVec4 0.32f 0.32f 0.32f 1.00f)) |
|
|
|
(set (at ImGuiCol_SeparatorHovered colors) (ImVec4 0.32f 0.32f 0.32f 1.00f)) |
|
|
|
(set (at ImGuiCol_SeparatorActive colors) (ImVec4 0.32f 0.32f 0.32f 1.00f)) |
|
|
|
(set (at ImGuiCol_ResizeGrip colors) (ImVec4 1.00f 1.00f 1.00f 0.85f)) |
|
|
|
(set (at ImGuiCol_ResizeGripHovered colors) (ImVec4 1.00f 1.00f 1.00f 0.60f)) |
|
|
|
(set (at ImGuiCol_ResizeGripActive colors) (ImVec4 1.00f 1.00f 1.00f 0.90f)) |
|
|
|
(set (at ImGuiCol_Tab colors) (ImVec4 0.07f 0.07f 0.07f 0.51f)) |
|
|
|
(set (at ImGuiCol_TabHovered colors) (ImVec4 0.86f 0.23f 0.43f 0.67f)) |
|
|
|
(set (at ImGuiCol_TabActive colors) (ImVec4 0.19f 0.19f 0.19f 0.57f)) |
|
|
|
(set (at ImGuiCol_TabUnfocused colors) (ImVec4 0.05f 0.05f 0.05f 0.90f)) |
|
|
|
(set (at ImGuiCol_TabUnfocusedActive colors) (ImVec4 0.13f 0.13f 0.13f 0.74f)) |
|
|
|
(set (at ImGuiCol_DockingPreview colors) (ImVec4 0.47f 0.47f 0.47f 0.47f)) |
|
|
|
(set (at ImGuiCol_DockingEmptyBg colors) (ImVec4 0.20f 0.20f 0.20f 1.00f)) |
|
|
|
(set (at ImGuiCol_PlotLines colors) (ImVec4 0.61f 0.61f 0.61f 1.00f)) |
|
|
|
(set (at ImGuiCol_PlotLinesHovered colors) (ImVec4 1.00f 0.43f 0.35f 1.00f)) |
|
|
|
(set (at ImGuiCol_PlotHistogram colors) (ImVec4 0.90f 0.70f 0.00f 1.00f)) |
|
|
|
(set (at ImGuiCol_PlotHistogramHovered colors) (ImVec4 1.00f 0.60f 0.00f 1.00f)) |
|
|
|
(set (at ImGuiCol_TableHeaderBg colors) (ImVec4 0.19f 0.19f 0.20f 1.00f)) |
|
|
|
(set (at ImGuiCol_TableBorderStrong colors) (ImVec4 0.31f 0.31f 0.35f 1.00f)) |
|
|
|
(set (at ImGuiCol_TableBorderLight colors) (ImVec4 0.23f 0.23f 0.25f 1.00f)) |
|
|
|
(set (at ImGuiCol_TableRowBg colors) (ImVec4 0.00f 0.00f 0.00f 0.00f)) |
|
|
|
(set (at ImGuiCol_TableRowBgAlt colors) (ImVec4 1.00f 1.00f 1.00f 0.07f)) |
|
|
|
(set (at ImGuiCol_TextSelectedBg colors) (ImVec4 0.26f 0.59f 0.98f 0.35f)) |
|
|
|
(set (at ImGuiCol_DragDropTarget colors) (ImVec4 1.00f 1.00f 0.00f 0.90f)) |
|
|
|
(set (at ImGuiCol_NavHighlight colors) (ImVec4 0.26f 0.59f 0.98f 1.00f)) |
|
|
|
(set (at ImGuiCol_NavWindowingHighlight colors) (ImVec4 1.00f 1.00f 1.00f 0.70f)) |
|
|
|
(set (at ImGuiCol_NavWindowingDimBg colors) (ImVec4 0.80f 0.80f 0.80f 0.20f)) |
|
|
|
(set (at ImGuiCol_ModalWindowDimBg colors) (ImVec4 0.80f 0.80f 0.80f 0.35f))) |
|
|
|
|
|
|
|
;; |
|
|
|
;; Building |
|
|
|
;; |
|
|
|
|
|
|
|
(add-dependency-git-submodule clone-imgui "https://github.com/ocornut/imgui" |
|
|
|
"Dependencies/imgui" |
|
|
|
"docking") |
|
|
|
|
|
|
|
(export-and-evaluate |
|
|
|
;; Different loaders are available. Loader selection could be done via macro to allow that flexibility |
|
|
|
(import "OpenGL.cake") |
|
|
|
(import "SDL.cake") |
|
|
|
(c-import "SDL.h" |
|
|
|
"imgui_impl_sdl.h" ;; Platform (inputs etc.) |
|
|
|
"imgui_impl_opengl3.h") ;; Rendering |
|
|
|
;; From ImGuiSDLOpenGL.cpp |
|
|
|
(declare-extern-function ImGuiSDLOpenGL_SetAttributes (glsl-version (* (* (const char))))) |
|
|
|
(declare-extern-function ImGuiSDLOpenGL_InitializeGLLoader (&return bool)) |
|
|
|
(declare-extern-function ImGuiSDLOpenGL_ClearWindow (io (* ImGuiIO) clear-color ImVec4)) |
|
|
|
|
|
|
|
;; TODO This is a hack: add build output dir as search directory. Should be built in? |
|
|
|
(defun-comptime add-search-build-directory (manager (& ModuleManager) module (* Module) |
|
|
|
&return bool) |
|
|
|
(call-on push_back (path module > cSearchDirectories) |
|
|
|
(call-on c_str (field manager buildOutputDir))) |
|
|
|
(return true)) |
|
|
|
(add-compile-time-hook-module pre-build add-search-build-directory) |
|
|
|
|
|
|
|
(add-c-search-directory-module |
|
|
|
"Dependencies/gamelib/src" |
|
|
|
"Dependencies/imgui" |
|
|
|
"Dependencies/imgui/backends") |
|
|
|
(add-cpp-build-dependency "imgui_impl_sdl.cpp" "ImGuiSDLOpenGL.cpp" "imgui_impl_opengl3.cpp") |
|
|
|
|
|
|
|
(comptime-cond |
|
|
|
('Unix |
|
|
|
(add-library-dependency "GL" "dl")) |
|
|
|
('Windows |
|
|
|
(add-linker-options "opengl32.lib")))) |
|
|
|
|
|
|
|
(add-cpp-build-dependency "imgui.cpp" |
|
|
|
"imgui_demo.cpp" |
|
|
|
"imgui_draw.cpp" |
|
|
|
"imgui_tables.cpp" |
|
|
|
"imgui_widgets.cpp") |
|
|
|
|
|
|
|
;; |
|
|
|
;; Testing |
|
|
|
;; |
|
|
|
|
|
|
|
(comptime-cond |
|
|
|
('auto-test |
|
|
|
(c-import "<stdio.h>") |
|
|
|
|
|
|
|
(make-imgui-sdl-gl3-application ;; If you want your own entry point, check this macro's body |
|
|
|
test--imgui-main |
|
|
|
"GameLib ImGui test" |
|
|
|
(scope (fprintf stderr "Initializing\n")) ;; Initialization |
|
|
|
(scope ;; Once per frame |
|
|
|
(imgui-call ShowDemoWindow)) |
|
|
|
(scope (fprintf stderr "Shut down\n"))))) ;; Shutdown |
|
|
|