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
Move Imgui integration #33
Conversation
Codecov Report
@@ Coverage Diff @@
## master #33 +/- ##
===========================================
+ Coverage 58.34% 71.72% +13.37%
===========================================
Files 16 11 -5
Lines 557 244 -313
===========================================
- Hits 325 175 -150
+ Misses 232 69 -163
Continue to review full report at Codecov.
|
FYI, just found this: https://gitlab.com/caleb-vincent/MagnumImGui so maybe that has also some changes worth integrating (if you would open an issue there notifying the author about this merge, that would be great |
@mosra Issues are not open on that project. Found a change, though, that I will integrate * Edit: A similiar change was already present in the other repo. |
9201580
to
40565d9
Compare
@mosra The code would be ready for some initial rough review pass. The documentation is not done yet, though. (There is currently a pending issue with the example still, though, so really, just rough review... or wait another two days) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty much finished to me already :) Great work, looking forward for the final thing.
modules/FindMagnumIntegration.cmake
Outdated
@@ -190,6 +191,14 @@ foreach(_component ${MagnumIntegration_FIND_COMPONENTS}) | |||
|
|||
set(_MAGNUMINTEGRATION_${_COMPONENT}_INCLUDE_PATH_NAMES MotionState.h) | |||
|
|||
# ImGui integration library | |||
elseif(_component STREQUAL ImGui) | |||
find_package(ImGui REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the REQUIRED
here -- if find_package(MagnumIntegration OPTIONAL)
would be used, this will break. (But OTOH I also don't know what's the proper way of doing this, I'm only saying find_package(Name)
everywhere.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, now I remember why we had a discussion about this once :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation says "REQUIRED stops processing on error message", hence manually outputting an error message would make it stop if find_package(MagnumIntegration REQUIRED ImGui)
whereas OPTIONAL would print the error message but continue processing...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OTOH, the error message will be output by find_package(ImGui)
already... right? So it will stop processing there, I'd expect...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, probably not. We need to revisit this later, maybe we need to add REQUIRED
based on value of MagnumIntegration_FIND_REQUIRED_ImGui ... but that then needs to be done for everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the REQUIRED
, then?
package/ci/appveyor.yml
Outdated
@@ -65,6 +65,10 @@ install: | |||
- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\0.9.9.0.zip appveyor DownloadFile https://github.com/g-truc/glm/archive/0.9.9.0.zip | |||
- 7z x 0.9.9.0.zip -o%APPVEYOR_BUILD_FOLDER%\deps && ren %APPVEYOR_BUILD_FOLDER%\deps\glm-0.9.9.0 glm | |||
|
|||
# ImGui | |||
- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\imgui-1.65.zip appveyor DownloadFile https://github.com/ocornut/imgui/archive/v1.65.zip | |||
- 7z x v1.65.zip -o%APPVEYOR_BUILD_FOLDER%\deps && ren %APPVEYOR_BUILD_FOLDER%\deps\imgui-1.65 imgui |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking out loud: we depend on particular version and since imgui backwards compatibility is broken quite often (at least by looking at changes in bgfx) it should be probably mentioned in the docs what version this integration supports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it would almost make sense to just bundle it in external
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I hope the changes are not so drastic (and I assume it will get more stable and better backward-compatible with upcoming versions). This is similar to OVR integration, no? There it was also recommending a version but it usually worked with newer ones as well.
|
||
#include <imgui.h> | ||
|
||
using namespace Magnum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this here ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not fixed ;)
c13570f
to
6cde770
Compare
@mosra Ready for review! Open questions (/for follow up):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still 2 unresolved comments (collapsed by GitHub) from before, one for the code snippet and one for minor code formatting. Besides that:
- there's some dllexport/dllimport issue on MinGW. Not sure why is that?
- the Emscripten (at least WebGL 2) build should be working too (it was working in the original repos)
- same for iOS ES3 I think
- there's lots of compiler warnings due to our very strict warning levels, not sure how to disable these for the interface sources (todo for myself)
doc/namespaces.dox
is missing the license info (i'm sure i mentioned this before somewhere, but can't find where)- the comments below :)
I need to hurry up with the CI updates to make Travis working. I also need to test this locally before merging (+ do the "note to self" things).
|
||
_projMatrixUniform = uniformLocation("projectionMatrix"); | ||
|
||
setUniform(uniformLocation("colorTexture"), TextureLayer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling that the two lines above are also wrapped in some if()
for the builtin shaders. I'll look into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So after looking into this, what do you say? (I am not sure whether I understand what this is about, btw...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! I'll look into this during the merge, I meant.
For the CI failures, it looks like you forgot to add the file in |
|
Signed-off-by: Squareys <squareys@googlemail.com>
482696a
to
d64bb8c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last comments from me before merge. The rest (such as ES2 / WebGL 1 shader compat) I'll do post-merge.
/* [Context-usage] */ | ||
|
||
/* [Context-usage-per-frame] */ | ||
GL::Renderer::enable(GL::Renderer::Feature::Blending); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also enable blending only for the draw call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you mean disabling it again after
modules/FindMagnumIntegration.cmake
Outdated
@@ -190,6 +191,14 @@ foreach(_component ${MagnumIntegration_FIND_COMPONENTS}) | |||
|
|||
set(_MAGNUMINTEGRATION_${_COMPONENT}_INCLUDE_PATH_NAMES MotionState.h) | |||
|
|||
# ImGui integration library | |||
elseif(_component STREQUAL ImGui) | |||
find_package(ImGui REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the REQUIRED
, then?
|
||
#include <imgui.h> | ||
|
||
using namespace Magnum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not fixed ;)
125bf31
to
d49c2e9
Compare
- Add documentation - Tests for input and basic test for rendering - Adapt code style - Add Conversion.h for converting imgui math types - Compile shaders as resource - Add find module for ImGui Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
d49c2e9
to
8f0b416
Compare
Would it be possible for the official integration to have a way to load custom fonts ? I currently have a customised version of nnarain's integration, and I had to edit it to add code to load my own fonts. I went to this line, and added the following before it: io.Fonts->AddFontFromFileTTF("aller.ttf",
16.0f,
nullptr,
ranges.Data);
io.Fonts->AddFontFromFileTTF("aller.ttf",
18.0f,
nullptr,
ranges.Data);
io.Fonts->AddFontFromFileTTF("aller.ttf",
20.0f,
nullptr,
ranges.Data);
io.Fonts->AddFontFromFileTTF("aller.ttf",
22.0f,
nullptr,
ranges.Data); As you can see, I load the same font multiple times at different sizes (to fit users' needs). I don't specify a custom font config (hence the Here's the ImGui documentation about fonts: https://github.com/ocornut/imgui/blob/67775448556d8dba304657719829f1ab768b3c97/imgui.cpp#L764-L838 and https://github.com/ocornut/imgui/blob/master/misc/fonts/README.txt |
@williamjcm You can still add those lines after calling the Otherwise a more magnum-like solution (? @mosra ) would probably be to allow ImGui to use |
The code that generates the font texture data is in the integration, however. Link to nnarain's version of the integration: https://github.com/nnarain/magnum-imgui/blob/256968783121306c65ddfb5c28906140f2ccf947/src/MagnumImGui.cpp#L76-L84 |
Oh! True, sorry, thanks for the hint! @mosra Maybe it would be best to add a dependency on AbstractFont here then and let that generate the glyph texture instead? I wouldn't expect the textures to be compatible, though, so maybe a "generateFonts" or something as a second step after Context initialization. I wonder how we could make that "unforgetible", i.e. an optional second step if no custom font needs to be loaded |
Maybe two constructors, with one asking for a file name among its parameter ? And once the object is constructed, a method could allow generating even more fonts as needed, maybe with optional arguments like ImGui font config and character ranges. |
Shower thoughts: I finally can see a bit into how this whole thing works, so if I understand correctly, all you need is to be able to do some stuff between So let's no overdo this. Could the following new constructor cover your case? (the parameter is just to distinguish the intention, otherwise not really needed) |
I like that idea. It would give more control to the integration's users who want it, while still giving a "I don't care" option to those who just want to get ImGui up and running. |
I merged the PR with the following changes:
I did not bother with port to ES2 / WebGL 1 yet since that would delay the merge by another year, will do that later. I'm now working on the example, will upload the docs once I have the example updated and merged as well. Feedback and bugreports very appreciated :) |
Hi all!
This is the WIP PR for my efforts to move various magnum-imgui projects (by @lecopivo https://github.com/lecopivo/magnum-imgui and @denesik and forks by @nnarain, @williamjcm and @ShaddyDC) into the official repository.
Cheers, Jonathan
TODOs: