-
Notifications
You must be signed in to change notification settings - Fork 172
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
Using ImGui-SFML with OpenGL 3.0 and SFML 2.5.1 #109
Comments
Hello Look at how complicated ImGui's OpenGL renderer example is: https://github.com/ocornut/imgui/blob/f0f5301612dbaa2caeede3091df6aee1c872dbdf/examples/imgui_impl_opengl3.cpp SFML uses OpenGL 2, so ImGui-SFML should use this OpenGL2 implementation by default, which is discussed in #79 - unfortunately I didn't have time to work on that. For now, I recommend trying not to call ImGui::SFML::Render, but to use imgui_impl_opengl3.cpp with your program somehow - I'm still not sure how to embed it into ImGui-SFML. |
From my knowledge, OpenGL 3.0 is just OpenGL 2.0 with extra steps. You have to load at runtime the functions your GPU uses, using the function glewInit() (see my code above). So as long as you write the necessary lines of code that set up the variables OpenGL 3.0 needs, it will work the same way as OpenGL 2.0. By adding that line, the project works now. That line tells the GPU the index of the object that will be drawn in the next draw call. It stores this index in a variable. The exception is the value 0. If you give 0 as a parameter, it wont draw anything. Somehow, if you call RenderDrawLists() without having that variable be 0, it crashes. I learned everything i know of OpenGL 3.0 from here: https://learnopengl.com/Getting-started/Hello-Triangle. Maybe this will help one day. |
Caused by #159 - closing |
I think a bug in your ImGui-SFML implementation. Since i dont understand the code 100% there is a slight chance that my solution is not 100% correct. Lets begin:
I want to build a project that uses OpenGL 3.0, ImGui-SFML and SFML 2.5.1. I wanted to draw the widgets with ImGui-SFML, but i want the scene to be rendered with OpenGL 3.0, not with SFML draw functions. I managed to make install all these libraries and compile the project. But at runtime something weird happened. It crashed. This is a small example of the code:
I was able to make the program not crash when it was using only OpenGL 3.0 draw calls and i managed to make it not crash when it was only using ImGui draw calls. So i realised that these 2 things affect each other. I managed to find the exact line at which the code crashes. Its at line "glBindVertexArray(VAO); ". Read that again, its "gl BIND vertex array" , not "glGenVertexArray".
After some hours of debugging, i figured out that the function "void RenderDrawLists ( ImDrawData* draw_data )" doesnt unbind the vertex array after it draws it. So i wrote "glBindVertexArray(0);" my code, and it stopped crashing. Normally, its my job to make sure i call that line after I'm done with a draw call, but i think it would be better for the library to also call that line, because today i lost 7 hours trying to fix this bug. If you want, i can send you a code repository with my example to show you that it crashes. Anyway, i hope this helps.
The text was updated successfully, but these errors were encountered: