mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-14 19:04:44 +00:00
About clipping rectangle #582
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#582
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
hello,
please forgive my pool English, I will try my best to make it clear.
when I want to use a texture to fully cover the window, I found that there was a blank area at the edge of the texture even though I set WindowPadding = ImVec2(0, 0);
So I found the code as follows:
when I comment "+0.5f" ,it works fine.Is this the correct way to solve the problem that I faced?
thank you.
Hello,
I will look into it. The solution is indeed around the spot you pointed but those lines have historically been tricky to get right, scissoring rectangles do not seem to behave the same with all renderers.
Are you using a renderer from one of the example?
Here's a repro (please try to submit a repro for subsequent bugs, thanks!)
OpenGL: the white square is 99x99 because of clipping.

DirectX9, DirectX11, square is 100x100

EDIT Fixed attachments, first post had twice the same picture.
Right now in my preliminary test it seems that removing both +0.5f works, but that leaves me with the question "why did I add them?".
Revision:
6e4d959953Date: 30/09/2015 21:30:27
Message: Window: fixed window lower-right clipping limit so it plays more friendly with both OpenGL and DirectX coordinates. Not sure about this. Hmm.
Note the "not sure about this", I rarely write that sort of thing in my commit message so something must have smelled fishy at the time already.
Revision:
ad00d88923Date: 25/08/2015 16:01:33
Message: Window clipping rect fixes (for child windows with borders among others)
Something else to note: borders were changed to lay WITHIN bound of every widget/window (see

b49a985324which happened after those two commits above), so this will affect this specific use case. Here the visible portion is 98x98. I don't intend to change that as having border lay inside made lots of code much simpler and bug-free. So if you have borders and you want zero-padding you can compensate by adding +1 padding on each axis.This is still a little confusing, I will investigate more tomorrow and probably apply fix of removing the two +0.5f but I ought to clarify this back and forth.
The reason for all this fishyness is because the renderers in examples/ are casting the floating point values to int which is a truncation. The OpenGL example is passing (float)x1 and (float)(x2-x1) whereas the DirectX examples are passing (float)x1 and (float)x2 which leads to different results. It is the OpenGL example behavior which led to the faulty commit linked at the top of the previous message. In addition, relying on the cast to preserve the integer value here is rather unreliable.
Will first soon. If it works for you can locally remove the +0.5f locally. Sorry fot the wall of text, @ottogithub
As you say, I indeed use OpenGL as My renderer。When I test the same code with directX9, it works fine.
Thank you very much for your detailed explanation.
@ocornut
I'll keep this open if you don't mind because I intend to fix this :)
Should be fixed now.
Rounding the floating point values to ensure user-side operations yield to correct results.
Realized that the rounding causes issues with negative clipping coordinates.
Although it doesn't make sense to use negative values in the typical case, I'm rendering my game via imgui and sometimes transports world-space coordinates in those fields so this is causing problem. It might be more relevant to not transform the data in the PushClipRect() function and rely on caller doing the right thing.