mirror of
https://github.com/ocornut/imgui.git
synced 2026-10-16 22:40:48 +00:00
Wrong scissor clipping when using glClipControl origin GL_UPPER_LEFT #2186
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#2186
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?
Hi!
In my app I set glClipControl origin to be GL_UPPER_LEFT to match D3D screen space coordinated.It effectively flips frame buffer attachment along Y axis .And I see that imgui GL backend uses inverted scissor rectangle ,and in this case the ui gets cut in wrong places.
My imgui version (v1.60 WIP) is a bit old so I made the following change to make it work:
imgui_impl_opengl3.cpp
Hello,
Never heard of
glClipControl()until today! (it is a GL 4.5 function)In theory we should save the current value using some glGet (I don't know if there is a define for it, can't find it), then call
glClipControl(GL_LOWER_LEFT)then restore it.Since this is so esoteric and using 4.5+ functions may be problematic in the binding, could you just call
glClipControl(GL_LOWER_LEFT)because calling the draw function? This way you don't have to modify imgui_impl_opengl3.cppHere is how I ended it:
GLint clip_origin; glGetIntegerv(GL_CLIP_ORIGIN, &clip_origin);
Can't find it in the docs of khronos.org but apparently there is a GL_CLIP_ORIGIN to be used with glGet()
https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_clip_control.txt
See my update. I don't frequently update imgui so I just fixed it inside that file.But maybe for the future uses it should be added via state query as you do with the rest of params.
Thanks.
My suggest above was to change the clip control on your side so you don't modify imgui's code. This is only going to reduce your update flexibility.
I have now added support for it in imgui_impl_opengl3.cpp (untested).
This requires the GL header file accessed by imgui_impl_opengl3 to be defining
GL_CLIP_ORIGINso may not work properly in all loaders configuration. How does it works for you?I see what you mean,but in my code I try to hide OpenGL details as much as possible ,and because imgui is used just for debug tasks and the rest of the rendering system uses UPPER_LEFT origin mode,in my case I found it more suitable to put inside that rendering backend file. But if you want my opinion so I would just do it as you do with the rest of the state.Just query that clip state and then either change the state during imgui pass or change the clipping rectangle.I hate changing states too much so I went with the second one .
So your patch looks great.Thanks.
Hello @MichaelSSky ,
Do you know if GL_CLIP_ORIGIN / GL_UPPER_LEFT if available in some form on Mac/OSX ?
Are you using it there?
See #2366