Skip to content

Some errors with ImVec2 + math while coding a custom checkbox. #6137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Smellon69 opened this issue Feb 2, 2023 · 2 comments
Closed

Some errors with ImVec2 + math while coding a custom checkbox. #6137

Smellon69 opened this issue Feb 2, 2023 · 2 comments

Comments

@Smellon69
Copy link

Version/Branch of Dear ImGui:

Version: DX9
Branch: It's just the latest version with all the essential files.

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_dx9.cpp + imgui_impl_win32.cpp
Compiler: Visual Studio 2022 Community
Operating System: Revision OS Windows 11 Pro

My Issue/Question:

So I am adding a custom checkbox and here is the line of code causing me all the trouble:
const ImRect bb(pos, pos + pos);
The error is:
No operator "+" matches these operands: operand types are: ImVec2 + ImVec2

Screenshots/Video

image

Standalone, minimal, complete and verifiable example: (see #2261)

// Here's some code anyone can copy and paste to reproduce your issue
const ImRect bb(pos, pos + pos);
@ocornut
Copy link
Owner

ocornut commented Feb 2, 2023

See the definition of ImVec2 we don’t define maths operators for it by default, as they could collide with your own maths operators in the case you setup ImVec2 to auto-cast to your own math types.

You can import our maths operator by using:

#define IMGUI_DEFINE_MATH_OPERATORS
#include "imgui.h"

@ocornut ocornut closed this as completed Feb 2, 2023
ocornut added a commit that referenced this issue Feb 15, 2023
…ATH_OPERATORS) implementation from imgui_internal.h in imgui.h. (#6164, #6137, #5966, #2832)
@xXxNozz4rrxXx
Copy link

See the definition of ImVec2 we don’t define maths operators for it by default, as they could collide with your own maths operators in the case you setup ImVec2 to auto-cast to your own math types.

You can import our maths operator by using:

#define IMGUI_DEFINE_MATH_OPERATORS
#include "imgui_internal.h"

hello i have the same error even if i define the :

#define IMGUI_DEFINE_MATH_OPERATORS
#include "imgui_internal.h"
still have this error
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants