diff --git a/README.md b/README.md new file mode 100644 index 0000000..102b539 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +build either with `build.cmd Debug` or `build.cmd Release` +Run `build_imgui_lib.cmd` to build imgui dependency +Both scripts must be run in x64 Native Tools Command Prompt for VS 20xx. + +You can also build with `jai build.jai - build_exe` or `jai build.jai - build_exe release` diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000..cc8d037 --- /dev/null +++ b/build.cmd @@ -0,0 +1,56 @@ +@echo off +setlocal enabledelayedexpansion + +if "%~1"=="" ( + echo Usage: build.cmd [Debug^|Release] + exit /b 1 +) + +set CONFIG=%~1 + +if /I "%CONFIG%"=="Debug" ( + set CFLAGS=/MDd /Od /Zi /DDEBUG /DEBUG -diagnostics:caret -diagnostics:column -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING -D_CRT_NONSTDC_NO_DEPRECATE -D_USE_MATH_DEFINES + set LIB_PATH=bin + set IMGUI_LIB_PATH=bin\Debug\dear-imgui.lib +) else if /I "%CONFIG%"=="Release" ( + set CFLAGS=/MD /O2 /DNDEBUG + set LIB_PATH=bin + set IMGUI_LIB_PATH=bin\Release\dear-imgui.lib +) else ( + echo Invalid configuration: %CONFIG% + echo Usage: build.cmd [Debug^|Release] + exit /b 1 +) + +set OBJDIR=obj + +if not exist "%LIB_PATH%" mkdir "%LIB_PATH%" +if not exist obj mkdir obj + +set LIB_NAME=musa + +set SRC_FILES=^ + exe_main.cpp + +set INCLUDE_DIRS=^ + /Isrc ^ + /Ilib ^ + /Ilib\api ^ + /Ithird_party + +set LINK_LIBS=^ + %IMGUI_LIB_PATH% + +rem NOTE: it defaults to C++11, so /std:c++11 is redundant +rem SHARED LIBRARY: + rem echo Building DLL (%CONFIG%) + rem cl /nologo /EHsc /DWIN32 /wd4530 %CFLAGS% %INCLUDE_DIRS% %SRC_FILES% /LD /Fe%LIB_PATH%\%LIB_NAME%.dll /Fo%OBJDIR%\ /link %LINK_LIBS% +echo Building EXE (%CONFIG%)... +cl /nologo /EHsc /DWIN32 /wd4530 %CFLAGS% %INCLUDE_DIRS% %SRC_FILES% /link /MACHINE:AMD64 %LINK_LIBS% /OUT:%LIB_PATH%\%LIB_NAME%.exe + +rem cleanup... +rd /s /q "%OBJDIR%" + +rem echo Running post-build script... +rem nothing to do (for now). +endlocal diff --git a/build.jai b/build.jai index 7296d35..9dd8a16 100644 --- a/build.jai +++ b/build.jai @@ -19,6 +19,7 @@ INCLUDE_DIRS :: string.[ "third_party" ]; + build_cpp_project :: () { start := seconds_since_init(); @@ -53,15 +54,18 @@ build_cpp_exe :: (compile_debug: bool) { exe_path := tprint("bin/%", EXE_BASE_NAME); make_directory_if_it_does_not_exist("bin"); + LINK_LIBS: []string; + if (compile_debug) { LINK_LIBS = .["bin/Debug/dear-imgui.lib"]; } + else { LINK_LIBS = .["bin/Release/dear-imgui.lib"]; } - success := build_cpp_executable(exe_path, ..EXE_SOURCE_FILENAMES, debug=compile_debug, extra=extra); + success := build_cpp_executable(exe_path, ..EXE_SOURCE_FILENAMES, debug=compile_debug, extra=extra, library_files=LINK_LIBS); print("\nbuild_cpp_executable, success: %\n", success); } build_cpp_lib :: (compile_debug: bool) -> bool { - lib_path := tprint("build/Debug/%", LIB_BASE_NAME); + lib_path := tprint("bin/Debug/%", LIB_BASE_NAME); if !compile_debug { - lib_path = tprint("build/Release/%", LIB_BASE_NAME); + lib_path = tprint("bin/Release/%", LIB_BASE_NAME); } lib_directory := path_strip_filename(lib_path); make_directory_if_it_does_not_exist(lib_directory, recursive = true); diff --git a/build_imgui_lib.cmd b/build_imgui_lib.cmd new file mode 100644 index 0000000..c218cbb --- /dev/null +++ b/build_imgui_lib.cmd @@ -0,0 +1,51 @@ +@echo off +setlocal enabledelayedexpansion + +if "%~1"=="" ( + echo Usage: build_imgui_lib.cmd [Debug^|Release] + exit /b 1 +) + +set CONFIG=%~1 + +if /I "%CONFIG%"=="Debug" ( + set CFLAGS=/MTd /Od /Z7 /DDEBUG /DEBUG -diagnostics:caret -diagnostics:column -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING -D_CRT_NONSTDC_NO_DEPRECATE -D_USE_MATH_DEFINES + set LIB_PATH=bin/Debug +) else if /I "%CONFIG%"=="Release" ( + set CFLAGS=/MT /O2 /DNDEBUG + set LIB_PATH=bin/Release +) else ( + echo Invalid configuration: %CONFIG% + echo Usage: build_imgui_lib.cmd [Debug^|Release] + exit /b 1 +) + +set OBJDIR=obj + +if not exist "%LIB_PATH%" mkdir "%LIB_PATH%" +if not exist obj mkdir obj + +set LIB_NAME=dear-imgui + +set SRC_FILES=^ + lib\third_party\dear-imgui\imgui.cpp ^ + lib\third_party\dear-imgui\imgui_widgets.cpp ^ + lib\third_party\dear-imgui\imgui_draw.cpp ^ + lib\third_party\dear-imgui\imgui_tables.cpp ^ + lib\third_party\dear-imgui\imgui_impl_dx11.cpp ^ + lib\third_party\dear-imgui\imgui_impl_win32.cpp + rem lib\third_party\dear-imgui\imgui_demo.cpp ^ + +set INCLUDE_DIRS=^ + /Ilib\third_party + +set LINK_LIBS= + +REM Build STATIC LIBRARY: + echo Building static LIB (%CONFIG%) + cl /nologo /EHsc /DWIN32 /wd4530 %CFLAGS% %INCLUDE_DIRS% %SRC_FILES% /c /Fo%OBJDIR%\ + lib /OUT:%LIB_PATH%\%LIB_NAME%.lib %OBJDIR%\*.obj %LINK_LIBS% + +rd /s /q "%OBJDIR%" + +endlocal diff --git a/exe_main.cpp b/exe_main.cpp index a1e17e0..76e37cb 100644 --- a/exe_main.cpp +++ b/exe_main.cpp @@ -1,23 +1,20 @@ #include "lib_main.cpp" -// #include "lib/third_party/dear-imgui/imgui.cpp" -// #include "lib/third_party/dear-imgui/imgui_widgets.cpp" -// #include "lib/third_party/dear-imgui/imgui_draw.cpp" -// #include "lib/third_party/dear-imgui/imgui_tables.cpp" -// #include "lib/third_party/dear-imgui/imgui_demo.cpp" -// #include "lib/third_party/dear-imgui/imgui_impl_dx11.cpp" -// #include "lib/third_party/dear-imgui/imgui_impl_win32.cpp" - -// #include "lib/third_party/dear-imgui/imgui.h" -// #include "lib/third_party/dear-imgui/imgui_impl_win32.h" -// #include "lib/third_party/dear-imgui/imgui_impl_dx11.h" - -// #pragma comment(lib, "d3d11") -// #pragma comment(lib, "d3dcompiler") #define BASE_RUN_TESTS 1 #if BASE_RUN_TESTS #include "lib/Base/run_tests.cpp" #endif -#include "src/Base_Entry_Point.cpp" +#define USE_DEAR_IMGUI 1 +#if USE_DEAR_IMGUI + #include + #pragma comment(lib, "d3d11.lib") + #pragma comment(lib, "dxgi.lib") + + #include "lib/third_party/dear-imgui/imgui.h" + #include "lib/third_party/dear-imgui/imgui_impl_win32.h" + #include "lib/third_party/dear-imgui/imgui_impl_dx11.h" + #include "src/imgui_main.cpp" +#endif +#include "src/Base_Entry_Point.cpp" diff --git a/lib/Base/Base.h b/lib/Base/Base.h index d4cf46c..bf82a5f 100644 --- a/lib/Base/Base.h +++ b/lib/Base/Base.h @@ -230,6 +230,27 @@ constexpr s64 S64_MIN = 0x8000000000000000LL; constexpr s64 S64_MAX = 0x7fffffffffffffffLL; constexpr u64 U64_MAX = 0xffffffffffffffffULL; +struct Vec2 { + union { + struct { float x, y; }; + float data[2]; + }; +}; + +struct Vec3 { + union { + struct { float x, y, z; }; + float data[3]; + }; +}; + +struct Vec4 { + union { + struct { float x, y, z, w; }; + float data[4]; + }; +}; + // #thread_primitives #move? #if OS_WINDOWS struct Condition_Variable { diff --git a/lib/Base/Base_Thread_Context.h b/lib/Base/Base_Thread_Context.h index db9104d..0b2f31b 100644 --- a/lib/Base/Base_Thread_Context.h +++ b/lib/Base/Base_Thread_Context.h @@ -1,4 +1,5 @@ struct Thread; // hacky fwd declare +struct Graphics; struct Thread_Context { ExpandableArena* temp; // Used for temporary allocations, scratch space. @@ -20,6 +21,9 @@ struct Thread_Context { Allocator error_allocator = GPAllocator(); Error* first_error = nullptr; Error* current_error = nullptr; + + // Graphics stuff: + Graphics* graphics; }; // C_LINKAGE thread_static TCTX* tctx_thread_local; diff --git a/lib/Base/General_Purpose_Allocator.cpp b/lib/Base/General_Purpose_Allocator.cpp index 7b61b85..f65abff 100644 --- a/lib/Base/General_Purpose_Allocator.cpp +++ b/lib/Base/General_Purpose_Allocator.cpp @@ -143,8 +143,8 @@ Allocator GPAllocator () { void* GPAllocator_Proc (Allocator_Mode mode, s64 requested_size, s64 old_size, void* old_memory, void* allocator_data) { u16 alignment = 16; // default alignment - Thread_Context* tctx = thread_context(); - if (tctx) alignment = tctx->GPAllocator_alignment; + Thread_Context* context = thread_context(); + if (context) alignment = context->GPAllocator_alignment; switch (mode) { case Allocator_Mode::ALLOCATE: { diff --git a/lib/Graphics.cpp b/lib/Graphics.cpp new file mode 100644 index 0000000..1569d1f --- /dev/null +++ b/lib/Graphics.cpp @@ -0,0 +1,87 @@ +#if GRAPHICS_OPENGL +#include + +#pragma comment(lib, "opengl32") +#pragma comment(lib, "gdi32") +#endif + +// #if GRAPHICS_DIRECTX11 + +// enum class Graphics_API: s32 { +// DirectX_11 = 0, +// OpenGL_3 = 1, +// }; + +struct Shader {}; +struct Texture {}; +struct Vertex { + Vec2 position; + Vec4 color_scale; + Vec2 uv0; + // The following values are for rendering rounded rectangles + // It's OK to put these here because for basic rendering the performance is "good enough" + Vec2 rect_center; + Vec2 rect_size; + f32 rect_corner_radius; + f32 rect_edge_softness = 1.0; +}; + +constexpr s64 starting_vertex_count = 2048; + +struct Graphics { + // Graphics_API api = Graphics_API::OpenGL_3; + + Window_Info current_window; + Shader* current_shader; + Texture* texture_render_target; + + Array vertices; // just init to max count. +}; + +void graphics_thread_destroy () { + Thread_Context* context = thread_context(); // maybe turn this into a :macro? + + array_free(context->graphics->vertices); + internal_free(context->graphics); +} + +void graphics_reset () { + Thread_Context* context = thread_context(); // maybe turn this into a :macro? + + context->graphics->current_shader = nullptr; +} + +Graphics* graphics_thread_init () { + Thread_Context* context = thread_context(); + + Assert(context != nullptr); + + push_allocator(GPAllocator()); + + if (context->graphics == nullptr) { + context->graphics = New(true); + array_reserve(context->graphics->vertices, starting_vertex_count); + } + + return context->graphics; +} + +void graphics_flush_buffer () { + // +} + +void graphics_update_current_window (Graphics* graphics) { + // graphics->current_window + +} + +void graphics_set_render_target (Window_Info window_info) { + Graphics* graphics = graphics_thread_init(); + + graphics->current_shader = nullptr; + graphics->texture_render_target = nullptr; + + graphics->current_window = window_info; + // #TODO: graphics_update_window :: + +} \ No newline at end of file diff --git a/lib/OS/OS_Win32.cpp b/lib/OS/OS_Win32.cpp index d6cfc11..2499875 100644 --- a/lib/OS/OS_Win32.cpp +++ b/lib/OS/OS_Win32.cpp @@ -628,8 +628,6 @@ Window_Dimensions platform_get_centered_window_dimensions (bool open_on_largest_ // #window_creation -> put API in OS_Win32.h // Instead of returning WindowType, return the handle + other information. bool os_create_window (string new_window_name, Window_Type parent, bool center_window, bool open_on_largest_monitor, bool display_window) { - const ArrayView background_color = array_view_from_values(0.0f, 0.0f, 0.0f); - local_persist string class_name = "Win32_Window_Class"; if (!global_win32_state.process_info.window_class_initialized) { @@ -638,14 +636,14 @@ bool os_create_window (string new_window_name, Window_Type parent, bool center_w WNDCLASSEXW wc = {}; wc.cbSize = sizeof(WNDCLASSEXW); wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = win32_wnd_proc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = nullptr; - wc.hIcon = (HICON)LoadImageW(nullptr, (LPCWSTR)utf8_to_wide("tmp.ico").data, IMAGE_ICON, 0, 0, LR_LOADFROMFILE); - wc.hCursor = LoadCursorW(nullptr, (LPCWSTR)IDC_ARROW); + wc.lpfnWndProc = win32_wnd_proc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = nullptr; + wc.hIcon = (HICON)LoadImageW(nullptr, (LPCWSTR)utf8_to_wide("tmp.ico").data, IMAGE_ICON, 0, 0, LR_LOADFROMFILE); + wc.hCursor = LoadCursorW(nullptr, (LPCWSTR)IDC_ARROW); wc.hbrBackground = nullptr; - wc.lpszMenuName = nullptr; + wc.lpszMenuName = nullptr; wc.lpszClassName = (LPCWSTR)utf8_to_wide(class_name).data; if (RegisterClassExW(&wc) == 0) { @@ -696,7 +694,7 @@ bool os_create_window (string new_window_name, Window_Type parent, bool center_w return true; } -Window_Info get_main_window() { +Window_Info get_main_window () { Array windows = global_win32_state.process_info.windows; Assert(windows.count > 0); diff --git a/lib/OS/OS_Win32.h b/lib/OS/OS_Win32.h index 52f7b54..7706e30 100644 --- a/lib/OS/OS_Win32.h +++ b/lib/OS/OS_Win32.h @@ -57,9 +57,13 @@ struct Window_Dimensions { struct Window_Info { Window_Type window; - Window_Dimensions initial_dimensions; + Window_Dimensions initial_dimensions; // for resetting. + b32 is_main_window; + b32 backend_initialized; + // Platform-Specific (Win32) + HDC hdc; }; // #move: Monitor - platform-independent hardware monitor information: @@ -78,7 +82,8 @@ struct Monitor { bool os_create_window (string new_window_name, Window_Type parent=nullptr, bool center_window=true, bool open_on_largest_monitor=true, bool display_window=true); -Window_Info get_main_window(); +Window_Info get_main_window (); +Window_Info* get_main_window_pointer (); // struct File_Contents { // File file = {}; diff --git a/lib_main.cpp b/lib_main.cpp index c34e3d0..f0f5210 100644 --- a/lib_main.cpp +++ b/lib_main.cpp @@ -54,6 +54,8 @@ #include "lib/Base/Thread_Group.cpp" +#include "lib/Graphics.cpp" + // #if OS_LINUX.. // #include "src/OS_Linux.cpp" // #if OS_MACOS.. diff --git a/src/Base_Entry_Point.cpp b/src/Base_Entry_Point.cpp index a7ff599..87fd674 100644 --- a/src/Base_Entry_Point.cpp +++ b/src/Base_Entry_Point.cpp @@ -18,7 +18,8 @@ internal void Main_Entry_Point (int argc, WCHAR **argv); internal void Main_Entry_Point (int argc, WCHAR **argv) { set_cpu_base_frequency(3200); // REQUIRED FOR TIMING MODULE! will depend on CPU - + ImGui_Application(); +/* #if BASE_RUN_TESTS run_pre_setup_tests(); // #no_context #endif @@ -43,9 +44,9 @@ internal void Main_Entry_Point (int argc, WCHAR **argv) { s32 window_width; s32 window_height; success = get_window_dimensions(&main_window, &window_width, &window_height); Assert(success); - // #TODO: Set in global state for convenience: - Rect main_screen = make_rect_int(0, 0, window_width, window_height); - // renderer.//set_render_target(main_window.window, main_screen); + // Maybe bake screen into window_info? + // Rect main_screen = make_rect_int(0, 0, window_width, window_height); + graphics_set_render_target(main_window); // get_render_dimensions @@ -55,5 +56,6 @@ internal void Main_Entry_Point (int argc, WCHAR **argv) { // 4. [ ] Setup Mouse and Keyboard Inputs // 5. [ ] Launch second thread; thread groups + */ } diff --git a/src/ImGui_Supplementary.cpp b/src/ImGui_Supplementary.cpp index 18e752c..0170c56 100644 --- a/src/ImGui_Supplementary.cpp +++ b/src/ImGui_Supplementary.cpp @@ -104,3 +104,80 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { } return ::DefWindowProcW(hWnd, msg, wParam, lParam); } + +#include "../lib/third_party/dear-imgui/imgui_internal.h" + +void Set_Custom_Style () { + ImGuiStyle* style = &ImGui::GetStyle(); + ImVec4* colors = style->Colors; + + style->Alpha = 1.0; + style->WindowRounding = 3.0f; + style->GrabRounding = 3.0f; + style->GrabMinSize = 20.0f; + style->FrameRounding = 8.0f; + style->TabRounding = 8.0f; + + colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); + colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); + colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); + colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f); + colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); + colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.52f, 0.88f, 1.00f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); + colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Separator] = colors[ImGuiCol_Border]; + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); + colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.20f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + colors[ImGuiCol_InputTextCursor] = colors[ImGuiCol_Text]; + colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered]; + colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f); + colors[ImGuiCol_TabSelected] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f); + colors[ImGuiCol_TabSelectedOverline] = colors[ImGuiCol_HeaderActive]; + colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); + colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f); + colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.50f, 0.50f, 0.50f, 0.00f); + colors[ImGuiCol_DockingPreview] = ImVec4(0.26f, 0.59f, 0.98f, 0.75f); //colors[ImGuiCol_HeaderActive] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f); + colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); + colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); + colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); + colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); + colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.20f, 1.00f); + colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.35f, 1.00f); // Prefer using Alpha=1.0 here + colors[ImGuiCol_TableBorderLight] = ImVec4(0.23f, 0.23f, 0.25f, 1.00f); // Prefer using Alpha=1.0 here + colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f); + colors[ImGuiCol_TextLink] = colors[ImGuiCol_HeaderActive]; + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); + colors[ImGuiCol_TreeLines] = colors[ImGuiCol_Border]; + colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); + colors[ImGuiCol_DragDropTargetBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_UnsavedMarker] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + colors[ImGuiCol_NavCursor] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); + colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); + colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); +} \ No newline at end of file diff --git a/imgui_main.cpp b/src/imgui_main.cpp similarity index 92% rename from imgui_main.cpp rename to src/imgui_main.cpp index 1304861..8329b1d 100644 --- a/imgui_main.cpp +++ b/src/imgui_main.cpp @@ -2,6 +2,8 @@ #include #include "ImGui_Supplementary.cpp" +global ImGuiContext* imgui_context; + void ImGui_Application () { // Make process DPI aware and obtain main monitor scale ImGui_ImplWin32_EnableDpiAwareness(); @@ -26,20 +28,23 @@ void ImGui_Application () { // Setup Dear ImGui context IMGUI_CHECKVERSION(); printf("ImGui Version %s \n", ImGui::GetVersion()); - ImGui::CreateContext(); + + imgui_context = ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); (void)io; - io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls + // 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.ConfigViewportsNoAutoMerge = true; - //io.ConfigViewportsNoTaskBarIcon = true; - //io.ConfigDockingAlwaysTabBar = true; - //io.ConfigDockingTransparentPayload = true; + io.ConfigViewportsNoAutoMerge = true; + io.ConfigViewportsNoTaskBarIcon = true; + io.ConfigDockingAlwaysTabBar = true; + io.ConfigDockingTransparentPayload = true; // Setup Dear ImGui style - ImGui::StyleColorsDark(); + // ImGui::StyleColorsDark(); + Set_Custom_Style(); // Setup scaling ImGuiStyle& style = ImGui::GetStyle(); @@ -66,6 +71,7 @@ void ImGui_Application () { // - 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. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author! // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! + //style.FontSizeBase = 20.0f; //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf"); @@ -121,6 +127,10 @@ void ImGui_Application () { { ImGui::Begin("Hello, world!"); + if (ImGui::Button("Debug_Break()")) { + debug_break(); + } + if (ImGui::Button("Create New Window")) { // I think that create_window should take few parameters, and we have other APIs for // styling, positioning, etc. I just call this and want to get a window.