ocornut / imgui

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

Linux + Mac laptop resolution issue #2171

Closed hamedsabri closed 6 years ago

hamedsabri commented 6 years ago

(Click "Preview" to turn any http URL into a clickable link)

I am running my app ( https://github.com/hamedsabri/Explore3MF ) on Linux ( Fedora29 distro ) that is installed on my Mac Laptop ( display resolution 2880x1800 ) but menus show very small in the app. Do I need to set something in the code to take to handle DPI properly?

Version/Branch of Dear ImGui:

master

Back-end file/Renderer/OS: (or specify if you are using a custom engine back-end)

OS: Fedora / Ubuntu Distros on Mac + Nvidia dirive GeForce GT 650M

Screenshots/Video (you can drag files here)

fedora_app

BrutPitt commented 6 years ago

The easiest way, I think, is to set ImGui::GetStyle().ScaleAllSizes(value) (value>1 bigger) and/or ImGui::GetIO().FontGlobalScale. Or or set font size on loading (via AddFontFromFileTTF, for example), or changing ImFont::Scale to resize font dynamically. Some examples are in imgui_demo

ocornut commented 6 years ago

Hamed, you didn’t specify which back-end files you are using.

Look up for “DPI” for some ideas.

ebachard commented 6 years ago

Hello,

I tested on Linux (Intel, x86_64, LinuxMint 18.3 + gcc, Gnome based). The build is OK, just one warning (see below).

~/my_machine/Explore3MF/src/Apps/ThreeMFApp/mainApp.cpp: In member function ‘virtual void E3D::MainApp::guiDraw()’:
~/my_machine/Explore3MF/src/Apps/ThreeMFApp/mainApp.cpp:167:62: warning: format not a string literal and no format arguments [-Wformat-security]
             if (ImGui::TreeNode("%s", mesh->getName().c_str()))

ldd returns:

ldd ThreeMFApp
    linux-vdso.so.1 =>  (0x00007ffc221dc000)
    libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f020924c000)
    libgtk-3.so.0 => /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 (0x00007f020891d000)
    libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f02086ca000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f02083b9000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f02081b1000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0207fad000)
    libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f0207c73000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0207a56000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f02076cd000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f02073c4000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f02071ad000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0206de3000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f0209451000)
    libgdk-3.so.0 => /usr/lib/x86_64-linux-gnu/libgdk-3.so.0 (0x00007f0206b08000)
    libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f0206904000)
    libpangocairo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007f02066f7000)
    libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007f02064e7000)
    libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f02062e1000)
    libcairo-gobject.so.2 => /usr/lib/x86_64-linux-gnu/libcairo-gobject.so.2 (0x00007f02060d8000)
    libcairo.so.2 => /usr/lib/x86_64-linux-gnu/libcairo.so.2 (0x00007f0205dc4000)
    libgdk_pixbuf-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007f0205ba2000)
    libatk-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0 (0x00007f020597d000)
    libatk-bridge-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0 (0x00007f020574e000)
    libepoxy.so.0 => /usr/lib/x86_64-linux-gnu/libepoxy.so.0 (0x00007f0205459000)
    libpangoft2-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007f0205243000)
    libpango-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007f0204ff7000)
    libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f0204db4000)
    libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f0204a2c000)
    libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f0204824000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f02045b4000)
    libxcb.so.1 => /usr/local/lib/libxcb.so.1 (0x00007f020438b000)
    libXinerama.so.1 => /usr/lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f0204188000)
    libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f0203f7d000)
    libXcursor.so.1 => /usr/lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f0203d73000)
    libXcomposite.so.1 => /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 (0x00007f0203b70000)
    libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f020396d000)
    libxkbcommon.so.0 => /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007f020372e000)
    libwayland-cursor.so.0 => /usr/lib/x86_64-linux-gnu/libwayland-cursor.so.0 (0x00007f0203526000)
    libwayland-egl.so.1 => /usr/lib/x86_64-linux-gnu/libwayland-egl.so.1 (0x00007f0203324000)
    libwayland-client.so.0 => /usr/lib/x86_64-linux-gnu/libwayland-client.so.0 (0x00007f0203115000)
    libmirclient.so.9 => /usr/lib/x86_64-linux-gnu/libmirclient.so.9 (0x00007f0202e6e000)
    libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f0202c5c000)
    libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f02029b2000)
    libpixman-1.so.0 => /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007f020270a000)
    libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f02024e5000)
    libxcb-shm.so.0 => /usr/local/lib/libxcb-shm.so.0 (0x00007f02022e1000)
    libxcb-render.so.0 => /usr/local/lib/libxcb-render.so.0 (0x00007f02020d3000)
    libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f0201ec9000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0201caf000)
    libatspi.so.0 => /usr/lib/x86_64-linux-gnu/libatspi.so.0 (0x00007f0201a80000)
    libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f0201834000)
    libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f02015d6000)
    libthai.so.0 => /usr/lib/x86_64-linux-gnu/libthai.so.0 (0x00007f02013cd000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f02011a4000)
    libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f0200f82000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f0200d67000)
    libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f0200b63000)
    libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f020095d000)
    libmircommon.so.7 => /usr/lib/x86_64-linux-gnu/libmircommon.so.7 (0x00007f0200716000)
    libmirprotobuf.so.3 => /usr/lib/x86_64-linux-gnu/libmirprotobuf.so.3 (0x00007f02004a4000)
    libcapnp-0.5.3.so => /usr/lib/x86_64-linux-gnu/libcapnp-0.5.3.so (0x00007f020021c000)
    libmircore.so.1 => /usr/lib/x86_64-linux-gnu/libmircore.so.1 (0x00007f0200013000)
    libboost_system.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0 (0x00007f01ffe0f000)
    libprotobuf-lite.so.9 => /usr/lib/x86_64-linux-gnu/libprotobuf-lite.so.9 (0x00007f01ffbde000)
    libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007f0209589000)
    libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f01ff9b8000)
    libdatrie.so.1 => /usr/lib/x86_64-linux-gnu/libdatrie.so.1 (0x00007f01ff7b0000)
    libboost_filesystem.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.58.0 (0x00007f01ff598000)
    libkj-0.5.3.so => /usr/lib/x86_64-linux-gnu/libkj-0.5.3.so (0x00007f01ff36f000)
    liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f01ff14d000)
    libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f01fee6c000)
    libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f01fec58000)

But, it doesn't work at all. See the screnshot below

image

And when I try to open .3mf files, I got an instant crash:

NMR Exception: Could not read ZIP file
terminate called after throwing an instance of 'NMR::CNMRException'
  what():  Could not read ZIP file
Abandon

So I'd say :

IMHO you should fix all of that first.

@ocornut : glfw sources are included, but not sure it is used. ldd ThreeMFApp | grep glfw is empty (?)

HTH

hamedsabri commented 6 years ago

@BrutPitt Thank you, will give it a try.

@ocornut Oh my bad. I am using imgui_impl_glfw, imgui_impl_opengl3 for back-end files

@ebachard, Thank you for testing the app and you certainly have a point there :+1:

3MF fundamentally is a zip format but it turned out that on Linux the file formats were set to text/plain which is obviously wrong and the NMR Exception makes sense. See below:

$> file -i ~/Explore3MF/src/Apps/ThreeMFApp/Resources/3MF/3MFrocket.3mf
rocket.3mf: text/plain; charset=us-ascii

Now, download the same file from github and test the file type:

$> file -i ~/Downloads/rocket.3mf
rocket.3mf: application/zip; charset=binary

I just fixed the issue (https://github.com/hamedsabri/Explore3MF/commit/72872d58333 ). I need to investigate this since I don't quite understand why this happened in the first place. Maybe it had something to do with git LFS? not 100% sure.

The filters in native file dialog are set correctly as we only want to load *.3mf

This app should run fine on both Nouveau display and Nvidia driver.

Best Regards, H

hamedsabri commented 6 years ago

@BrutPitt ImGui::GetStyle().ScaleAllSizes and ImGui::GetIO().FontGlobalScale did the trick. Thank you.