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 Rendering State Features #68

Closed
hofstee opened this issue Oct 27, 2019 · 3 comments

Comments

@hofstee
Copy link

@hofstee hofstee commented Oct 27, 2019

In the imgui example, there's a set of comments here that say it's sufficient to do this in the renderer constructor if you're only drawing imgui elements.

    /* Set appropriate states. If you only draw imgui UI, it is sufficient to
       do this once in the constructor. */
    GL::Renderer::enable(GL::Renderer::Feature::Blending);
    GL::Renderer::disable(GL::Renderer::Feature::FaceCulling);
    GL::Renderer::disable(GL::Renderer::Feature::DepthTest);
    GL::Renderer::enable(GL::Renderer::Feature::ScissorTest);

Which suggests you can just comment out these lines:

    // /* Reset state. Only needed if you want to draw something else with
    //    different state next frame. */
    // GL::Renderer::disable(GL::Renderer::Feature::ScissorTest);
    // GL::Renderer::enable(GL::Renderer::Feature::DepthTest);
    // GL::Renderer::enable(GL::Renderer::Feature::FaceCulling);
    // GL::Renderer::disable(GL::Renderer::Feature::Blending);

While this comment seems valid on Emscripten, at least when I build locally with SDL2 this doesn't work. By doing nothing other than commenting out the line disabling the scissor test, I get those solitaire card effects or glitchy Windows95 things being dragged and I get a trail of the old imgui windows.

Frankly, I'm somewhat baffled.

That being said, I probably have an odd setup. I'll just list what I think would be relevant.

  • imgui version: docking branch
  • OS: Debian running in ChromeOS
  • Window manager: Wayland
  • SDL2 version:
libsdl2-2.0-0/oldstable,now 2.0.5+dfsg1-2 amd64 [installed,automatic]
  Simple DirectMedia Layer

libsdl2-dev/oldstable,now 2.0.5+dfsg1-2 amd64 [installed]
  Simple DirectMedia Layer development files
  • Info from Magnum
Renderer: virgl by Red Hat
OpenGL version: 4.3 (Core Profile) Mesa 19.2.0-devel
Using optional features:
    GL_ARB_ES2_compatibility
    GL_ARB_direct_state_access
    GL_ARB_get_texture_sub_image
    GL_ARB_invalidate_subdata
    GL_ARB_multi_bind
    GL_ARB_robustness
    GL_ARB_separate_shader_objects
    GL_ARB_texture_filter_anisotropic
    GL_ARB_texture_storage
    GL_ARB_texture_storage_multisample
    GL_ARB_vertex_array_object
    GL_KHR_debug
Using driver workarounds:
    no-layout-qualifiers-on-old-glsl
    mesa-forward-compatible-line-width-range
@hofstee

This comment has been minimized.

Copy link
Author

@hofstee hofstee commented Oct 27, 2019

I poked around a bit more and found an imgui issue about something similar: ocornut/imgui#874

If that's accurate, then the line resetting the scissor test back to its initial state is required to be there, but the others can be omitted.

@mosra

This comment has been minimized.

Copy link
Owner

@mosra mosra commented Oct 27, 2019

Hi!

You're right -- thinking about it, what happens there is the framebuffer clear at the beginning of drawEvent() being affected by the enabled scissor test from previous frame, clearing only a very tiny part of the screen and leaving the Solitaire trail when you drag windows :)

I'll clarify that in the example code.

@mosra mosra added this to the 2019.1c milestone Oct 27, 2019
@mosra mosra added this to TODO in Project management via automation Oct 27, 2019
@mosra

This comment has been minimized.

Copy link
Owner

@mosra mosra commented Nov 6, 2019

While attempting to document this, I realized it's easier and simpler to just reset the scissor back in the renderer itself. So that's done in mosra/magnum-integration@e0d2e38.

Thanks for the report!

@mosra mosra closed this Nov 6, 2019
Project management automation moved this from TODO to Done Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2 participants
You can’t perform that action at this time.