Exemplo n.º 1
0
void Window::configExit( )
{
    if( !_xDisplay ) 
        return;

    leaveNVSwapBarrier();
    configExitFBO();
    exitGLEW();

    glXMakeCurrent( _xDisplay, None, 0 );

    GLXContext context  = getGLXContext();
    XID        drawable = getXDrawable();

    setGLXContext( 0 );
    setXDrawable( 0 );
    XSync( _xDisplay, False ); // WAR assert in glXDestroyContext/xcb_io.c:183

    if( context )
        glXDestroyContext( _xDisplay, context );

    if( drawable )
    {
        if( getIAttribute( eq::Window::IATTR_HINT_DRAWABLE ) == PBUFFER )
            glXDestroyPbuffer( _xDisplay, drawable );
        else
            XDestroyWindow( _xDisplay, drawable );
    }

    EQINFO << "Destroyed GLX context and X drawable " << std::endl;
}
Exemplo n.º 2
0
bool Window::configInitGLXDrawable( GLXFBConfig* fbConfig )
{
    switch( getIAttribute( IATTR_HINT_DRAWABLE ))
    {
        case PBUFFER:
            return configInitGLXPBuffer( fbConfig );

        case FBO:
        case OFF:
        {
            const PixelViewport pvp( 0, 0, 1, 1 );
            setXDrawable( _createGLXWindow( fbConfig, pvp ));
            return _impl->xDrawable != 0;
        }

        default:
            LBWARN << "Unknown drawable type "
                   << getIAttribute( IATTR_HINT_DRAWABLE ) << ", using window"
                   << std::endl;
            // no break;
        case UNDEFINED:
        case WINDOW:
            return configInitGLXWindow( fbConfig );
    }
}
Exemplo n.º 3
0
bool Window::configInitGLXWindow( GLXFBConfig* fbConfig )
{
    if( !_impl->xDisplay )
    {
        sendError( ERROR_GLXWINDOW_NO_DISPLAY );
        return false;
    }

    PixelViewport pvp = getPixelViewport();
    if( getIAttribute( IATTR_HINT_FULLSCREEN ) == ON )
    {
        const int screen = DefaultScreen( _impl->xDisplay );
        pvp.h = DisplayHeight( _impl->xDisplay, screen );
        pvp.w = DisplayWidth( _impl->xDisplay, screen );
        pvp.x = 0;
        pvp.y = 0;

        setPixelViewport( pvp );
    }

    XID drawable = _createGLXWindow( fbConfig, pvp );
    if( !drawable )
        return false;

    // map and wait for MapNotify event
    XMapWindow( _impl->xDisplay, drawable );

    XEvent event;
    XIfEvent( _impl->xDisplay, &event, WaitForNotify, (XPointer)(drawable) );

    XMoveResizeWindow( _impl->xDisplay, drawable, pvp.x, pvp.y, pvp.w, pvp.h );
    XFlush( _impl->xDisplay );

    // Grab keyboard focus in fullscreen mode
    if( getIAttribute( IATTR_HINT_FULLSCREEN ) == ON ||
        getIAttribute( IATTR_HINT_DECORATION ) == OFF )
    {
        XGrabKeyboard( _impl->xDisplay, drawable, True, GrabModeAsync,
                       GrabModeAsync, CurrentTime );
    }
    setXDrawable( drawable );

    LBVERB << "Created X11 drawable " << drawable << std::endl;
    return true;
}
Exemplo n.º 4
0
bool Window::configInitGLXPBuffer( GLXFBConfig* fbConfig )
{
    if( !_xDisplay )
    {
        setError( ERROR_GLXWINDOW_NO_DISPLAY );
        return false;
    }
    if( !fbConfig )
    {
        setError( ERROR_SYSTEMWINDOW_NO_PIXELFORMAT );
        return false;
    }
    if( !GLXEW_VERSION_1_3 )
    {
        setError( ERROR_GLXWINDOW_GLX_1_3_REQUIRED );
        return false;
    }

    // Create PBuffer
    const PixelViewport& pvp = getWindow()->getPixelViewport();
    const int attributes[] = { GLX_PBUFFER_WIDTH, pvp.w,
                               GLX_PBUFFER_HEIGHT, pvp.h,
                               GLX_LARGEST_PBUFFER, True,
                               GLX_PRESERVED_CONTENTS, True,
                               0 };

    // TODO: Could check for GLX_SGIX_pbuffer, but the only GLX 1.2 platform at
    // hand is OS X, which does not support this extension.

    XID pbuffer = glXCreatePbuffer( _xDisplay, fbConfig[ 0 ], attributes );
    if ( !pbuffer )
    {
        setError( ERROR_GLXWINDOW_CREATEPBUFFER_FAILED );
        return false;
    }

    XFlush( _xDisplay );
    setXDrawable( pbuffer );

    EQINFO << "Created X11 PBuffer " << pbuffer << std::endl;
    return true;
}