games-samples icon indicating copy to clipboard operation
games-samples copied to clipboard

Cannot Build: error: use of undeclared identifier 'ImGuiTableColumnFlags_WidthAutoResize'

Open Yohnny777 opened this issue 2 years ago • 1 comments

\agdk\game_controller\common\demo_scene.cpp:767:53: error: use of undeclared identifier 'ImGuiTableColumnFlags_WidthAutoResize'

Yohnny777 avatar Sep 03 '22 22:09 Yohnny777

The sample is currently built against 1.80 of imgui. Later versions might cause build errors. To check out 1.80, navigate to agdk/third_party/imgui and do something like:

git fetch --all --tags git checkout tags/v1.80 -b v1.80

natetrost avatar Sep 06 '22 20:09 natetrost

Even after checking out v1.80 I am getting:

FAILED: CMakeFiles/game.dir/C_/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/common/demo_scene.cpp.o 
C:\Users\USERNAME\AppData\Local\Android\Sdk\ndk\21.4.7075529\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android21 --gcc-toolchain=C:/Users/USERNAME/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/USERNAME/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64/sysroot  -DIMGUI_IMPL_OPENGL_ES2 -Dgame_EXPORTS -IC:/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/gameactivity/app/src/main/cpp -IC:/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/gameactivity/app/src/main/cpp/../../../../../common -IC:/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/gameactivity/app/src/main/cpp/../../../../../../common/include -IC:/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/gameactivity/app/src/main/cpp/../../../../../../third_party/imgui -isystem C:/Users/USERNAME/.gradle/caches/transforms-2/files-2.1/dfcc27200594e40addd7a32f5a34e1f7/jetified-games-activity-1.1.0-beta03/prefab/modules/game-activity/include -isystem C:/Users/USERNAME/.gradle/caches/transforms-2/files-2.1/a5b29d7f2465e00d5e172357944bb069/jetified-games-controller-1.1.0-beta01/prefab/modules/paddleboat_static/include -isystem C:/Users/USERNAME/.gradle/caches/transforms-2/files-2.1/def4df69013b2e41dd02eef355809197/jetified-libpng-1.6.37-alpha-1/prefab/modules/png16-static/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -std=c++17 -Wall -O0 -fno-limit-debug-info  -fPIC   -std=c++17 -Wall -Wextra-semi -Wshadow -Wshadow-field -O0 -Werror -MD -MT CMakeFiles/game.dir/C_/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/common/demo_scene.cpp.o -MF CMakeFiles\game.dir\C_\Users\USERNAME\AndroidStudioProjects\games-samples\agdk\game_controller\common\demo_scene.cpp.o.d -o CMakeFiles/game.dir/C_/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/common/demo_scene.cpp.o -c C:/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/common/demo_scene.cpp
C:/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/common/demo_scene.cpp:765:47: error: use of undeclared identifier 'ImGuiTableFlags_ColumnsWidthFixed'; did you mean 'ImGuiTableColumnFlags_WidthFixed'?
    if (ImGui::BeginTable("##motiontable", 2, ImGuiTableFlags_ColumnsWidthFixed,
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                              ImGuiTableColumnFlags_WidthFixed
C:/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/gameactivity/app/src/main/cpp/../../../../../../third_party/imgui\imgui.h:1124:5: note: 'ImGuiTableColumnFlags_WidthFixed' declared here
    ImGuiTableColumnFlags_WidthFixed            = 1 << 3,   // Column will not stretch. Preferable with horizontal scrolling enabled (default if table sizing policy is _SizingFixedFit and table is resizable).
    ^
C:/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/common/demo_scene.cpp:767:53: error: use of undeclared identifier 'ImGuiTableColumnFlags_WidthAutoResize'
        ImGui::TableSetupColumn("Accelerometer   ", ImGuiTableColumnFlags_WidthAutoResize);
                                                    ^
C:/Users/USERNAME/AndroidStudioProjects/games-samples/agdk/game_controller/common/demo_scene.cpp:768:48: error: use of undeclared identifier 'ImGuiTableColumnFlags_WidthAutoResize'
        ImGui::TableSetupColumn("Gyroscope  ", ImGuiTableColumnFlags_WidthAutoResize);
                                               ^
3 errors generated.

It seems ImGuiTableFlags_ColumnsWidthFixed was already commented out in version 1.80? https://github.com/ocornut/imgui/blob/v1.80/imgui.h#L1111

I can't seem to find any declaration of ImGuiTableColumnFlags_WidthAutoResize at all.

constructor-s avatar Oct 15 '22 14:10 constructor-s

I changed: https://github.com/android/games-samples/blob/8800f3d551017c80c7fc7ae2677ce7c89d8a9f31/agdk/game_controller/common/demo_scene.cpp#L765-L768

to:

    if (ImGui::BeginTable("##motiontable", 2, ImGuiTableColumnFlags_WidthFixed,
                          ImVec2(0.0f, ImGui::GetTextLineHeightWithSpacing() * 4.5f))) {
        ImGui::TableSetupColumn("Accelerometer   ", ImGuiTableColumnFlags_WidthFixed);
        ImGui::TableSetupColumn("Gyroscope  ", ImGuiTableColumnFlags_WidthFixed);

Compiles and seems to work fine.

constructor-s avatar Oct 15 '22 15:10 constructor-s

Should be resolved with https://github.com/android/games-samples/pull/32

natetrost avatar Jan 12 '23 20:01 natetrost