You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bool OpenglContext::Start(const std::string& title, int width, int height, bool isFullscreen)
{
m_windowTitle = title;
m_isFullscreen = isFullscreen;
InitWindow(width, height);
ImGui::SFML::Init(m_window);
Init();
LoadResource();
ShowCursor();
sf::Clock clock;
while (m_window.isOpen())
{
m_window.setActive();
sf::Event event;
while (m_window.pollEvent(event))
{
ImGui::SFML::ProcessEvent(event);
switch (event.type)
{
case sf::Event::Closed:
m_window.close();
break;
case sf::Event::Resized:
OnWindowResized(event.size.width, event.size.height);
break;
case sf::Event::KeyPressed:
OnKeyPress(event.key.code);
break;
case sf::Event::KeyReleased:
OnKeyRelease(event.key.code);
break;
case sf::Event::MouseMoved:
OnMouseMove(event.mouseMove.x, event.mouseMove.y);
break;
case sf::Event::MouseButtonPressed:
OnMousePress(ConvertMouseButton(event.mouseButton.button), event.mouseButton.x,
event.mouseButton.y);
break;
case sf::Event::MouseButtonReleased:
OnMouseReleased(ConvertMouseButton(event.mouseButton.button), event.mouseButton.x,
event.mouseButton.y);
break;
case sf::Event::MouseWheelMoved:
if (event.mouseWheel.delta > 0)
OnMousePress(MOUSE_BUTTON_WHEEL_UP, event.mouseButton.x, event.mouseButton.y);
else
OnMousePress(MOUSE_BUTTON_WHEEL_DOWN, event.mouseButton.x, event.mouseButton.y);
break;
}
}
ImGui::SFML::Update(m_window, clock.restart());
ImGui::Begin("MyWindow"); // begin window
ImGui::Button("wow!");
ImGui::End(); // end window
m_window.clear(sf::Color(30, 30, 30));
m_window.resetGLStates();
// Uncommenting the two lines below replaces everything with my game.
// Init();
// Render(m_lastFrameTime);
ImGui::SFML::Render(m_window);
m_window.display();
m_lastFrameTime = clock.getElapsedTime().asSeconds();
// Handle ourself frame rate limit, sf::Window::setFramerateLimit doesn't seems to work
float waitTime = (1.f / m_maxFps) - m_lastFrameTime;
if (waitTime > 0)
{
sf::sleep(sf::seconds(waitTime));
m_lastFrameTime = clock.getElapsedTime().asSeconds();
}
}
UnloadResource();
DeInit();
ImGui::SFML::Shutdown();
return true;
}
The two commented lines prepare the GL context (enable depth test, etc.) and then draws the entirety of my game. If I keep these lines commented, I can see my ImGui window with a button in it. If I comment out these lines, ImGui is nowhere to be seen.
What gives?
I update ImGui and send some stuff to it.
Render my game.
Render ImGui with ImGui::SFML::Render
Send to the screen with RenderWindow::Display
What am I missing?
The text was updated successfully, but these errors were encountered:
Hello
It'll help me a lot if you'll find a very simple compilable example. Even if it's pretty big, but is one file that I can compile - it'll help a lot. I'm not doing 3D graphics, so I'm not sure what can cause the problem, unfortunately.
Also take a look at "RenderDrawLists" in imgui-SFML.cpp - I think there might be some glEnable/glDisable calls which I've missed and which screw up the OpenGL state.
Here is a relevant excerpt from my code
The two commented lines prepare the GL context (enable depth test, etc.) and then draws the entirety of my game. If I keep these lines commented, I can see my ImGui window with a button in it. If I comment out these lines, ImGui is nowhere to be seen.
What gives?
ImGui::SFML::Render
RenderWindow::Display
What am I missing?
The text was updated successfully, but these errors were encountered: