Code Monkey home page Code Monkey logo

magnum-integration's Introduction

Here are integration libraries for Magnum C++11/C++14 graphics engine, providing integration of various math and physics libraries into the engine itself.

Join the chat at https://gitter.im/mosra/magnum Build Status Build Status Coverage Status MIT License

SUPPORTED PLATFORMS

WHAT'S NEW?

Curious about what was added or improved recently? Check out the Changelog page in the documentation.

BUILDING MAGNUM INTEGRATION

The building process is similar to Magnum itself. See the building documentation for a comprehensive guide for building, packaging and crosscompiling — we provide packages for many platforms, including Windows, Linux and macOS.

CONTACT & SUPPORT

If you want to contribute to Magnum, if you spotted a bug, need a feature or have an awesome idea, you can get a copy of the sources from GitHub and start right away! There is the already mentioned guide about how to download and build Magnum Integration and also a guide about coding style and best practices which you should follow to keep the library as consistent and maintainable as possible.

See also the Magnum Project Contact & Support page for further information.

CREDITS

See the CREDITS.md file for details. Big thanks to everyone involved!

LICENSE

Magnum is licensed under the MIT/Expat license, see the COPYING file for details.

magnum-integration's People

Contributors

arximboldi avatar auburn avatar costashatz avatar gergondet avatar jacksoncampolattaro avatar jandupal avatar janos95 avatar jlaxson avatar lacyyy avatar mosra avatar mtao avatar olga-python avatar pezcode avatar rune-scape avatar sigman78 avatar squareys avatar sthalik avatar thehans avatar williamjcm avatar xqms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

magnum-integration's Issues

How to use ImGui integration as subdirectory

Howdy!

I can compile but not link the ImGui example currently (Windows, VS2019). I get linker errors regarding the event handlers in Context:

main.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl Magnum::ImGuiIntegration::Context::updateApplicationCursor<class Kpns::UI::MainWindow>(class Kpns::UI::MainWindow &)" (??$updateApplicationCursor@VMainWindow@UI@Kpns@@@Context@ImGuiIntegration@Magnum@@QEAAXAEAVMainWindow@UI@Kpns@@@Z) referenced in function "private: virtual void __cdecl Kpns::UI::MainWindow::drawEvent(void)" (?drawEvent@MainWindow@UI@Kpns@@EEAAXXZ)
main.cpp.obj : error LNK2019: unresolved external symbol "public: bool __cdecl Magnum::ImGuiIntegration::Context::handleKeyPressEvent<class Magnum::Platform::GlfwApplication::KeyEvent>(class Magnum::Platform::GlfwApplication::KeyEvent &)" (??$handleKeyPressEvent@VKeyEvent@GlfwApplication@Platform@Magnum@@@Context@ImGuiIntegration@Magnum@@QEAA_NAEAVKeyEvent@GlfwApplication@Platform@2@@Z) referenced in function "private: virtual void __cdecl Kpns::UI::MainWindow::keyPressEvent(class Magnum::Platform::GlfwApplication::KeyEvent &)" (?keyPressEvent@MainWindow@UI@Kpns@@EEAAXAEAVKeyEvent@GlfwApplication@Platform@Magnum@@@Z)
main.cpp.obj : error LNK2019: unresolved external symbol "public: bool __cdecl Magnum::ImGuiIntegration::Context::handleKeyReleaseEvent<class Magnum::Platform::GlfwApplication::KeyEvent>(class Magnum::Platform::GlfwApplication::KeyEvent &)" (??$handleKeyReleaseEvent@VKeyEvent@GlfwApplication@Platform@Magnum@@@Context@ImGuiIntegration@Magnum@@QEAA_NAEAVKeyEvent@GlfwApplication@Platform@2@@Z) referenced in function "private: virtual void __cdecl Kpns::UI::MainWindow::keyReleaseEvent(class Magnum::Platform::GlfwApplication::KeyEvent &)" (?keyReleaseEvent@MainWindow@UI@Kpns@@EEAAXAEAVKeyEvent@GlfwApplication@Platform@Magnum@@@Z)
main.cpp.obj : error LNK2019: unresolved external symbol "public: bool __cdecl Magnum::ImGuiIntegration::Context::handleMousePressEvent<class Magnum::Platform::GlfwApplication::MouseEvent>(class Magnum::Platform::GlfwApplication::MouseEvent &)" (??$handleMousePressEvent@VMouseEvent@GlfwApplication@Platform@Magnum@@@Context@ImGuiIntegration@Magnum@@QEAA_NAEAVMouseEvent@GlfwApplication@Platform@2@@Z) referenced in function "private: virtual void __cdecl Kpns::UI::MainWindow::mousePressEvent(class Magnum::Platform::GlfwApplication::MouseEvent &)" (?mousePressEvent@MainWindow@UI@Kpns@@EEAAXAEAVMouseEvent@GlfwApplication@Platform@Magnum@@@Z)
main.cpp.obj : error LNK2019: unresolved external symbol "public: bool __cdecl Magnum::ImGuiIntegration::Context::handleMouseReleaseEvent<class Magnum::Platform::GlfwApplication::MouseEvent>(class Magnum::Platform::GlfwApplication::MouseEvent &)" (??$handleMouseReleaseEvent@VMouseEvent@GlfwApplication@Platform@Magnum@@@Context@ImGuiIntegration@Magnum@@QEAA_NAEAVMouseEvent@GlfwApplication@Platform@2@@Z) referenced in function "private: virtual void __cdecl Kpns::UI::MainWindow::mouseReleaseEvent(class Magnum::Platform::GlfwApplication::MouseEvent &)" (?mouseReleaseEvent@MainWindow@UI@Kpns@@EEAAXAEAVMouseEvent@GlfwApplication@Platform@Magnum@@@Z)
main.cpp.obj : error LNK2019: unresolved external symbol "public: bool __cdecl Magnum::ImGuiIntegration::Context::handleMouseMoveEvent<class Magnum::Platform::GlfwApplication::MouseMoveEvent>(class Magnum::Platform::GlfwApplication::MouseMoveEvent &)" (??$handleMouseMoveEvent@VMouseMoveEvent@GlfwApplication@Platform@Magnum@@@Context@ImGuiIntegration@Magnum@@QEAA_NAEAVMouseMoveEvent@GlfwApplication@Platform@2@@Z) referenced in function "private: virtual void __cdecl Kpns::UI::MainWindow::mouseMoveEvent(class Magnum::Platform::GlfwApplication::MouseMoveEvent &)" (?mouseMoveEvent@MainWindow@UI@Kpns@@EEAAXAEAVMouseMoveEvent@GlfwApplication@Platform@Magnum@@@Z)
main.cpp.obj : error LNK2019: unresolved external symbol "public: bool __cdecl Magnum::ImGuiIntegration::Context::handleMouseScrollEvent<class Magnum::Platform::GlfwApplication::MouseScrollEvent>(class Magnum::Platform::GlfwApplication::MouseScrollEvent &)" (??$handleMouseScrollEvent@VMouseScrollEvent@GlfwApplication@Platform@Magnum@@@Context@ImGuiIntegration@Magnum@@QEAA_NAEAVMouseScrollEvent@GlfwApplication@Platform@2@@Z) referenced in function "private: virtual void __cdecl Kpns::UI::MainWindow::mouseScrollEvent(class Magnum::Platform::GlfwApplication::MouseScrollEvent &)" (?mouseScrollEvent@MainWindow@UI@Kpns@@EEAAXAEAVMouseScrollEvent@GlfwApplication@Platform@Magnum@@@Z)
main.cpp.obj : error LNK2019: unresolved external symbol "public: bool __cdecl Magnum::ImGuiIntegration::Context::handleTextInputEvent<class Magnum::Platform::GlfwApplication::TextInputEvent>(class Magnum::Platform::GlfwApplication::TextInputEvent &)" (??$handleTextInputEvent@VTextInputEvent@GlfwApplication@Platform@Magnum@@@Context@ImGuiIntegration@Magnum@@QEAA_NAEAVTextInputEvent@GlfwApplication@Platform@2@@Z) referenced in function "private: virtual void __cdecl Kpns::UI::MainWindow::textInputEvent(class Magnum::Platform::GlfwApplication::TextInputEvent &)" (?textInputEvent@MainWindow@UI@Kpns@@EEAAXAEAVTextInputEvent@GlfwApplication@Platform@Magnum@@@Z)

My relevant CMake script that sets up Magnum:

##############################################################################
# Magnum (and it's associated subprojects)
#
set(BUILD_STATIC ON CACHE BOOL "" FORCE)

set(WITH_TESTSUITE OFF CACHE BOOL "" FORCE)
add_subdirectory(source/corrade EXCLUDE_FROM_ALL)

set(WITH_AUDIO OFF CACHE BOOL "" FORCE)
set(WITH_GLFWAPPLICATION ON CACHE BOOL "" FORCE)
add_subdirectory(source/magnum EXCLUDE_FROM_ALL)

set(WITH_EIGEN ON CACHE BOOL "" FORCE)
set(WITH_IMGUI ON CACHE BOOL "" FORCE)
set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source/imgui)
add_subdirectory(source/magnum-integration EXCLUDE_FROM_ALL)

set(WITH_PNGIMAGECONVERTER ON CACHE BOOL "" FORCE)
set(WITH_PNGIMPORTER ON CACHE BOOL "" FORCE)
add_subdirectory(source/magnum-plugins EXCLUDE_FROM_ALL)

And because I set this all up from a subdirectory under the repo root I provide a global interface library to avoid having to repeat myself for anything that uses Magnum:

add_library(kpns_graphics INTERFACE)
target_link_libraries(kpns_graphics INTERFACE
  Corrade::Main
  Magnum::GlfwApplication
  Magnum::GL
  Magnum::Magnum
  Magnum::Shaders
  Magnum::SceneGraph
  Magnum::DebugTools
  Magnum::Primitives
  Magnum::Text
  Magnum::TextureTools
  Magnum::Trade
  MagnumIntegration::ImGui
  MagnumIntegration::Eigen
  )

My application adds kpns_graphics to it's PRIVATE target_link_libraries.

So, everything compiles fine, CLion resolves all symbols etc. But when linking it fails and I'm not sure why. I'd appreciate any helpful advice.

Thanks!

ImGui integration does not support adding UserCallback to DrawList

The ImDrawList advanced API allows one to register arbitrary callbacks to change the OpenGL state during rendering. This can be used to manipulate shaders or, in my case, to temporarily change the glBlendFunc for the rendering of one particular widget.

This needs support from the rendering engine. The Magnum integration is ignoring these, but this is how the standard OpenGL integration handles them:
https://github.com/ocornut/imgui/blob/6a161b878943241ddecbeee4ae27103dbd2d33d0/backends/imgui_impl_opengl2.cpp#L163

ImGUI IO assertion failure

With the most recent versions of ImGUI and Magnum, ImGUI example crashes with the following message:

external/imgui/imgui.cpp:7707: void ImGui::ErrorCheckNewFrameSanityChecks(): Assertion `g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < ((int)(sizeof(g.IO.KeysDown) / sizeof(*(g.IO.KeysDown)))) && "io.KeyMap[] contains an out of bound value (need to be 0..511, or -1 for unmapped key)"' failed.

Perhaps it is related to this discussion?
ocornut/imgui#2269 (comment)

[arch] build fails - lwop_ivec3 not defined

I have glm-0.9.9.8-1 installed. Build fails on following file/line:

error log
 Build files have been written to: /home/marin/magnum-root/magnum-integration/build
[3/4] Building CXX object src/Magnum/GlmIntegration...eFiles/GlmIntegrationTest.dir/IntegrationTest.cpp.o
FAILED: src/Magnum/GlmIntegration/Test/CMakeFiles/GlmIntegrationTest.dir/IntegrationTest.cpp.o 
/usr/bin/c++  -DCORRADE_IS_DEBUG_BUILD -I../src -Isrc -isystem /usr/include/MagnumExternal/OpenGL -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -g   -std=c++11 -Wall -Wextra -Wold-style-cast -Winit-self -Werror=return-type -Wmissing-declarations -Wpedantic -fvisibility=hidden -fvisibility-inlines-hidden -Wzero-as-null-pointer-constant -Wdouble-promotion -MD -MT src/Magnum/GlmIntegration/Test/CMakeFiles/GlmIntegrationTest.dir/IntegrationTest.cpp.o -MF src/Magnum/GlmIntegration/Test/CMakeFiles/GlmIntegrationTest.dir/IntegrationTest.cpp.o.d -o src/Magnum/GlmIntegration/Test/CMakeFiles/GlmIntegrationTest.dir/IntegrationTest.cpp.o -c ../src/Magnum/GlmIntegration/Test/IntegrationTest.cpp
../src/Magnum/GlmIntegration/Test/IntegrationTest.cpp: In member function ‘void Magnum::GlmIntegration::Test::{anonymous}::IntegrationTest::debugVec()’:
../src/Magnum/GlmIntegration/Test/IntegrationTest.cpp:470:25: error: ‘lowp_ivec3’ is not a member of ‘glm’; did you mean ‘lowp_dvec3’?
  470 |     Debug{&out} << glm::lowp_ivec3{1, 42, -3};
      |                         ^~~~~~~~~~
      |                         lowp_dvec3
ninja: build stopped: subcommand failed.
==> ERROR: A failure occurred in build().
    Aborting...

I have searched for this lowp_ivec3 and on my machine it is defined in /usr/include/glm/gtc/type_precision.hpp:1295

On the official API doc of type_precision.hpp, in that same file type is not defined nor mentioned.
After some digging, I found in API docs that lwop_ivec3 is defined in glm/ext/vector_int3_precision.hpp.

I am totally confused now, I honestly just want build to pass at this point.

ImGuiIntegration memory corruption when destroying context with custom font loaded via AddFontFromMemoryTTF

The problem

I apologise if this is not MagnumImGuiIntegration problem but ImGui problem instead. I am not sure what is the exact cause of this problem so I have started here.

I am following the ImGui example from here: https://doc.magnum.graphics/magnum/examples-imgui.html

I am trying to load a custom font from a ttf file. Had to slightly modify the original example below into the following:

IMGUI_CHECKVERSION();
context = ImGui::CreateContext();

const Utility::Resource rs{ "fonts" };
const auto ttfRaw = rs.getRaw(<font name here>);
ImGuiIO& io = ImGui::GetIO();
imguiFont = io.Fonts->AddFontFromMemoryTTF(reinterpret_cast<void*>(const_cast<char*>(ttfRaw.data())), ttfRaw.size(), 18.0f);
IM_ASSERT(imguiFont != NULL);
io.Fonts->Build();

// Passing ImGui context into the constructor!
_imgui = ImGuiIntegration::Context(*context, Vector2{windowSize()}/dpiScaling(), windowSize(), framebufferSize());

I am able to draw the ImGui with the custom font without issues. However when the _imgui falls out of scope (on program exit), ImGui tries to delete invalid memory.

The exact traceback:

MagnumImGuiIntegration-d.dll!FreeWrapper(void * ptr, void * user_data) Line 1065
MagnumImGuiIntegration-d.dll!ImGui::MemFree(void * ptr) Line 2966
MagnumImGuiIntegration-d.dll!ImFontAtlas::ClearInputData() Line 1462
MagnumImGuiIntegration-d.dll!ImFontAtlas::Clear() Line 1500
MagnumImGuiIntegration-d.dll!ImFontAtlas::~ImFontAtlas() Line 1452
[External Code]	
MagnumImGuiIntegration-d.dll!IM_DELETE<ImFontAtlas>(ImFontAtlas * p) Line 1534
MagnumImGuiIntegration-d.dll!ImGui::Shutdown(ImGuiContext * context) Line 3570
MagnumImGuiIntegration-d.dll!ImGui::DestroyContext(ImGuiContext * ctx) Line 3035
MagnumImGuiIntegration-d.dll!Magnum::ImGuiIntegration::Context::~Context() Line 137
magnum-imgui.exe::ImGuiExample::~ImGuiExample()

Inside of the FreeWrapper it is trying to call free(); with pointer that comes from my exe. (Visual Studio reports that the address of the pointer belongs to the exe, not to the Magnum DLL.)

Workaround

It seems that if I add io.Fonts->ConfigData.clear(); before creating ImGuiIntegration::Context it works without issues. So I get the following:

ImGuiIO& io = ImGui::GetIO();
imguiFont = io.Fonts->AddFontFromMemoryTTF(reinterpret_cast<void*>(const_cast<char*>(ttfRaw.data())), ttfRaw.size(), 18.0f);
IM_ASSERT(imguiFont != NULL);
io.Fonts->Build();
io.Fonts->ConfigData.clear();

No memory corruption on exit. But why?

Additional info

OS: Windows 10
Compiler: Visual Studio 15 2017 Win64 (14.16.27023)
Configuration: Debug
Magnum integration version: Commit 31ccefc
ImGui version: Commit ocornut/imgui@79f7778
Haven't tried Linux or OSX

BulletIntegration broken on Ubuntu 16.06 with GCC 5.4

The annotation:

CORRADE_UNUSED

Is used on member functions:

drawContactPoint
draw3dText

in file:

BulletIntegration/DebugDraw.h

This does not appear to be recognized as a valid annotation in GCC 5.4 on Ubuntu 16.06, possibly due to a lacking include? This is precluding me from compiling, but removing the annotation is a quick and easy fix.

BulletIntegration: Usage

I'm having a little bit of trouble figuring out exactly how BulletIntegration works.

I understand:

  • [ x] - MotionState is a feature you hang off of an object you want to physic-ify
  • [ x] - You can use the simplified converters to convert from Magnum collision shapes to Bullet collision shapes

I don't understand:

  • - How to idiomatically hook these two things together to get a working physics object
  • - Why MotionState doesn't provide some simple helper functions to set common things like restitution and friction, so we don't need to know exactly how Bullet works for simple things

Do we have any examples or anything? I'm sorry if I simply missed them!

error: no member named 'RGBA8' in 'Magnum::GL::TextureFormat'(Cross-compiling for Emscripten)

when build target wasm:

C:\workspace\magnum-integration\build-emscripten>cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten-wasm.cmake"  -DCMAKE_BUILD_TYPE=Release  -DEMSCRIPTEN_PREFIX="C:/workspace/emsdk/fastcomp/emscripten" -DCMAKE_PREFIX_PATH="C:/lib/emscripten/system" -DWITH_IMGUI=ON -DIMGUI_DIR="C:/workspace/imgui" -DCMAKE_INSTALL_PREFIX="C:/lib/emscripten/system" -DMAGNUM_DEPLOY_PREFIX="C:/http/magnum" -DCMAKE_FIND_ROOT_PATH="C:/lib/emscripten/system" -DCMAKE_MAKE_PROGRAM="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe"
-- Found Magnum: C:/lib/emscripten/system/include
-- Found Magnum: C:/lib/emscripten/system/include  found components:  GL
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_TOOLCHAIN_FILE


-- Build files have been written to: C:/workspace/magnum-integration/build-emscripten

Got the error:

C:\workspace\magnum-integration\build-emscripten>cmake --build . --target install
[2/8] Building CXX object src/Magnum/ImGuiIntegration/CMakeFiles/MagnumImGuiIntegration.dir/Context.cpp.o
FAILED: src/Magnum/ImGuiIntegration/CMakeFiles/MagnumImGuiIntegration.dir/Context.cpp.o
C:\workspace\emsdk\fastcomp\emscripten\em++.bat  -DIMGUI_USER_CONFIG=\"Magnum/ImGuiIntegration/visibility.h\" -I../src -Isrc -isystem C:/lib/emscripten/system/include/MagnumExternal/OpenGL -isystem C:/lib/emscripten/system/include -isystem C:/workspace/imgui -s WASM=1 -Wno-warn-absolute-paths -DNDEBUG -O3 -O3 -DNDEBUG   -std=c++11 -Wall -Wextra -Wold-style-cast -Winit-self -Werror=return-type -Wmissing-declarations -pedantic -fvisibility=hidden -fvisibility-inlines-hidden -Wmissing-prototypes -Wno-shorten-64-to-32 -MD -MT src/Magnum/ImGuiIntegration/CMakeFiles/MagnumImGuiIntegration.dir/Context.cpp.o -MF src\Magnum\ImGuiIntegration\CMakeFiles\MagnumImGuiIntegration.dir\Context.cpp.o.d -o src/Magnum/ImGuiIntegration/CMakeFiles/MagnumImGuiIntegration.dir/Context.cpp.o -c ../src/Magnum/ImGuiIntegration/Context.cpp
../src/Magnum/ImGuiIntegration/Context.cpp:226:47: error: no member named 'RGBA8' in 'Magnum::GL::TextureFormat'
            .setStorage(1, GL::TextureFormat::RGBA8, image.size())
                           ~~~~~~~~~~~~~~~~~~~^
1 error generated.
shared:ERROR: 'C:/workspace/emsdk/fastcomp/fastcomp/bin\clang++.exe -target asmjs-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=38 -D__EMSCRIPTEN_tiny__=46 -D_LIBCPP_ABI_VERSION=2 -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystemC:\workspace\emsdk\fastcomp\emscripten\system\include\libcxx -Xclang -isystemC:\workspace\emsdk\fastcomp\emscripten\system\lib\libcxxabi\include -Xclang -isystemC:\workspace\emsdk\fastcomp\emscripten\system\include\compat -Xclang -isystemC:\workspace\emsdk\fastcomp\emscripten\system\include -Xclang -isystemC:\workspace\emsdk\fastcomp\emscripten\system\include\libc -Xclang -isystemC:\workspace\emsdk\fastcomp\emscripten\system\lib\libc\musl\arch\emscripten -Xclang -isystemC:\workspace\emsdk\fastcomp\emscripten\system\local\include -DIMGUI_USER_CONFIG="Magnum/ImGuiIntegration/visibility.h" -I../src -Isrc -isystem C:/lib/emscripten/system/include/MagnumExternal/OpenGL -isystem C:/lib/emscripten/system/include -isystem C:/workspace/imgui -DNDEBUG -O3 -O3 -DNDEBUG -std=c++11 -Wall -Wextra -Wold-style-cast -Winit-self -Werror=return-type -Wmissing-declarations -pedantic -fvisibility=hidden -fvisibility-inlines-hidden -Wmissing-prototypes -Wno-shorten-64-to-32 -MD -MT src/Magnum/ImGuiIntegration/CMakeFiles/MagnumImGuiIntegration.dir/Context.cpp.o -MF src\Magnum\ImGuiIntegration\CMakeFiles\MagnumImGuiIntegration.dir\Context.cpp.o.d -c -DEMSCRIPTEN -mllvm -disable-llvm-optzns ../src/Magnum/ImGuiIntegration/Context.cpp -Xclang -disable-O0-optnone -Xclang -isystemC:\workspace\emsdk\fastcomp\emscripten\system\include\SDL -c -o src/Magnum/ImGuiIntegration/CMakeFiles/MagnumImGuiIntegration.dir/Context.cpp.o -emit-llvm' failed (1)
[6/8] Building CXX object src/Magnum/ImGuiIntegration/CMakeF...es/MagnumImGuiIntegration.dir/C_/workspace/imgui/imgui.cpp.o
C:/workspace/imgui/imgui.cpp:13998:27: warning: unused variable 'backup_dock_id' [-Wunused-variable]
            const ImGuiID backup_dock_id = window->DockId;
                          ^
1 warning generated.
ninja: build stopped: subcommand failed.

Issue with building DART example

When building DART example with magnum-integration, I encountered the following issue

CMake Error at /usr/local/Cellar/cmake/3.14.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Could NOT find MagnumIntegration (missing: Dart) Call Stack (most recent call first): /usr/local/Cellar/cmake/3.14.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) /Users/jerryhe/Desktop/Projects/habitat/magnum-examples/modules/FindMagnumIntegration.cmake (find_package_handle_standard_args)

I use magnum-integration installed from brew on MacOS.

I also tried building magnum-integration from source, and got the same issue.

My DART example's cmake file looks like the following:

#   This file is part of Magnum.
#
#   Original authors — credit is appreciated but not required:
#
#       2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 —
#           Vladimír Vondruš <[email protected]>
#       2019 — Konstantinos Chatzilygeroudis <[email protected]>
#
#   This is free and unencumbered software released into the public domain.
#
#   Anyone is free to copy, modify, publish, use, compile, sell, or distribute
#   this software, either in source code form or as a compiled binary, for any
#   purpose, commercial or non-commercial, and by any means.
#
#   In jurisdictions that recognize copyright laws, the author or authors of
#   this software dedicate any and all copyright interest in the software to
#   the public domain. We make this dedication for the benefit of the public
#   at large and to the detriment of our heirs and successors. We intend this
#   dedication to be an overt act of relinquishment in perpetuity of all
#   present and future rights to this software under copyright law.
#
#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
#   THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
#   IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
#   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

cmake_minimum_required(VERSION 3.1)

project(MagnumDartExample)

# Add module path in case this is project root
if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/../../modules/")
endif()

if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID)
    set(DARTEXAMPLE_DIR ".")
else()
    set(DARTEXAMPLE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()

# We need the URDF loader of DART for this example
find_package(DART 6.0.0 CONFIG REQUIRED OPTIONAL_COMPONENTS io-urdf utils-urdf)

if(NOT (DART_utils-urdf_FOUND OR DART_io-urdf_FOUND) OR (DART_VERSION STRLESS 6.0.0))
    message(FATAL_ERROR "DART version >= 6 and DART urdf library are required for this example!")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
               ${CMAKE_CURRENT_BINARY_DIR}/configure.h)

find_package(Magnum REQUIRED
    GL
    MeshTools
    Primitives
    SceneGraph
    Sdl2Application
    Shaders
    Trade)
find_package(MagnumIntegration REQUIRED Dart)


set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)

add_executable(magnum-dart DartExample.cpp)
target_include_directories(magnum-dart PUBLIC ${DART_INCLUDE_DIRS} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
# target_compile_options(magnum-dart PUBLIC -march=native -faligned-new)
target_link_libraries(magnum-dart PRIVATE
    Magnum::Application
    Magnum::MeshTools
    Magnum::Magnum
    Magnum::SceneGraph
    Magnum::Primitives
    Magnum::Shaders
    MagnumIntegration::Dart
    ${DART_LIBRARIES})

install(TARGETS magnum-dart DESTINATION ${MAGNUM_BINARY_INSTALL_DIR})

I wonder if there's anything that I'm missing. Thanks for the help!

Imgui_internal.h IMGUI_API inclusion

When I try to compile implot with magnum imgui integration under windows. I'm getting unresolved external symbol warnings for "ImPool". This is a class located in imgui_internal.h. I can fix the error by replacing current line 638 struct IMGUI_API ImPool to struct __declspec( dllexport ) ImPool. This means that magnum's visibility.h file is likely not included for the imgui_internal header, even though there is IMGUI_API macros there. Unfortunately, I could not figure out how magnum's cmake system does this. Thanks for looking at this.

ArchLinux PKGBUILD needs fixes

Actual PKGBUILD generates several errors for me. It seems be intended as a part of github repo, while usual practise is to download PKGBUILD only and let the makepkg to download needed sources. Below is version that worked for me:

# Author: mosra <[email protected]>
pkgname=magnum-integration
pkgver=dev
pkgrel=1
pkgdesc="Integration libraries for the Magnum C++11/C++14 graphics engine"
arch=('i686' 'x86_64')
url="https://magnum.graphics"
license=('MIT')
depends=('magnum' 'bullet' 'eigen' 'glm' 'imgui-src')
makedepends=('cmake' 'ninja')
options=(!strip)
provides=('magnum-integration-git')
source=("git+https://github.com/mosra/magnum-integration") # tag: v2020.06
sha256sums=('SKIP')

# _rootdir=$startdir/../../
_rootdir=$startdir/src

build() {
    mkdir -p "build"
    cd "build"

    cmake ../$pkgname \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DIMGUI_DIR=/opt/imgui \
        -DWITH_BULLET=ON \
        -DWITH_DART=OFF \
        -DWITH_EIGEN=ON \
        -DWITH_GLM=ON \
        -DWITH_IMGUI=ON \
        -DBUILD_TESTS=OFF \
        -DBUILD_GL_TESTS=OFF \
        -G Ninja
    ninja
}

check() {
    cd "$_rootdir/build"
    CORRADE_TEST_COLOR=ON ctest --output-on-failure
}

package() {
    cd "$_rootdir/build"
    DESTDIR="$pkgdir/" ninja install
}

However, I had to disable tests due to magnum detection fail (although I have it installed).

CMake error when generating the imgui example

I tried to generate the imgui example and I read that I need to set the IMGUI_DIR to the location of imgui to work. But when generating the project this error shows up:

image

Doing some research I found this and the solution of commenting this lines has worked for me too (but won't compile). IDK if this is a CMake problem or not.

Magnum version: 2019.01
OS: macOS 10.14.5
CMake version: 3.15.0

2D Physics Engine

I noticed Bullet doesn't have a 2D version for its objects. Feasibly, this could be fixed in two ways:

  1. Create a 2D version of the Bullet objects, which would assumedly convert between the 2D magnum API's and a 2D version of Bullet shapes (similar to the current way 3D Bullet integration works, but with the Z axis disabled or some such)
  2. Keep the API similar, but use a Box2D backend, giving similar integration but a different and more suitable backend.

I've got experience with Box2D, if that seems more applicable to what we want in a 2D physics engine, and it's widely used and widely regarded.

Fail to build target iOS

Xcode 12.2
iOS SDK 14.2
CMake 3.19.1

have tried both default magnum toolchain and polly toolchain.

with magnum default toolchain:

➜  build-ios git:(master) cmake .. \
                        -DCMAKE_BUILD_TYPE=Release \
                        -DCMAKE_TOOLCHAIN_FILE=../toolchains/generic/iOS.cmake \
                        -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
                        -DCMAKE_OSX_ARCHITECTURES="arm64" \
                        -DBUILD_STATIC=ON \
                        -DWITH_IMGUI=ON \
                        -DIMGUI_DIR=/Users/jjj/workspace/imgui \
                        -DCMAKE_INSTALL_PREFIX=/Users/jjj/workspace/ios-libs \
                        -DCMAKE_PREFIX_PATH=/Users/jjj/workspace/ios-libs \
                        -G Xcode
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
Could NOT find Corrade (missing: CORRADE_INCLUDE_DIR
_CORRADE_CONFIGURE_FILE)
Call Stack (most recent call first):
/Applications/CMake.app/Contents/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:577 (_FPHSA_FAILURE_MESSAGE)
modules/FindCorrade.cmake:311 (find_package_handle_standard_args)
modules/FindMagnum.cmake:233 (find_package)
CMakeLists.txt:37 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Users/jjj/workspace/magnum-integration/build-ios/CMakeFiles/CMakeOutput.log".

with polly toolchain:

➜  build-ios git:(master) export POLLY_ROOT=$HOME/workspace/polly
➜  build-ios git:(master) export XCODE_XCCONFIG_FILE=$HOME/workspace/polly/scripts/NoCodeSign.xcconfig
➜  build-ios git:(master) export POLLY_IOS_DEVELOPMENT_TEAM="xxxxxxxx"
➜  build-ios git:(master) cmake .. \
                        -DCMAKE_BUILD_TYPE=Release \
                        -DCMAKE_TOOLCHAIN_FILE=${POLLY_ROOT}/ios-14-0-dep-9-3-arm64.cmake \
                        -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
                        -DCMAKE_OSX_ARCHITECTURES="arm64" \
                        -DBUILD_STATIC=ON \
                        -DWITH_IMGUI=ON \
                        -DIMGUI_DIR=/Users/jjj/workspace/imgui \
                        -DCMAKE_INSTALL_PREFIX=/Users/jjj/workspace/ios-libs \
                        -DCMAKE_PREFIX_PATH=/Users/jjj/workspace/ios-libs \
                        -G Xcode
-- [polly] Used toolchain: iOS 14.2 / Deployment 9.3 / arm64 / clang / c++14 support
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Corrade: /usr/local/include  found components: Containers rc Utility 
-- Found Magnum: /usr/local/include   
-- LIB_SUFFIX variable is not defined. It will be autodetected now.
-- You can set it manually with -DLIB_SUFFIX=<value> (64 for example)
-- LIB_SUFFIX autodetected as '', libraries will be installed into /Users/jjj/workspace/ios-libs/lib
-- Found Git: /usr/bin/git (found version "2.24.3 (Apple Git-128)") 
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
Could NOT find OpenGL (missing: OPENGL_INCLUDE_DIR)
Call Stack (most recent call first):
/Applications/CMake.app/Contents/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:577 (_FPHSA_FAILURE_MESSAGE)
/Applications/CMake.app/Contents/share/cmake-3.19/Modules/FindOpenGL.cmake:421 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
modules/FindMagnum.cmake:836 (find_package)
src/Magnum/ImGuiIntegration/CMakeLists.txt:29 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Users/jjj/workspace/magnum-integration/build-ios/CMakeFiles/CMakeOutput.log".

SDL/GLFW text input events reported to both keyPressEvent() and textInputEvent()

Hi!
I have set some numeric hotkeys in my magnum application, but now whenever I type numeric input into the text field of e.g. a DragFloat, then I can edit the DragFloat value but the event is still being processed by the magnum application as well.

More specifically:

void MyApplication::keyPressEvent(KeyEvent &event) {
  if (m_imgui.handleKeyPressEvent(event))
    return;

  switch (event.key()) {
  case KeyEvent::Key::One:
    // DO SOMETHING
    break;
[...]

handleKeyPressEvent does not return true for numeric input.
Actually, it does not return true when typing anything (e.g. "r") in the DragFloat text field; however, "r" is not being written into the text field, so one might argue that imgui ignores this event so magnum can process it, though I'm not sure if I wouldn't prefer if as long as the DragFloat text field is active, no key event would be processed by magnum.

Or am I simply missing some line of code?

Linking failure with ImGui HEAD

Looks like ImGui added a new source file in a recent commit: imgui_tables.cpp. This causes linking errors like the following:

imgui.obj : error LNK2019: unresolved external symbol "void __cdecl ImGui::EndTable(void)" (?EndTable@ImGui@@YAXXZ) referenced in function "void __cdecl Im
Gui::ErrorCheckEndFrameRecover(void (__cdecl*)(void *,char const *,...),void *)" (?ErrorCheckEndFrameRecover@ImGui@@YAXP6AXPEAXPEBDZZ0@Z) [C:\code\SaikoEng
ine\bld\vs\external\magnum-integration\src\Magnum\ImGuiIntegration\MagnumImGuiIntegration.vcxproj]
imgui_demo.obj : error LNK2001: unresolved external symbol "void __cdecl ImGui::EndTable(void)" (?EndTable@ImGui@@YAXXZ) [C:\code\SaikoEngine\bld\vs\extern 
al\magnum-integration\src\Magnum\ImGuiIntegration\MagnumImGuiIntegration.vcxproj]

I see the list of expected source file is hard-coded here. Presumably that will need to change, and change in such a way that it supports both old and new versions of ImGui.

BulletIntegration: btlDebugDraw implementation for Magnum.

Hello everybody!

While working with Bullet for a bit, I found this btlDebugDraw class/interface which is supposed to be dervied with implementations for simple primitive drawing methods. It can then be attached to a btCollisionWorld or btDynamicsWorld for example, to provide fast and simple means of debug rendering.

I suggest this could be a great thing to have in the BulletIntegration library, since its code would most likely be common for all Magnum apps which use bullet.

(This is in no way urgent and if I have time, I might event implement this myself later next year. Just wanted to put that out there for discussion.)

Greetings, Squareys

ImGuiIO modifier key states incorrect under Linux/X11 (glfw)

When using the ImGui Integration under Linux/X11 the ImGuiIO.KeyCtrl/Shift/Alt/Super states aren't always correct. The modifiers in the key events contain the modifier state just before the event. When pressing the Shift key, for example, this results in the following behaviour:

  • Pressing the shift key down results in a key event without the shift modifier, ImGuiIO.KeyShift = false
  • Releasing the shift key results in a key event with the shift modifier, ImGuiIO.KeyShift = true

For common shortcuts, like Ctrl+C this doesn't cause too much trouble as the key events for the non-modifier key contain the right modifier state and will result in the ImGuiIO.KeyCtrl state being correct. But when combined with mouse events, the incorrect modifier state causes unexpected behaviour. Holding down a modifier key having no effect and the modifier state 'sticking around' after letting go of a modifier key.

This is likely a regression introduced by switching to ImGui's event based input model. See glfw/glfw#1630 for more details and some possible workarounds (though, sadly, none of the workarounds seem ideal).

ImFontAtlas::TexID remains unset after a call to ImGuiIntegration::Context::relayout

ImGuiIntegration::Context::relayout() creates the GL::Texture2D for the font atlas, but does not set the TexID in the ImFontAtlas object.

I may have just missed something, but I couldn't find any way to access the imgui font atlas texture.

Simple fix tho!

Around there this line should fix it:

io.Fonts->SetTexID(reinterpret_cast<ImTextureID>(&_texture));
or
io.Fonts->SetTexID(&_texture);

I am unsure if the reinterpret cast is needed, I would expect it, because ImTextureID is void*.

It seems like static_cast<ImTextureID>() is used elsewhere, so idk.

Custom flags for Dear ImGui integration

I have this problem: https://stackoverflow.com/a/57608651/4818802

I want to add target_compile_options(??? PUBLIC $<$<CXX_COMPILER_ID:GNU>:-D__USE_MINGW_ANSI_STDIO=1>) so that ImGui is built with this flag and the flag is forwarded to my project. What would be a correct target? I can not specify this property on MagnumIntegration::ImGui because it is an ALIAS target.

I'm also open to other solutions - preferably through CMake but without touching stuff like CMAKE_CXX_FLAGS.

Redefinition errors including ImGuiIntegration/Context.hpp multiple times

When including the ImGuiIntegration/Context.hpp multiple times (when for example there are two files that include ImGuiIntegration/Context.hpp and these files are included in another file) the compiler gives several redefinition errors.
This is due to missing #pragma once or #ifndef/#define in the ImGuiIntegration/Context.hpp file.

ImGui Static Lib Stuff

vcpkg's imgui is a static lib, while link to this version of lib may due to imgui.lib multiple link to the executable, both in imgui-example.exe and magnum-integration.dll.
So Is it possible to add imgui repos as a external libs in this repos? Or make an PR to vcpkg repos ?
for details, vcpkg/ports/imgui/CMakeLists.txt

add_library(${PROJECT_NAME}
    ${IMGUI_INCLUDES_PUBLIC}
    ${IMGUI_INCLUDES_PRIVATE}
    ${IMGUI_SOURCES}
)

OVR SDK integration cleanup

Hi @Squareys,

While merging #12 I went over the code and did a rough formatting and documentation cleanup. Few things were not clear to me as I'm not very familiar with the API, so once you get some spare time, can you go through the following issues?

  • The HMD -> Session rename is not fully done, some function parameters are still named hmd though the type is now Session
  • Similarly with texture set -> texture swap chain, types don't match function parameter names and docs
  • There are some types still named Hmd but used in the Session class, is that okay?
  • Is OvrIntegration/HmdEnum.h still named correctly? What about just OvrIntegration/Enums.h?
  • The documentation of Session class functions mentions things like
         * If you are using `ovrTrackerPoses` then you will need to call
         * `ovr_GetTrackerPose` after this, because the sensor position(s) will
         * change as a result of this.

More occurences elsewhere. I think the docs should mention the wrapper APIs and not the original OVR SDK APIs.

  • The HmdTrackingCapability and HmdTrackingCapabilities don't seem to be used anywhere and reference removed Hmd::configureTracking() function. Similarly with StatusFlag and StatusFlags. Should they be removed also?
  • The TimewarpProjectionDescription class doesn't seem to be used at all.
  • What does this mean (documentation of StatusFlag)?

The values must be the same as in enum StatusBits.

  • Shouldn't Session::pollController() return the InputState instead of passing it by reference? Isn't the method chaining useless in this case?
  • The HmdStatusFlag enum is used only internally, shouldn't it be hidden from public API (putting it in Implementation namespace or in privates of Session class, e.g.)
  • Avoid repetition by renaming Session::sessionStatus() to just Session::status()
  • Session::ovrEyePoses() returns ovrPosef* but the docs say that this is actually a two-element array. I suggest returning Containers::StaticArrayView<2, ovrPosef> instead.
  • Session::headPoseState(), Session::calibratedOrigin(), Session::eyePoses() and Session::handPoseStates() documentation is copy-pasted four times and doesn't match the code
  • Can we avoid std::string in the Error struct? What about just mirroring the original char[512]?

imgui_stdlib is not being detected

I found myself using imgui_stdlib.h file which contains some overrides for using std libraries with ImGUI. However Magnum does not include those when finding components. A quick fix that worked for me was:

File FindImGui.cmake
Line 101: foreach(_file imgui imgui_widgets imgui_draw imgui_demo **imgui_stdlib**)

Next a new entry will appear in cmake to point to that file. Hope that helps someone.

Remove ImGui dependency on ApplicationServices once 1.72b is widely used enough

I am trying to build the magnum integration with imgui on mac, but the build always fails with the following error:

Undefined symbols for architecture x86_64:
  "_CFArrayGetCount", referenced from:
      GetClipboardTextFn_DefaultImpl(void*) in imgui.cpp.o
  "_CFDataCreate", referenced from:
      SetClipboardTextFn_DefaultImpl(void*, char const*) in imgui.cpp.o
  "_CFDataGetBytes", referenced from:
      GetClipboardTextFn_DefaultImpl(void*) in imgui.cpp.o
  "_CFDataGetLength", referenced from:
      GetClipboardTextFn_DefaultImpl(void*) in imgui.cpp.o
  "_CFRelease", referenced from:
      GetClipboardTextFn_DefaultImpl(void*) in imgui.cpp.o
      SetClipboardTextFn_DefaultImpl(void*, char const*) in imgui.cpp.o
  "_PasteboardClear", referenced from:
      SetClipboardTextFn_DefaultImpl(void*, char const*) in imgui.cpp.o
  "_PasteboardCopyItemFlavorData", referenced from:
      GetClipboardTextFn_DefaultImpl(void*) in imgui.cpp.o
  "_PasteboardCopyItemFlavors", referenced from:
      GetClipboardTextFn_DefaultImpl(void*) in imgui.cpp.o
  "_PasteboardCreate", referenced from:
      GetClipboardTextFn_DefaultImpl(void*) in imgui.cpp.o
      SetClipboardTextFn_DefaultImpl(void*, char const*) in imgui.cpp.o
  "_PasteboardGetItemCount", referenced from:
      GetClipboardTextFn_DefaultImpl(void*) in imgui.cpp.o
  "_PasteboardGetItemIdentifier", referenced from:
      GetClipboardTextFn_DefaultImpl(void*) in imgui.cpp.o
  "_PasteboardPutItemFlavor", referenced from:
      SetClipboardTextFn_DefaultImpl(void*, char const*) in imgui.cpp.o
  "_PasteboardSynchronize", referenced from:
      GetClipboardTextFn_DefaultImpl(void*) in imgui.cpp.o
  "___CFConstantStringClassReference", referenced from:
      CFString in imgui.cpp.o
      CFString in imgui.cpp.o
  "_kCFAllocatorDefault", referenced from:
      SetClipboardTextFn_DefaultImpl(void*, char const*) in imgui.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/Magnum/ImGuiIntegration/libMagnumImGuiIntegration.2.2.dylib] Error 1
make[1]: *** [src/Magnum/ImGuiIntegration/CMakeFiles/MagnumImGuiIntegration.dir/all] Error 2
make: *** [all] Error 2

which are windows specific functions, I tried building it on windows the same way I did on mac and it worked. So I believe it is a mac specific issue.

Anyway to overcome this issue?

Could NOT find MagnumIntegration (missing: Dart)

Hi,

I am trying to build the dart example on Ubuntu.

I get the following error:
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find MagnumIntegration (missing: Dart)
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake/MagnumIntegration/FindMagnumIntegration.cmake:307 (find_package_handle_standard_args)
/usr/share/cmake/MagnumIntegration/MagnumIntegrationConfig.cmake:26 (include)
CMakeLists.txt:62 (find_package)

Please help.

ImGui fonts not working

I'm having problems to use custom fonts with ImGui. Normally in ImGui doing AddFontFromFileTTF(path) will use automatically that font as the default. But when I try to use it with magnum it does nothing: the default imgui font remains. I also tried to check if the font is NULL but it wasn't.
The strange fact is that when I try to use PushFont(font)/PopFont() it give me assertion error here. Now IDK if maybe there is something that I am missing to use fonts or it is a bug.

ImGui version: docking, latest commit ocornut/imgui@9f35ba8 (I even tried the 1.71 release)
ImGuiIntegration: latest commit b157344

I'm using Sdl2Application if that's relevant.

vcpgk imgui

I tried switching from manually downloaded/built/linked corrade magnum imgui and magnum-imgui to vcpkg, now that magnum-integration[imgui] is listed.

However, there seem to be problems stemming from the capitalization of the imgui library.
vcpkg imgui is lowercase and will then be used via

find_package(imgui CONFIG REQUIRED)
target_link_libraries(main PRIVATE imgui::imgui)

whereas the FindMagnumIntegration.cmake is set up to use ImGui::ImGui.

I tried to no avail modifying the file to the lower case version but something always seemed to go wrong, maybe trying to find imgui headers, which are not set in vcpkg's imguiConfig.cmake.

Maybe the easiest solution for me would be to modify vcpkg's imgui instead, but I think if imgui will stay lowercase then magnum-integration should likely adapt to this.

Any local/temporary fix would be appreciated!

Add Support for Dear ImGui extensions

I've set up a Magnum project with ImGui integration enabled, and I want to try out some ImGui extensions. A lot of them (such as ImGuizmo) are laid out as just a set of cpp/h files to be added directly to a project in the same way Dear ImGui itself is added.

I'm pretty new to CMake, so I'm not sure how to set this up myself with Magnum's CMake structure. It would be nice if I could specify CMake variables to provide any number of arbitrary cpp/h files to be added alongside the base Dear ImGui files. And to make things easier with git subdirectories, it would be best if these files didn't have to actually be in the same directory (IMGUI_DIR).

ImGuiIntegration: glUseProgram(0) called anywhere in drawEvent causes imgui to not render

I know, another one.

I'm not an openGL expert, so I may just be misunderstanding.
but..
glUseProgram(0) should reset the shader program, and is not an error
ImGuiIntegration::Context::draw() should call glUseProgram(shader_id) in some way

Calling glUseProgram(0) anywhere in the drawEvent causes ImGuiIntegration::Context to not draw anything because (as I understand it) its not using the correct shader.
If I put glUseProgram(_imgui._shader.id()); right before ImGuiIntegration::Context::draw() then everything works.

There is a similar problem calling glBindVertexArray(0)

Am I missing something?

I tested this using
https://github.com/mosra/magnum-examples/blob/master/src/imgui/ImGuiExample.cpp
With the latest on corrade, magnum, and magnum-integration
And with v2019.10 on corrade, magnum, and magnum-integration

Consider switching from the legacy Find*.cmake modules to install(TARGETS ... EXPORT ...)

Instead of writing custom Find*.cmake modules

set(MagnumIntegration_MODULES
FindMagnumIntegration.cmake
MagnumIntegrationConfig.cmake)
install(FILES ${MagnumIntegration_MODULES} DESTINATION ${MAGNUMINTEGRATION_CMAKE_MODULE_INSTALL_DIR})

...consider using install(TARGETS ... EXPORT) so that CMake would generate a safer module for find_package.

For context, I'm observing some confusing issues with the Find-module when trying to build habitat-sim (https://github.com/SomeoneSerge/dust3r.nix/blob/35377e113d4b03e4c625e270554d4d1b1344419a/nix/magnum-integration/package.nix):

...
magnum-integration> -- Install configuration: "Release"
magnum-integration> -- Installing: /nix/store/7d4q02xsprmlsghak8769zj4prb9l5qq-magnum-integration-unstable-2024-03-07/share/cmake/MagnumIntegration/FindMagnumIntegration.cmake
magnum-integration> -- Installing: /nix/store/7d4q02xsprmlsghak8769zj4prb9l5qq-magnum-integration-unstable-2024-03-07/share/cmake/MagnumIntegration/MagnumIntegrationConfig.cmake
magnum-integration> -- Installing: /nix/store/7d4q02xsprmlsghak8769zj4prb9l5qq-magnum-integration-unstable-2024-03-07/include/Magnum/versionIntegration.h
magnum-integration> -- Installing: /nix/store/7d4q02xsprmlsghak8769zj4prb9l5qq-magnum-integration-unstable-2024-03-07/include/Magnum/EigenIntegration/DynamicMatrixIntegration.h
magnum-integration> -- Installing: /nix/store/7d4q02xsprmlsghak8769zj4prb9l5qq-magnum-integration-unstable-2024-03-07/include/Magnum/EigenIntegration/GeometryIntegration.h
magnum-integration> -- Installing: /nix/store/7d4q02xsprmlsghak8769zj4prb9l5qq-magnum-integration-unstable-2024-03-07/include/Magnum/EigenIntegration/Integration.h
...
habitat-sim> CMake Error at /nix/store/paxnwg89pdx4car5fj84mmiprg952459-cmake-3.28.2/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
habitat-sim>   Could NOT find MagnumIntegration (missing: Eigen)
habitat-sim>
habitat-sim>       Reason given by package: Eigen is not built by default. Make sure you enabled MAGNUM_WITH_EIGEN when building Magnum Integration.
...

Thanks!

Key Events have changed in ImGui

In the latest version of ImGui the key events enums have shifted by 512 preventing proper capture of keys such as delete and backspace. Now the function "AddKeyEvent" has to be used to do the translation.

I think the issue can be fixed by replacing the switch in src/Magnum/ImGuiIntegration/Context.hpp file to:

switch(event.key()) {
        /* LCOV_EXCL_START */
        case KeyEvent::Key::LeftShift:
        case KeyEvent::Key::RightShift:
            io.KeyShift = value;
            break;
        case KeyEvent::Key::LeftCtrl:
        case KeyEvent::Key::RightCtrl:
            io.KeyCtrl = value;
            break;
        case KeyEvent::Key::LeftAlt:
        case KeyEvent::Key::RightAlt:
            io.KeyAlt = value;
            break;
        case KeyEvent::Key::LeftSuper:
        case KeyEvent::Key::RightSuper:
            io.KeySuper = value;
            break;
        case KeyEvent::Key::Tab:
            io.AddKeyEvent(ImGuiKey_Tab, value);
            break;
        case KeyEvent::Key::Up:
            io.AddKeyEvent(ImGuiKey_UpArrow, value);
            break;
        case KeyEvent::Key::Down:
            io.AddKeyEvent(ImGuiKey_DownArrow, value);
            break;
        case KeyEvent::Key::Left:
            io.AddKeyEvent(ImGuiKey_LeftArrow, value);
            break;
        case KeyEvent::Key::Right:
            io.AddKeyEvent(ImGuiKey_RightArrow, value);
            break;
        case KeyEvent::Key::Home:
            io.AddKeyEvent(ImGuiKey_Home, value);
            break;
        case KeyEvent::Key::End:
            io.AddKeyEvent(ImGuiKey_End, value);
            break;
        case KeyEvent::Key::PageUp:
            io.AddKeyEvent(ImGuiKey_PageUp, value);
            break;
        case KeyEvent::Key::PageDown:
            io.AddKeyEvent(ImGuiKey_PageDown, value);
            break;
        case KeyEvent::Key::Enter:
        case KeyEvent::Key::NumEnter:
            io.AddKeyEvent(ImGuiKey_Enter, value);
            break;
        case KeyEvent::Key::Esc:
            io.AddKeyEvent(ImGuiKey_Escape, value);
            break;
        case KeyEvent::Key::Space:
            io.AddKeyEvent(ImGuiKey_Space, value);
            break;
        case KeyEvent::Key::Backspace:
            io.AddKeyEvent(ImGuiKey_Backspace, value);
            break;
        case KeyEvent::Key::Delete:
            io.AddKeyEvent(ImGuiKey_Delete, value);
            break;
        case KeyEvent::Key::A:
            io.AddKeyEvent(ImGuiKey_A, value);
            break;
        case KeyEvent::Key::C:
            io.AddKeyEvent(ImGuiKey_C, value);
            break;
        case KeyEvent::Key::V:
            io.AddKeyEvent(ImGuiKey_V, value);
            break;
        case KeyEvent::Key::X:
            io.AddKeyEvent(ImGuiKey_X, value);
            break;
        case KeyEvent::Key::Y:
            io.AddKeyEvent(ImGuiKey_Y, value);
            break;
        case KeyEvent::Key::Z:
            io.AddKeyEvent(ImGuiKey_Z, value);
            break;
        /* LCOV_EXCL_STOP */

        /* Unknown key, do nothing */
        default: return false;
    }

BulletIntegration: conversion of Magnum mesh data into Bullet collision mesh [snippet]

As @Squareys mentioned in #19, here's his code snippet for creating Bullet collision mesh directly from Magnum mesh data, licensed under CC0: https://groups.google.com/forum/#!topic/magnum-engine/V3iL35umkwU

/* source mesh, a valid pointer to data which needs to persist
 * for the resulting shape to stay valid */
MeshData3D* mesh = /* ... */;
/* resulting shape */
btCollisionShape* shape = nullptr;

/* this code only works for Triangles only meshes */
if (mesh->primitive() == MeshPrimitive::Triangles) {
  /* create a bullet indexed mesh from our mesh data */
  btIndexedMesh bulletMesh;
  bulletMesh.m_numTriangles = mesh->indices().size()/3;
  bulletMesh.m_triangleIndexBase = (const unsigned char *)mesh->indices().data();
  bulletMesh.m_triangleIndexStride = 3 * sizeof(UnsignedInt);
  bulletMesh.m_numVertices = mesh->positions(0).size();
  bulletMesh.m_vertexBase = (const unsigned char *)mesh->positions(0).data();
  bulletMesh.m_vertexStride = sizeof(Vector3);
  bulletMesh.m_indexType = PHY_INTEGER;
  bulletMesh.m_vertexType = PHY_FLOAT;

  btTriangleIndexVertexArray *pTriMesh = new btTriangleIndexVertexArray();
  pTriMesh->addIndexedMesh(bulletMesh, PHY_INTEGER);

  shape = new btBvhTriangleMeshShape(pTriMesh, true, true);
} else {
  Error() << "Unsupported mesh primitive type while converting Magnum mesh to Bullet mesh.";
}

Since btConvexHullShape is more efficient with smaller meshes (see http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Shapes#Meshes) here is another code snippet which you can replace the contents of the if block with:

shape = new btConvexHullShape((const btScalar *)mesh->positions(0).data(), mesh->positions(0).size(), sizeof(Vector3));       

Note that it is recommended to use meshes of less than around 100 vertices for bullet convex hulls (see the link above). Also, convex hulls are, obviously, convex. They might not be suited for you individual collision mesh. (Also note, that I didn't test that line very much)

Just putting it here since the Google Groups forum seems to be quite abandoned now (which I completely understand, the UI is horrible). I think this snippet may even be useful and general enough to include directly in the Bullet Integration library.

Crash in magnum-imgui Example Program

I have successfully built and compiled the magnum-imgui example program, but it crashes upon execution, and I have not modified any of the source code. The crash information is "Unhandled exception thrown: read access violation. this was 0xFFFFFFFFFFFFFFFF." The crash details are shown in the image below:
image
Call Stack:
image
ImGui Example crash position:
image
Memory of Fonts:
image

Before this, I was able to run the magnum-triangle and magnum-animated-gif example programs, which are part of the magnum-examples project. Other dependencies were installed using vcpkg, but magnum-integration and imgui were built together as submodules of the magnum-examples cmake project.

Minor LibOvrIntegration API changes

  • rename all getSomething() methods to something() for consistency (Hmd and SwapTextureSet classes)
  • return std::array<DualQuaternion, 2> from Hmd::getEyePoses()/Hmd::eyePoses() instead of std::unique_ptr, no need to do heap allocation in this case
  • rename LibOvrIntegration::LibOvrContext to just LibOvrIntegration::Context (also consistency, the header is already named like that)

cc @Squareys

ImGui Integration with vcpkg

Hi,

I installed Magnum and its dependencies via vcpkg after giving up on the cmake approach. I then installed imgui integration:
vcpkg install magnum-integration[imgui] --head
I also installed magnum with --head.

When I tried to compile the imgui example in a newly created empty visual studio project (with only single cpp (example) file), I got linker errors (LNK2001 unresolved external symbol) related to imgui integration.

Oh I also slightly modified the example cpp (swapped sdl2application with glfwapplication, for some reason sdl was giving syntax errors).

LNK2001 Unresolved external symbol warnings:

  1. "__declspec(dllimport) public: void __cdecl ImGuiIO::AddInputCharactersUTF8(char const *)" (_imp?AddInputCharactersUTF8@ImGuiIO@@QEAAXPEBD@Z)
  2. "__declspec(dllimport) bool __cdecl ImGui::ColorEdit3(char const *,float * const,int)" (_imp?ColorEdit3@ImGui@@YA_NPEBDQEAMH@Z)
  3. "__declspec(dllimport) void __cdecl ImGui::End(void)" (_imp?End@ImGui@@yaxxz)
  4. "__declspec(dllimport) struct ImGuiIO & __cdecl ImGui::GetIO(void)" (_imp?GetIO@ImGui@@YAAEAUImGuiIO@@xz)
  5. "__declspec(dllimport) bool __cdecl ImGui::SliderFloat(char const *,float *,float,float,char const *,float)" (_imp?SliderFloat@ImGui@@YA_NPEBDPEAMMM0M@Z)
  6. "__declspec(dllimport) bool __cdecl ImGui::Button(char const *,struct ImVec2 const &)" (_imp?Button@ImGui@@YA_NPEBDAEBUImVec2@@@z)
  7. "__declspec(dllimport) void __cdecl ImGui::SetNextWindowPos(struct ImVec2 const &,int,struct ImVec2 const &)" (_imp?SetNextWindowPos@ImGui@@YAXAEBUImVec2@@H0@Z)
  8. "__declspec(dllimport) void __cdecl ImGui::ShowDemoWindow(bool *)" (_imp?ShowDemoWindow@ImGui@@YAXPEA_N@Z)
  9. "__declspec(dllimport) void __cdecl ImGui::SetCurrentContext(struct ImGuiContext *)" (_imp?SetCurrentContext@ImGui@@YAXPEAUImGuiContext@@@z)
  10. "__declspec(dllimport) bool __cdecl ImGui::Begin(char const *,bool *,int)" (_imp?Begin@ImGui@@YA_NPEBDPEA_NH@Z)
  11. "__declspec(dllimport) int __cdecl ImGui::GetMouseCursor(void)" (_imp?GetMouseCursor@ImGui@@yahxz)
  12. "__declspec(dllimport) void __cdecl ImGui::Text(char const *,...)" (_imp?Text@ImGui@@YAXPEBDZZ)
  13. "__declspec(dllimport) void __cdecl ImGui::SetNextWindowSize(struct ImVec2 const &,int)" (_imp?SetNextWindowSize@ImGui@@YAXAEBUImVec2@@h@Z)

Currently installed repos:

C:\Sys\vcpkg>vcpkg list
corrade:x64-windows
corrade[interconnect]:x64-windows
corrade[pluginmanager]:x64-windows
corrade[testsuite]:x64-windows
corrade[utility]:x64-windows
curl:x64-windows
curl[non-http]:x64-windows
curl[ssl]:x64-windows
curl[winssl]:x64-windows
glfw3:x64-windows
imgui:x64-windows
magnum-integration:x64-windows
magnum-integration[imgui]:x64-windows
magnum:x64-windows
magnum[anyaudioimporter]:x64-windows
magnum[anyimageconverter]:x64-windows
magnum[anyimageimporter]:x64-windows
magnum[anysceneimporter]:x64-windows
magnum[audio]:x64-windows
magnum[debugtools]:x64-windows
magnum[gl]:x64-windows
magnum[glfwapplication]:x64-windows
magnum[meshtools]:x64-windows
magnum[primitives]:x64-windows
magnum[scenegraph]:x64-windows
magnum[sdl2application]:x64-windows
magnum[shaders]:x64-windows
magnum[text]:x64-windows
magnum[texturetools]:x64-windows
magnum[trade]:x64-windows
openal-soft:x64-windows
sdl2:x64-windows
zlib:x64-windows

By the way, can I get away with using only vcpkg (no CMake) ? Or do I have to resort to CMake eventually even though I have all Magnum related stuff installed via vcpkg ? I seldom use CMake and I suck at it (last time was 2 years ago, compiling OpenCascade).

ImGui IdxOffset not honored correctly during frame drawing

Using the magnum-integration I get the following graphical glitch with ImGui:
https://github.com/ocornut/imgui/releases/tag/v1.86 (see first section)

I have created an issue there. However, I was pointed out by Ocornut, creator of imgui, it is an issue with the backend (i.e. Magnum) not honoring the ImDrawCmd::IdxOffset correctly.

See the following ImGui issues (all the same):
ocornut/imgui#4887 (this one is mine)
ocornut/imgui#4863
ocornut/imgui#4845

I think the (easy) fix is to change src/Magnum/ImGuiIntegration/Context.cpp line 328 to:

_mesh.setIndexBuffer(_indexBuffer, pcmd->IdxOffset*sizeof(ImDrawIdx),
                sizeof(ImDrawIdx) == 2
                ? GL::MeshIndexType::UnsignedShort
                : GL::MeshIndexType::UnsignedInt);

Lines 310 and 333 then become obsolete. This way the IdxOffset of ImGui is respected and not re-calculated by magnum. With this change the glitch goes away at least in my code. Please check what I did as I'm not fully familiar with your code.

Thanks for looking at this.

Magnum::ImGuiIntegration missing from debian package

Hi all,
I'm trying to work through the Dear ImGui example and currently attempting to get the ImGui Integration set up with a bit of resistance.

I have installed Magnum Integrations through the debian workflow in the documentations. I have also followed the requirements listed on the ImGuiIntegration page to properly set CMake up to find ImGui.

The error I am receiving however is the following

CMake Error at /.../cmake/linux/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find MagnumIntegration (missing: ImGui)

I also noticed in my Magnum build only GlmIntegration and BulletIntegration are present, which means that the debian based installation did not install the necessary files for ImGuiIntegration. I do not know if this is purposeful but I believe if it is then it may be worth adding a note about that on the documentation page here

imgui including problem

Hello, sorry for creating new issue(new in this community, not sure if its the best thing.)

I tried implementing imgui in magnum however, it failed nonstop. you guyz seem to provide findimgui.cmake however imgui itself is not a cmake-able. How should I proceed to include imgui with my magnum developments.

Also since you and imgui is developing nonstop is there a suggesting commit that should work without problem.

Sorry to copy the issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.