Skip to content
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

ImGui::Image draws garbage in modal window #5438

Closed
Hyldrean opened this issue Jun 30, 2022 · 2 comments
Closed

ImGui::Image draws garbage in modal window #5438

Hyldrean opened this issue Jun 30, 2022 · 2 comments

Comments

@Hyldrean
Copy link

Dear ImGui 1.88 (18800)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=202002
define: __linux__
define: __GNUC__=11
--------------------------------
io.BackendPlatformName: imgui_impl_sfml
io.BackendRendererName: NULL
io.ConfigFlags: 0x00000000
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00000007
 HasGamepad
 HasMouseCursors
 HasSetMousePos
--------------------------------
io.Fonts: 3 fonts, Flags: 0x00000000, TexSize: 512,1024
io.DisplaySize: 1200.00,800.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Version/Branch of Dear ImGui:

Version: 1.88 (commit)

Back-end/Renderer/Compiler/OS

Back-ends: ImGui-SFML
Operating System: Debian bookworm

My Issue/Question:

When calling '''ImGui::Image''' in a modal window, it renders garbage for the first call, then works fine. In popup window it works perfectly fine. It seems to be a bug and I don't know whether it is a SFML related issue or not, so I posted it here.
I have tried with '''ImGui::ImageButton''' too, the bug is the same (except all calls fail to draw the texture).
I have resized the image to see it bigger. It appears it is the font texture.

Screenshots/Video

image
image

Standalone, minimal, complete and verifiable example: (see #2261)

#include <SFML/Graphics.hpp>
#include "imgui-SFML.h"
#include "imgui.h"

int main()
{
    sf::RenderWindow window(sf::VideoMode(1200, 800), "My window");
    ImGui::SFML::Init(window);

    sf::Texture texture;
    texture.loadFromFile("assets/dice/red_1.png");

    sf::Clock clock;

    while (window.isOpen()) {
        //poll events
        sf::Event event{};
        while (window.pollEvent(event)) {
            ImGui::SFML::ProcessEvent(event);

            if (event.type == sf::Event::Closed)
                window.close();
        }

        //
        window.clear();

        //clock
        sf::Time elapsed = clock.restart();

        //update ImGui
        ImGui::SFML::Update(window, elapsed);

        //draw main window
        ImGui::Begin("main");

        if (ImGui::Button("Open popup"))
            ImGui::OpenPopup("popup");

        if (ImGui::Button("Open modal"))
            ImGui::OpenPopup("modal");

        //draw popup
        if (ImGui::BeginPopup("popup")) {
            ImVec2 image_size(50.f, 50.f);

            //draw them
            for (int i = 0; i < 5; ++i) {
                ImGui::Image(texture, image_size);
                ImGui::SameLine();
            }

            ImGui::EndPopup();
        }

        //draw modal
        if (ImGui::BeginPopupModal("modal")) {
            ImVec2 image_size(50.f, 50.f);

            //draw them
            for (int i = 0; i < 5; ++i) {
                ImGui::Image(texture, image_size);
                ImGui::SameLine();
            }


            ImGui::EndPopup();
        }

        ImGui::End();

        //
        ImGui::SFML::Render(window);
        window.display();
    }

    return 0;
}
@ocornut
Copy link
Owner

ocornut commented Jun 30, 2022

Given the screenshot it looks like a bug in your version of the imgui-SFML backend ?

Fixed by SFML/imgui-sfml@004efd8

See "Got visual Glitches?" in https://github.com/ocornut/imgui/releases/tag/v1.86
Same as #4845, #4863, #4887, #4888 and #5406 and others

Can you confirm it?

@Hyldrean
Copy link
Author

It works with the commit 004efd85a590343e8c9d166dc9d2524c199c9450 and above. Thank you for your time, I didn't found the issue you mentioned even though I searched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants