Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL3 is not working with ImGui-SFML #159

Open
eliasdaler opened this issue Mar 21, 2021 · 7 comments
Open

OpenGL3 is not working with ImGui-SFML #159

eliasdaler opened this issue Mar 21, 2021 · 7 comments

Comments

@eliasdaler
Copy link
Contributor

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.

@utilForever
Copy link

I wanna analyze this issue. 😄

@eliasdaler
Copy link
Contributor Author

eliasdaler commented Mar 28, 2021

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)

@utilForever
Copy link

utilForever commented Mar 28, 2021

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

@eliasdaler
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@LucasM127
Copy link

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

@eliasdaler
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants