ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.6k stars 10.15k forks source link

implot breaks on IMGUI_DEFINE_MATH_OPERATORS #7528

Closed mca222 closed 4 months ago

mca222 commented 4 months ago

Version/Branch of Dear ImGui:

HEAD b555984a, branch docking

Back-ends:

imgui_impl_win32.cpp + imgui_impl_dx12.cpp

Compiler, OS:

Windows11, MSVS2022

Full config/build information:

Dear ImGui 1.90.6 WIP (19052)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1939
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx12
io.ConfigFlags: 0x00000443
 NavEnableKeyboard
 NavEnableGamepad
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1264.00,761.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

My Issue/Question:

I'm trying to add implot to an imgui example (example_win32_directx12) following these instructions: https://github.com/ocornut/implot?tab=readme-ov-file#integration

After adding the headers and source to the example solution (and before setting of the implot contexts), I get these build errors

Rebuild started at 11:47...
1>------ Rebuild All started: Project: example_win32_directx12, Configuration: Debug x64 ------
1>implot_demo.cpp
1>C:\Users\user\source\repos\imgui\imgui_internal.h(102,1): error C1189: #error:  Please '#define IMGUI_DEFINE_MATH_OPERATORS' _BEFORE_ including imgui.h!
1>(compiling source file '../../../implot/implot_demo.cpp')
1>implot_items.cpp
1>C:\Users\user\source\repos\imgui\imgui_internal.h(102,1): error C1189: #error:  Please '#define IMGUI_DEFINE_MATH_OPERATORS' _BEFORE_ including imgui.h!
1>(compiling source file '../../../implot/implot_items.cpp')
1>imgui.cpp
1>imgui_demo.cpp
1>imgui_draw.cpp
1>imgui_tables.cpp
1>imgui_widgets.cpp
1>imgui_impl_dx12.cpp
1>imgui_impl_win32.cpp
1>main.cpp
1>Generating Code...
1>Done building project "example_win32_directx12.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Rebuild completed at 11:47 and took 03,197 seconds ==========

Screenshots/Video:

implot

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
MoreCodeToExplainMyIssue();
ImGui::End();
ocornut commented 4 months ago

This is an implot issue, but i fixed it in implot the same day i pushed the change to imgui. So the simplest would be to update implot.

ocornut commented 4 months ago

I just realized you have pointed to ocornut/implot which is my own non-up-to-date fork which i occasionally use to submit patches to implot. Please use the original implot project, not my fork! Probably this was the problem :)

ocornut commented 4 months ago

I have renamed the master branch on ocornut/implot to master_DONT_THIS_REPO to avoid this situation. Please grab implot from its original repository: https://github.com/epezent/implot

mca222 commented 4 months ago

I just realized you have pointed to ocornut/implot which is my own non-up-to-date fork which i occasionally use to submit patches to implot. Please use the original implot project, not my fork! Probably this was the problem :)

That was indeed the issue, I was under the impression you were the implot author. Thanks for your swift reaction.