imgui-sfml
imgui-sfml copied to clipboard
OpenGL3 is not working with ImGui-SFML
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.
I wanna analyze this issue. 😄
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)
Alright, I'll check these files and start to implement it. 🍡 @eliasdaler Which part should I look at in SDL example?
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
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.
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 thanks! This will be very helpful for me to get started.