mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-01 05:10:41 +00:00
compile error in example if IMGUI_IMPL_OPENGL_LOADER_CUSTOM is defined #2178
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#2178
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?
Version/Branch of Dear ImGui:
Version 1.65 :
Back-end file/Renderer/OS: (or specify if you are using a custom engine back-end)
Back-ends: imgui_impl_opengl3.cpp, imgui_impl_glfw.cpp
OS: Ubuntu 16.04
Compiler: gcc 5.4.0
My Issue/Question: (please provide context)
examples/example_glfw_opengl3/main.cppfails to compileif
IMGUI_IMPL_OPENGL_LOADER_CUSTOMis defined.The problem is here:
If
IMGUI_IMPL_OPENGL_LOADER_CUSTOMis defined,then none of
IMGUI_IMPL_OPENGL_LOADER_{GL3W,GLEW,GLAD}are defined,thus the local variable
erris not defined,and thus you get a compile time error:
I suspect that the bug was introduced with the changes for #2001.
Hello,
What do you expect should happen or be done? The examples’ main.cpp can’t implement initialization for an unknown loader. This define makes sense to use the imgui_impl_opengl3 file in your own code, how are you trying to use it here?
I started OpenGL programming by copying another project on github and modifying it. As a result, my code doesn't use a loader library, because the project I copied doesn't. I just ask GLFW to include the OpenGL headers for me, with no loader library. My custom header does this:
I modified
examples/example_glfw_opengl3/main.cpp, changing this:to this:
and everything works fine on Linux. The ImGui example works, and my code that uses ImGui also works. The new code also looks more correct from a pure programming perspective, since the variable
erris now defined in all cases.I didn't bother to learn about OpenGL loader libraries until now. Somehow I've managed to work on my project for several years without having this knowledge. Now that I've researched the topic, I see claims that just including the opengl headers doesn't work; you need to use a loader library. I use OpenGL3 with shaders, so my code shouldn't work as written. I'm going to make a guess that this claim is more true on Windows and MacOS than it is on Linux.
If you are saying that ImGui requires a loader, and that using OpenGL without a loader is not supported by the ImGui examples, then just close this issue.
I'm going to try and modify my project to use GLAD, since that appears to be the most popular loader.
You are right here, it's just that I didn't expect the examples/ main.cpp file to ever compile as-is with any other loaders (when using IMGUI_IMPL_OPENGL_LOADER_CUSTOM). But at it happens,
glext.hdoes not requires any initialization and saw your setup works perfectly. Given that I made the change you have requested. Thanks!There's some friction to provide a IMGUI_IMPL_OPENGL_LOADER_GLEXT out of the box: glext.h is not available by default under Windows, and gl.h+glext.h tend to requires specific os-related included which would increase the size of the include blocks in main.cpp and _opengl3.cpp - but that's possible to do later, I just need to investigate it a little further. Basically we need to be copying what's done in
glfw3.horglfw3native.hwhich is a little messy.For the records, here's a block to add in main.cpp/imgui_impl_opengl3.cpp to use glext without GLFW. It's only tested under Windows however.
Given the mess/nature of using glext.h I think it is preferable to not add support for
IMGUI_IMPL_OPENGL_LOADER_GLEXTand let the user go through a third-party like you are withGLFW_INCLUDE_GLEXT.Link to #2001, #2002.
Thanks @ocornut.
FYI, libepoxy is another loader library that doesn't require initialization code. I haven't tried it. The advantages are no initialization and lazy loading.