Skip to content

Mixing SFML code with imgui-sfml broken on mobile #347

@Zombieschannel

Description

@Zombieschannel

Currently mixing SFML rendering with imgui-sfml seems to not work properly together.

On Android, I'm getting the following message spammed:
<glDrawArrays:4884>: glDrawArrays is called with VERTEX_ARRAY client state disabled!

After further investigation it seems like rendering from imgui-sfml indeed disables the vertex arrays, color arrays and texture arrays:

Rendering happens here: https://github.com/SFML/imgui-sfml/blob/master/imgui-SFML.cpp#L573

There is a call to resetGLStates() which reset these vertex/color/texture arrays to be enabled. After that there is a call to the main rendering function which after rendering disables these arrays: https://github.com/SFML/imgui-sfml/blob/master/imgui-SFML.cpp#L1061

From SFML code (https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/RenderTarget.cpp#L523) only resetGLStates() resets the vertex arrays, color arrays and texture arrays back to enabled which does not seem to be called after imgui-sfml rendering.

This breaks the SFML rendering? I'm not sure why I don't have any problems with this on desktop?

Indeed I was able to fix this locally by moving the resetGLStates() to be after rendering like this:

    target.pushGLStates();
    ImGui::Render();
    RenderDrawLists(ImGui::GetDrawData());
    target.popGLStates();
    target.resetGLStates();

I'm unsure if that now may break something else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions