Closed kongo555 closed 8 years ago
Hmm, actually you have to use renderTexture.display()! Can you please find the minimal code which reproduces the problem? It will help me solve potentially undiscovered bugs.
Btw, I've tried doing the same thing as you, didn't have any problems.
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "");
window.setVerticalSyncEnabled(true);
ImGui::SFML::Init(window);
bool show = true;
sf::RenderTexture renderTexture;
sf::Sprite sprite;
if (!renderTexture.create(32, 32))
{
std::cout << "error renderTexture\n";
// error...
}
sprite = sf::Sprite(renderTexture.getTexture());
sf::RectangleShape tileTexture(sf::Vector2f(32, 32));
tileTexture.setFillColor(sf::Color::White);
tileTexture.setPosition(0, 0);
renderTexture.draw(tileTexture);
renderTexture.display();
sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
ImGui::SFML::ProcessEvent(event);
if (event.type == sf::Event::Closed) {
window.close();
}
}
ImGui::SFML::Update(deltaClock.restart());
ShowText(show);
ShowImage(show, sprite);
window.clear();
ImGui::Render();
window.display();
}
ImGui::SFML::Shutdown();
}
static void ShowText(bool& p_open)
{
ImGui::SetNextWindowPos(ImVec2(10,10));
if (!ImGui::Begin("Example: Text", &p_open))
{
ImGui::End();
return;
}
ImGui::Text("Simple overlay\non the top-left side of the screen.");
ImGui::Separator();
ImGui::Text("Mouse Position: (%.1f,%.1f)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y);
ImGui::End();
}
static void ShowImage(bool& p_open, sf::Sprite sprite)
{
ImGui::SetNextWindowPos(ImVec2(100,100));
if (!ImGui::Begin("Example: Image", &p_open))
{
ImGui::End();
return;
}
ImGui::Image(sprite);
ImGui::End();
}
When i comment renderTexture.display(); everything works, without it i have buged window.
Calling display is needed here. And indeed, calling it there causes some problems. It looks like this commit solves the issue. Can you try it out?
Everything is fine now :)
Awesome! I've also managed to remove reset/push/popGLStates calls in the latest version. Please try it out, and see if it works fine for you as well. :)
Hello! I have simillar problem to #8 and #10 but window.pushGLStates() and window.popGLStates() doesn't help. I'm rendering my scene to texture and then try to display it in imgui. It start to bug on renderTexture.display() method. I call it before ImGui::Render()
In test() and render(sprite) i call just imgui functions. I'm using 2.4 sfml version.
Thanks in advance for help :)
EDIT: It turns out that i don't have to use renderTexture.display() and then everything is fine.