Skip to content
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

Setting the Vulkan VkViewport leads to incomplete display of widgets. #7800

Open
swhoro opened this issue Jul 17, 2024 · 3 comments
Open

Setting the Vulkan VkViewport leads to incomplete display of widgets. #7800

swhoro opened this issue Jul 17, 2024 · 3 comments

Comments

@swhoro
Copy link

swhoro commented Jul 17, 2024

Version/Branch of Dear ImGui:

Version 1.90.9

Back-ends:

no backends

Compiler, OS:

ubuntu 20.04 + gcc 9.4.0

Full config/build information:

No response

Details:

I want the width of a button to fill the window. If I use the normal VkViewport, for example, create a glfw window with width=1280, height=720, set VkViewport{x=0,y=0,width=1280,height=720}, and set io.Displaysize={1280,720}, it display correctly. But if I want the glfw window has 100 padding on x (set VkViewport{x=100,y=0,width=1080,height=720} and io.Displaysize={1080,720}), then the right part of the button is not displayed

Screenshots/Video:

This is the image in which I do not set viewport and button has full width
correct

This is the image I set viewport as I described above and right part of the button is cutted
uncorrect

Minimal, Complete and Verifiable Example code:

https://gist.github.com/swhoro/be2b72efad472558363b6f1debef46a2
This is almost the same as https://github.com/SaschaWillems/Vulkan/blob/master/examples/imgui/main.cpp except line 101, 380, 458, 758 and 761.

@swhoro
Copy link
Author

swhoro commented Jul 17, 2024

I find it is because in line484, I set wrong scissor.
But why window border can display correctly? It seems when drawing window border, the pcmd->ClipRect is {0,0,1080,720},which is the whole imgui viewport, but when drawing the button, the pcmd->ClipRect is {1,1,499,499}, which only contain the button area. What exactly does pcmd->ClipRect mean?

@ocornut
Copy link
Owner

ocornut commented Jul 18, 2024

Backends don't currently support transforming inputs or render.
You can modify ImDrawData::DisplayPos from (0,0) to (-100,0) and it will look right, but inputs will be incorrect anyhow.

I don't see/understand the reason for setting VkViewport{x=100,y=0,width=1080,height=720} and already DisplayPos. Why not giving access to the full platform window to dear imgui ?

@swhoro
Copy link
Author

swhoro commented Jul 19, 2024

Backends don't currently support transforming inputs or render. You can modify ImDrawData::DisplayPos from (0,0) to (-100,0) and it will look right, but inputs will be incorrect anyhow.

I don't see/understand the reason for setting VkViewport{x=100,y=0,width=1080,height=720} and already DisplayPos. Why not giving access to the full platform window to dear imgui ?

I am coding for an engine and in that engine, I can only draw on a certain area on the screen.
For example, I write a text_layer for the engine. Every time they use the text_layer, they will tell me where to draw the text, how big it should be and what the content is, but will not give me the screen size. I can only code for the text_layer, and outside the layer, I can not call ImGui::* functions. So for each layer, I maintain a standalone ImGui context, and set the viewport offset and size to what they give.
The code I list above is only a simple example to reproduce the problem what I get in that engine.
It seems a bad design but I can do nothing about this.

By the way, it seems pcmd->ClipRect meaning the "parent" elmenet size? For imgui window, it is the whole imgui viewport, and for a button, it is the window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants