[Bug] Artifacts after windows resize with OpenGL3Renderer

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

msiedlarek
Just popping in
Just popping in
Posts: 10
Joined: Wed Sep 03, 2014 17:09

[Bug] Artifacts after windows resize with OpenGL3Renderer

Postby msiedlarek » Tue Sep 09, 2014 17:49

As per Lukas'es request I'm moving the discussion from this ticket here: http://cegui.org.uk/mantis/view.php?id=1051#c1310

Now answering your question:

Do you have the same issue in regular OpenGLRenderer or only OpenGL3? What OpenGL version does your driver (fully!) support?

With this configuration OpenGLRenderer works just fine:

Code: Select all

    Vendor: NVIDIA Corporation
    Version: 2.1 NVIDIA-8.26.26 310.40.45f01
    Renderer: NVIDIA GeForce GT 650M OpenGL Engine
    Shaders version: 1.20

With this configuration OpenGL3Renderer has the described problem after viewport resize:

Code: Select all

    Vendor: NVIDIA Corporation
    Version: 4.1 NVIDIA-8.26.26 310.40.45f01
    Renderer: NVIDIA GeForce GT 650M OpenGL Engine
    Shaders version: 4.10
    OpenGL profile: core

Image

[edit]

I can do some tinkering, so if you have an idea that you'd like to try out, just say so. I'm fairly new to CEGUI, so I don't really know where to look for this problem, considering how hard it is to debug OpenGL.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby Ident » Wed Sep 10, 2014 07:20

The artefacts are quite random. Since you said OGL works, this already limits our set of possible causes a lot. The major difference between OGL and OGL3 Renderers are the usage of FBOS and VBO/VAOs. The issue could lay there, or somewhere else, for example in more minor differences, or most annoyingly: it could simply be a driver bug!

Based on the artefacts I d assume that the issue is FBO-related. If you would be so kind you could try out the following:
Open "datafiles\layouts\GameMenu.layout"
Set all

Code: Select all

<Property name="AutoRenderingSurface" value="True" />

to

Code: Select all

<Property name="AutoRenderingSurface" value="False" />


Start the SampleBrowser again and look for a change in the Sample.
CrazyEddie: "I don't like GUIs"

msiedlarek
Just popping in
Just popping in
Posts: 10
Joined: Wed Sep 03, 2014 17:09

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby msiedlarek » Wed Sep 10, 2014 13:33

Oh, I see I caused some confusion by using sample resources for the screenshot. The problem is occurring with CEGUI working alongside my own OpenGL 3 engine. I just checked and SampleFramework app works just fine, so now I see it's probably something stupid I do. But changing AutoRenderingSurface solved the problem, so I hope you can help me locate it.

As for my engine - I'm doing the cleanup described in CEGUI documentation before calling renderAllGUIContexts(), that is I'm unbinding 2D texture and deactivating texture/shading program. Also I turned off all the rendering in my application apart from CEGUI call, and the problem remains.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby Ident » Wed Sep 10, 2014 13:37

Oh man i was 100% sure you were using the SampleBrowser..

Also I turned off all the rendering in my application apart from CEGUI call, and the problem remains.

That doesnt make sense considering you can run the SampleBrowser without issue.

Do you use "enableExtraStateSettings ()"?
CrazyEddie: "I don't like GUIs"

msiedlarek
Just popping in
Just popping in
Posts: 10
Joined: Wed Sep 03, 2014 17:09

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby msiedlarek » Wed Sep 10, 2014 14:00

Ident wrote:Do you use "enableExtraStateSettings ()"?

Nope, my initialization for CEGUI looks basically like this:

Code: Select all

    CEGUI::System::create(                                                         
        CEGUI::OpenGL3Renderer::create(),                                         
        MyCustomResourceProvider::get()                                               
    );                                                                             
                                                                                   
    CEGUI::SchemeManager::getSingleton().createFromFile("Generic.scheme");         
    CEGUI::SchemeManager::getSingleton().createFromFile("GameMenu.scheme");       
    CEGUI::Window * const root_window = (                                         
        CEGUI::WindowManager::getSingleton().loadLayoutFromFile(                   
            "GameMenu.layout"                                                     
        )                                                                         
    );                                                                             
    CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(           
        root_window                                                               
    );

And rendering like this:

Code: Select all

    oglplus::Texture::Unbind(oglplus::TextureTarget::_2D);                         
    oglplus::Texture::Active(0);                                                   
    oglplus::Program::UseNone();

    CEGUI::System::getSingleton().renderAllGUIContexts();

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby Ident » Wed Sep 10, 2014 15:05

What is "oglplus"?

What happens if u never make any setting in oglplus?
What happens if u turn aforementioned setting on?
CrazyEddie: "I don't like GUIs"

msiedlarek
Just popping in
Just popping in
Posts: 10
Joined: Wed Sep 03, 2014 17:09

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby msiedlarek » Wed Sep 10, 2014 15:07

OGLplus is just a C++ wrapper for OpenGL calls, replacing those lines with raw calls changes nothing.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby Ident » Wed Sep 10, 2014 15:16

msiedlarek wrote:OGLplus is just a C++ wrapper for OpenGL calls, replacing those lines with raw calls changes nothing.

Weird. I never heard of that wrapper. Does it call OpenGL only if a setting is actually changed(saving the previous state) or whats the point of it?

Did you try enableExtraStateSettings (true) for the OGL3Renderer?
CrazyEddie: "I don't like GUIs"

msiedlarek
Just popping in
Just popping in
Posts: 10
Joined: Wed Sep 03, 2014 17:09

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby msiedlarek » Wed Sep 10, 2014 15:49

Ident wrote:Weird. I never heard of that wrapper. Does it call OpenGL only if a setting is actually changed(saving the previous state) or whats the point of it?

I use it mainly because of object lifetime management, which I did end up writing myself for previous project, before I found OGLplus. It also makes OpenGL API typesafe, which sometimes can save your life. Check it out - it's worth it: http://oglplus.org/oglplus/html/index.h ... s_features

Ident wrote:Did you try enableExtraStateSettings (true) for the OGL3Renderer?

I did just now and it works! So I guess I can now trace an intersection of what this setting affects and what my engine does, thanks!

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby Ident » Wed Sep 10, 2014 16:30

msiedlarek wrote:
Ident wrote:Did you try enableExtraStateSettings (true) for the OGL3Renderer?

I did just now and it works! So I guess I can now trace an intersection of what this setting affects and what my engine does, thanks!

This basically just sets and resets certain functions that are needed to be set if you changed them. Your engine MUST have changed some settings otherwise the Samplebrowser, which doesnt use this function, would also not work.

In order to reduce such problems for future users: Could you tell us why you hadnt heard of the function or how we could have documented better that this function exists or how it can be used?
Would you expect this function to be on by default? Do you think changing it to be on by default would be good?

The only issue about the function is that it introduces a certain (often unnecessary) performance reduction which is why it was off by default. However, people could then always turn it off anyways. I guess the priority for people first is that "it works".
CrazyEddie: "I don't like GUIs"

msiedlarek
Just popping in
Just popping in
Posts: 10
Joined: Wed Sep 03, 2014 17:09

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby msiedlarek » Wed Sep 10, 2014 18:04

Oh, so it seems I was being an idiot again. I've added enableExtraStateSettings and ran my application on modified resources with AutoRenderingSurface disabled. Now that I'm running it with original GameMenu.layout it's not working anymore. Any ideas left?

As of the enableExtraStateSettings() - I think it could be mentioned in "The Beginners Guide to Initialising CEGUI". There is already a cleanup process specified for OpenGL (glBindTexture(0), glUseProgram(0), glActiveTexture(GL_TEXTURE_0)) but no mention that more may be needed.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby Ident » Wed Sep 10, 2014 18:10

msiedlarek wrote:There is already a cleanup process specified for OpenGL (glBindTexture(0), glUseProgram(0), glActiveTexture(GL_TEXTURE_0)) but no mention that more may be needed.

That's what the enableExtraAttribs function does for you.

msiedlarek wrote:Any ideas left?

bind the framebuffer to 0 before rendering. Also make 1000% sure that your library does not set any stuff at all.

Also I want to mention I once had a similar issue (also framebuffer resize related although my artefacts looked different) when using openglut or freeglut (dont remember which one, i abandoned all *glut libraries afterwards), which disappeared once i changed to glew and glfw. It could be the library you use that causes the issue. Remember that the Samplebrowser works. Wait, it does, right? If it does, including resizes, I would go and blame that library, tbh.
CrazyEddie: "I don't like GUIs"

msiedlarek
Just popping in
Just popping in
Posts: 10
Joined: Wed Sep 03, 2014 17:09

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby msiedlarek » Wed Sep 10, 2014 19:38

Ident wrote:
msiedlarek wrote:There is already a cleanup process specified for OpenGL (glBindTexture(0), glUseProgram(0), glActiveTexture(GL_TEXTURE_0)) but no mention that more may be needed.

That's what the enableExtraAttribs function does for you.

And I'm just saying it should be mentioned in the guide. You asked me why I didn't know about it - it's because as a beginner I was going with the beginner guide. :)

Ident wrote:bind the framebuffer to 0 before rendering. Also make 1000% sure that your library does not set any stuff at all.

Also I want to mention I once had a similar issue (also framebuffer resize related although my artefacts looked different) when using openglut or freeglut (dont remember which one, i abandoned all *glut libraries afterwards), which disappeared once i changed to glew and glfw. It could be the library you use that causes the issue. Remember that the Samplebrowser works. Wait, it does, right? If it does, including resizes, I would go and blame that library, tbh.

I tried setting both read and draw framebuffers to 0 and it didn't help. As for possible interference from my engine or OGLplus I managed to extract a minimal program that still has this issue:

Code: Select all

#include <SDL2/SDL.h>
#include <SDL2/SDL_video.h>

#include <CEGUI/System.h>
#include <CEGUI/RendererModules/OpenGL/GL3Renderer.h>
#include <CEGUI/SchemeManager.h>
#include <CEGUI/WindowManager.h>
#include <CEGUI/GUIContext.h>
#include <CEGUI/DefaultResourceProvider.h>
#include <CEGUI/Font.h>
#include <CEGUI/Scheme.h>
#include <CEGUI/WindowManager.h>
#include <CEGUI/falagard/WidgetLookManager.h>
#include <CEGUI/ImageManager.h>

int main()
{
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GL_SetAttribute(
        SDL_GL_CONTEXT_PROFILE_MASK,
        SDL_GL_CONTEXT_PROFILE_CORE
    );

    SDL_Window * const window = SDL_CreateWindow(
        "Sample",
        SDL_WINDOWPOS_CENTERED,
        SDL_WINDOWPOS_CENTERED,
        1200,
        700,
        SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE
    );
    SDL_GLContext sdl_opengl_context = SDL_GL_CreateContext(window);

    CEGUI::OpenGL3Renderer::bootstrapSystem();
    CEGUI::System & system = CEGUI::System::getSingleton();

    {
        CEGUI::DefaultResourceProvider * rp = (
            static_cast<CEGUI::DefaultResourceProvider*>(
                system.getResourceProvider()
            )
        );
        rp->setResourceGroupDirectory("schemes", "./datafiles/schemes/");
        rp->setResourceGroupDirectory("imagesets", "./datafiles/imagesets/");
        rp->setResourceGroupDirectory("fonts", "./datafiles/fonts/");
        rp->setResourceGroupDirectory("layouts", "./datafiles/layouts/");
        rp->setResourceGroupDirectory("looknfeels", "./datafiles/looknfeel/");

        CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets");
        CEGUI::Font::setDefaultResourceGroup("fonts");
        CEGUI::Scheme::setDefaultResourceGroup("schemes");
        CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
        CEGUI::WindowManager::setDefaultResourceGroup("layouts");
    }

    {
        CEGUI::SchemeManager::getSingleton().createFromFile("Generic.scheme");
        CEGUI::SchemeManager::getSingleton().createFromFile("GameMenu.scheme");
        CEGUI::Window * const root_window = (
            CEGUI::WindowManager::getSingleton().loadLayoutFromFile(
                "GameMenu.layout"
            )
        );
        system.getDefaultGUIContext().setRootWindow(root_window);
    }

    while (!SDL_QuitRequested()) {
        SDL_Event event;
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_WINDOWEVENT
                    && event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
                int x, y;
                SDL_GL_GetDrawableSize(window, &x, &y);
                system.notifyDisplaySizeChanged({
                    static_cast<float>(x),
                    static_cast<float>(y)
                });
            }
        }

        system.renderAllGUIContexts();
        SDL_GL_SwapWindow(window);
    }

    CEGUI::OpenGL3Renderer::destroySystem();
    SDL_GL_DeleteContext(sdl_opengl_context);
    SDL_DestroyWindow(window);
    SDL_Quit();

    return 0;
}


edit

So this may be something specific about how SDL2 creates an OpenGL context? I'll look into that. All ideas still welcome. :)

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby Ident » Wed Sep 10, 2014 20:03

Okay so you use SDL in both cases, whereas both dont work? You see, you never explicitly mentioned that you use SDL - that would have been kinda important to know, in case I knew something in that regards( I actually dont). Admittedly, I also didnt ask for it ;)

Also: Can you please confirm that the SampleBrowser, when you click on the samples for fullscreen view, and resize the application window, still works normally? If it is, I assume we can both do a safe bet on that SDL does something wrong here.
CrazyEddie: "I don't like GUIs"

msiedlarek
Just popping in
Just popping in
Posts: 10
Joined: Wed Sep 03, 2014 17:09

Re: [Bug] Artifacts after windows resize with OpenGL3Rendere

Postby msiedlarek » Wed Sep 10, 2014 20:30

Ident wrote:Also: Can you please confirm that the SampleBrowser, when you click on the samples for fullscreen view, and resize the application window, still works normally?

It does.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 2 guests