sensics / OSVR-RenderManager

Apache License 2.0
64 stars 45 forks source link

Black screen in extended mode OpenGL when blending enabled #267

Closed russell-taylor closed 7 years ago

russell-taylor commented 7 years ago

@findus79 on Gitter reports: whenever I enable blending in the display callback or in the setup, I get a black screen in ExtendedMode, it does however work in DirectMode. So I moved back the blending settings to a later point, which works now.

Findus79 commented 7 years ago

I created a small, bare-bones example to recreate the effect.

#include <GL/glew.h>

#include <osvr/ClientKit/Context.h>

#include <osvr/RenderKit/RenderManager.h>
#include <osvr/RenderKit/GraphicsLibraryOpenGL.h>

void setup()
{
    glClearColor(1.f, 0.f, 0.f, 1.f);
    glClearDepth(1.f);

    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}

void osvr_display_callback(void* pUserData, osvr::renderkit::GraphicsLibrary library, osvr::renderkit::RenderBuffer buffers)
{
    osvr::renderkit::GraphicsLibraryOpenGL* gl_lib = library.OpenGL;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

int main(int nArgs, char** pArgs)
{
    auto context = osvr::clientkit::ClientContext("com.rde.osvr_ext_mode_test");

    auto renderer = osvr::renderkit::createRenderManager(context.get(), "OpenGL");

    renderer->SetDisplayCallback(osvr_display_callback);
    renderer->OpenDisplay();

    setup();

    glewExperimental = true;
    if (GLEW_OK != glewInit())
    {
        return -1;
    }

    while (1)
    {
        context.update();
        renderer->Render();
    }

    return 0;
}

if glEnable(GL_BLEND) is set, I only get a black screen in extended mode, disabling blending fixes this. Running in direct mode it works either way.

russell-taylor commented 7 years ago

Thanks for the excellent simple example! This has been fixed and pull requested in https://github.com/sensics/OSVR-RenderManager/pull/268