-
Notifications
You must be signed in to change notification settings - Fork 176
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
[Linux] Rendering a rendertexture to ImGui::Image #11
Comments
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. |
Everything is fine now :) |
Awesome! |
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.
The text was updated successfully, but these errors were encountered: