imgui-sfml icon indicating copy to clipboard operation
imgui-sfml copied to clipboard

OpenGL3 is not working with ImGui-SFML

Open eliasdaler opened this issue 4 years ago • 7 comments

Related: #40 #55 #70 #109

Currently, OpenGL 2 is used for rendering Dear ImGui;s widgets and it's done similarly to this backend implementation.

However, to properly restore state when drawing things in OpenGL 3+, this implementation should be used.

This is not as easy to integrate, because it will require us to start depending on some kind of OpenGL loader (glew, glad, etc.). We'll also need the option to switch between different render implementations which also adds another layer of complexity.


So, I think that it will be nice for someone who uses OpenGL 3+ and SFML to try to use this code instead of calling ImGui::SFML::Render(window). If there are some things that will prevent you from using it properly (some things being private, perhaps?), feel free to report such things here - I'll see what I can do.

eliasdaler avatar Mar 21 '21 12:03 eliasdaler

I wanna analyze this issue. 😄

utilForever avatar Mar 28 '21 00:03 utilForever

That'll be very helpful. I think that ideally both render implementations should be separated into different files and the user should be able to choose OpenGL3 impl if they want to.

OpenGL2 should be the default because it doesn't require any additional dependencies, while OpenGL3 one is much trickier as it requires some OpenGL loader to be present...

But we really don't want to have all implementations in imgui-SFML.cpp (it's already too big)

We should follow Dear ImGui's example implementations more closely (especially SDL example)

eliasdaler avatar Mar 28 '21 01:03 eliasdaler

Alright, I'll check these files and start to implement it. 🍡 @eliasdaler Which part should I look at in SDL example?

utilForever avatar Mar 28 '21 01:03 utilForever

You should look at how it separates rendering from "platform" things. I think that we should have something like imgui-SFML.h/cpp, imgui-SFML_OpenGL2.h/cpp and imgui-SFML_OpenGL3.h/cpp

I think that the users should not care about including these new header files into their build. The switch between OpenGL2/OpenGL3 should be performed by IMGUI_SFML_USE_OPENGL3 define (which should also be an option in CMake) but the API will remain the same - the user will only have to call ImGui::SFML::Render

eliasdaler avatar Mar 28 '21 11:03 eliasdaler

I think that in the most perfect scenario we'll be able to just use imgui/backends/imgui_impl_opengl{2,3}.{h,cpp} from Dear ImGui's repo so that we won't need to copy-paste the code and sync with things that change in Dear ImGui repo.

eliasdaler avatar Mar 28 '21 14:03 eliasdaler

I got it to work with opengl3 by removing all the rendering stuff from the imgui-SFML.cpp file and using it alongside the imgui_impl_opengl3.h file. It is very hacky but for now I can limp by with it until you guys fix it. Don't understand it too well.

https://gist.github.com/LucasM127/76dfa83b52ba6313c12a114af1696f71

LucasM127 avatar Apr 03 '21 02:04 LucasM127

@LucasM127 thanks! This will be very helpful for me to get started.

eliasdaler avatar Apr 03 '21 12:04 eliasdaler