-
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
An issue using modern OpenGL and Imgui-SFML ? #55
Comments
Hello The "Texture.cpp" is SFML's sf::Texture. Which probably means that you're messing SFML's internal state of OpenGL by calling OpenGL where SFML doesn't expect you to do so. Try calling You can also try doing this: (You'll also need to remove resetGLStates from ImGui::SFML::Render) window.pushGLStates();
ImGui::SFML::Render(window);
window.popGLStates();
On what line exactly does it crash? |
Thanks! This is close to a minimal reproducible example, so I'll try to reproduce it and see what I can do. |
Closing, #159. |
Hello,
I tried using your work since I already use a SFML window for my openGL project.
For now it pretty much crashes as soon as I try to display the GUI calling:
ImGui::SFML::Render(window)
Before that I get a lot of errors during my openGL operations
An internal OpenGL call failed in Texture.cpp(667). Expression: glMatrixMode(GL_MODELVIEW) Error description: GL_INVALID_OPERATION The specified operation is not allowed in the current state.
I'm not sure which "texture.cpp" this is, I have such a class but it is not 667 lines long. But it seems there is some state conflict between my openGL operations and the ones done by IMGUI-SFML.
I know that the othaur of Imgui advised against mixing modern and old openGL and I also noticed that the imgui-sfml.cpp file had the following lines:
` glMatrixMode(GL_TEXTURE);
glLoadIdentity();
as well as :
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + offsetof(ImDrawVert, pos))); glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + offsetof(ImDrawVert, uv))); glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + offsetof(ImDrawVert, col)));
which look like 1.2 openGL. could it be that your openGL code is at odds with mine? Is there a way around it?
The init of my window and openGL context is this:
` std::cout << "starting application" << std::endl;
/*
WINDOW OPENGL INIT
*/
const std::string title = "openGL";
sf::ContextSettings settings;
settings.depthBits = 24;
settings.stencilBits = 8;
settings.antialiasingLevel = 2; // Optional
// Request OpenGL version 3.2 (optional but recommended)
settings.majorVersion = 4;
settings.minorVersion = 5;
settings.attributeFlags = sf::ContextSettings::Core;
I do the following in my main loop:
` tetraRender::EventHandler handler(scene);
while (window.isOpen())
{
// check all the window's events that were triggered since the last iteration of the loop
in scene->renderScene() I do a lot of opengl state calls to render my scenes using multiple framebuffers and shaders using opengl 4.3.
I would like to add that the system crashes during a call to Imgui::End() because g.currentWindow is null. And the many openGL errors appear during the call of window.resetGLStates();
The text was updated successfully, but these errors were encountered: