taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.37k stars 2.27k forks source link

ti.init(...) needlessly interferes with external GUI #6037

Open prybicki opened 2 years ago

prybicki commented 2 years ago

Thank you for developing great software πŸ™‡

When ti.init(...) is called (with no window setup), it unexpectedly changes appearance of a GUI program on a 4K screen, making everything smaller (no HiDPI scaling?).

Edit: the issue happens only on Windows. On Linux (Mint), DearPyGUI seems to ignore HiDPI scaling, so the effect of ti.init(...) is not visible.

Correct appearance, without calling ti.init(...) image

Wrong appearance, after calling ti.init(...) image

import dearpygui.dearpygui as dpg
import taichi as ti

# If uncommented, this line makes DearPyGUI smaller (no HiDPI scaling (?))
# ti.init(arch=ti.vulkan)

dpg.create_context()
dpg.create_viewport(title='Custom Title', width=400, height=300)

with dpg.window(label="Example Window"):
    dpg.add_text("Hello, world")

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

Motivation Since taichi's GUI does not satisfy my needs (no advanced widgets, such as charts), I attempted to use an external GUI (AFAIK most starred pythong GUI framework), however found it difficult to integrate them in a single app.

PENGUINLIONG commented 1 year ago

Hinting the GLFW window with GLFW_SCALE_TO_MONITOR could help. I could have a look at it a bit later but please feel free to contribute this change.