mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-01 05:10:41 +00:00
Using OpenGL 3 bindings to display in an OpenGL 2.1 context ? #1513
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#1513
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,
I'm getting into a strange problem while trying to add imgui to one of my projects : this project was started in 2002 and uses what's now called legacy OpenGL.
I wanted to take advantage of the switch to move to modern OpenGL (3.3+).
Unfortunately there are some caveats : when compiling the basic example on my desktop computer (with a fairly recent graphics card), everything works fine and the windows are correctly displayed.
On the other hand, when compiling the OpenGL 3 example on a laptop (with an integrated Intel HD4000 graphics card), I get a 0xC0000005 exception before any rendering is done, and if I remove glfwWindowHint calls to get a compatibility context, the display is garbled, and the inputs are erratic at best :

The graphics card is supposed to have a 3.3 context capability, but it looks like the drivers aren't up to the task. And as it's a branded laptop, the drivers are proprietary, old, and can't be replaced by vanilla Intel drivers ...
I've tried compiling the OpenGL 2 version on the laptop, and it works fine.
So my question is : using OpenGL 3 bindings, is it possible to force OpenGL to display imgui through an OpenGL 2 context ?
Thanks for reading :)
A few things to try:
Read https://github.com/ocornut/imgui/issues/1466 and try to see if tweaking the shader
#versionand context version fixes it for you?I don't really understand what you are asking. You have access to all the code in opengl2 and opengl3 folders with code for both styles, just use/copy what works for you.
It's however quite suspicious that the opengl3 doesn't work and it would be judicious to understand the reason.
(ADMIN: Restored accidental edit to original post)
Thanks for your quick answer Omar, I really appreciate :)
I modified the version, with no visible behaviour change unfortunately ...
My ultimate goal would be to be able to choose between legacy or modern opengl at runtime, depending on the graphics card capability, in order to have my program working on a wide range of machines ...
I guess I will have to stick to OpenGL 2 bindings and to forget about modern OpenGL migration for now then ...
Looks like you edited my post instead of answering it :p
I actually tested this route, without being successful :D
I second that ... I guess I'll have to dig further :)
(My apologies! It is the second time this happens here.. I restored your post according to the e-mail notification now. It's quite unusual and dangerous that github even gives me this button.)
Not sure what you mean here. Unless you referring to the second paragraph, that you don't know what to test for? Otherwise having both code paths in the same exe should work.
I tried to factorize the code, keeping only one main codepath and calling specific OpenGL variants depending on the version used, but it didn't work.
Based on what you said, I created 2 different codepaths, and it worked fine. I guess I'll leave it there for now :)
BTW, thanks for your work, not only on Dear Imgui, but also on everything else (gaming wise, emulation wise and all ...) 🥇
First of all, happy new year everyone ! :D
Next, I've been doing some more research about the initial problem I'm having at the beginning of the thread (ie the garbled display in the first post).
The display card in my laptop is OpenGL 3.3 compatible (verified querying in app and using OpenGL Extensions Viewer), and should work. The only missing extension being the context profile one, but commenting out the following line
//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);allows the example to run, but with the rendering artifacts.
So what's new you might (rightfully) ask ?
Actually the display works perfectly when there's only one window displayed ... as soon as there's more, everything gets corrupted.
I don't know enough of Dear Imgui inner working to see if it's interesting, but I thought it might ring a bell to someone ...
Hello Runik, and happy new year!
I don't have time to look at it immediately but may I suggest looking at #1466, and you can try to change the glsl version? I'm just curious if this might have an effect.
I changed the glsl version to 150 with no visible improvement, unfortunately ...
I'm sure it's something trivial, but I can't put my finger on it yet.
@rtoumazet Sorry for the bump (better late than never!). I have made some changes to the imgui_impl_opengl3.cpp bindings to support lower GLSL versions. However it is tricky to fully test locally as modern drivers have different properties emulating old contexts and I don't think there is a way pre-GL 3.0 to disable backward compatibility.
I would be interested if you could confirm how the examples currently fare with your laptop?
It would also be interesting to double-check and test again with the version from when you initially posted (~Dec 20) and make sure that it still doesn't run (aka confirm that some OS/driver update didn't fix an old issue).
Thank you for your help.
Don't worry Omar, I know how it is ;)
I just tested the latest repository, and unfortunately the results are the same ... glfw + opengl3 gets garbled when more than one window is displayed, and it works fine with just one window.
Everything works ok in opengl2.
No driver change on the laptop (Toshiba isn't interested in updating a 2012 proprietary graphic driver :p)
Thanks for your test and feedback! With your help I would really like to solve this.
I realize that I don't know which OS are we talking about here? Windows 7/10? Linux?
In case you are running on Linux, could you post the output of
glxinfo -B?Could you try modifying the main.cpp to use different variations.
Currently:
Try to changing to:
or
Note that the example now display shader compilation/link error in stdout (which should appear in the console under Windows) so worth checking there.
Thank you.
Ok, so here we go :)