Exemple #1
0
AGLContext Window::createAGLContext( AGLPixelFormat pixelFormat )
{
    if( !pixelFormat )
    {
        sendError( ERROR_SYSTEMWINDOW_NO_PIXELFORMAT );
        return 0;
    }

    const WindowIF* aglShareWindow =
        dynamic_cast< const WindowIF* >( getSharedContextWindow( ));
    AGLContext shareCtx = aglShareWindow ? aglShareWindow->getAGLContext() : 0;

    Global::enterCarbon();
    AGLContext context = aglCreateContext( pixelFormat, shareCtx );

    if( !context )
    {
        sendError( ERROR_AGLWINDOW_CREATECONTEXT_FAILED ) << aglError();
        Global::leaveCarbon();
        return 0;
    }

    _initSwapSync( context );
    aglSetCurrentContext( context );

    Global::leaveCarbon();

    LBVERB << "Created AGL context " << context << " shared with " << shareCtx
           << std::endl;
    return context;
}
Exemple #2
0
void Window::_setupObjectManager()
{
    if( !glewGetContext( ))
        return;

    _releaseObjectManager();

    Window*    sharedWindow = getSharedContextWindow();
    ObjectManager* sharedOM = sharedWindow ? sharedWindow->getObjectManager():0;

    if( sharedOM )
        _objectManager = new ObjectManager( sharedOM );
    else
        _objectManager = new ObjectManager( glewGetContext( ));
}
/**
 *  Function for creating and holding of shared context.
 */
void GPUAsyncLoaderBase::run()
{
    LBASSERT( !_sharedContextWindow );
    _sharedContextWindow = initSharedContextWindow( _wnd, &_computeCtx );

    onInit();

    if( !getSharedContextWindow() )
        return;

    runLocal();
    cleanup();

    deleteSharedContextWindow( _wnd, &_sharedContextWindow, &_computeCtx );
}
Exemple #4
0
void Window::_setupObjectManager()
{
    if( !glewGetContext( ))
        return;

    _releaseObjectManager();

    const Window* sharedWindow = getSharedContextWindow();
    if( sharedWindow && sharedWindow != this )
        _objectManager = sharedWindow->_objectManager;
    else
    {
        util::ObjectManager om( glewGetContext( ));
        _objectManager = om;
    }
}
Exemple #5
0
		bool configInitOSWindow(const uint32_t id)
		{
			Widget* widget = Widget::getInstance();

			if (!widget)
			{
				// Share context only between Eq-created OS windows
				eq::OSWindow* osWindow = getSharedContextWindow()->getOSWindow();
				if (dynamic_cast<GLWindow*> (osWindow))
				{
					const std::vector<eq::Window*>& windows = getPipe()->getWindows();
					EQASSERT( windows.size() > 1 );
					setSharedContextWindow(windows[1]);
				}

				return eq::Window::configInitOSWindow(id);
			}

			setOSWindow(new GLWindow(this, widget));
			return true;
		}
Exemple #6
0
GLXContext Window::createGLXContext( GLXFBConfig* fbConfig )
{
    if( !_impl->xDisplay )
    {
        sendError( ERROR_GLXWINDOW_NO_DISPLAY );
        return 0;
    }
    if( !fbConfig )
    {
        sendError( ERROR_SYSTEMWINDOW_NO_PIXELFORMAT );
        return 0;
    }

    GLXContext shCtx = 0;
    const SystemWindow* shareWindow = getSharedContextWindow();
    if( shareWindow )
    {
        const WindowIF* shareGLXWindow =
                                 dynamic_cast< const WindowIF* >( shareWindow );
        if( shareGLXWindow )
            shCtx = shareGLXWindow->getGLXContext();
#ifdef EQUALIZER_USE_QT5WIDGETS
        else if( dynamic_cast< const qt::WindowIF* >( shareWindow ))
        {
            // allows sharing with Qt window
            shareWindow->makeCurrent();
            shCtx = glXGetCurrentContext();
        }
#endif
    }

    int type = GLX_RGBA_TYPE;
    if( getIAttribute( IATTR_HINT_DRAWABLE ) == PBUFFER &&
        ( getIAttribute( IATTR_PLANES_COLOR ) == RGBA16F ||
          getIAttribute( IATTR_PLANES_COLOR ) == RGBA32F ))
    {
        type = GLX_RGBA_FLOAT_TYPE;
    }

    GLXContext context = 0;
    if( glXCreateContextAttribsARB &&
        getIAttribute( IATTR_HINT_CORE_PROFILE ) == ON )
    {
        int attribList[] = {
            GLX_CONTEXT_MAJOR_VERSION_ARB,
            getIAttribute( IATTR_HINT_OPENGL_MAJOR ),
            GLX_CONTEXT_MINOR_VERSION_ARB,
            getIAttribute( IATTR_HINT_OPENGL_MINOR ),
            GLX_RENDER_TYPE, type,
            GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
            None
        };

        context = glXCreateContextAttribsARB( _impl->xDisplay, fbConfig[0],
                                              shCtx, True, attribList );
    }
    else
    {
        if( GLXEW_VERSION_1_3 )
            context = glXCreateNewContext( _impl->xDisplay, fbConfig[0], type,
                                           shCtx, True );
        else
            context = glXCreateContextWithConfigSGIX( _impl->xDisplay,
                                               fbConfig[0], type, shCtx, True );
    }

#ifdef Darwin
    // WAR http://xquartz.macosforge.org/trac/ticket/466
    if( !context )
    {
        XVisualInfo* visInfo = GLXEW_VERSION_1_3 ?
            glXGetVisualFromFBConfig( _impl->xDisplay, fbConfig[0] ) :
            glXGetVisualFromFBConfigSGIX( _impl->xDisplay, fbConfig[0] );
        if( !visInfo )
        {
            std::vector<int> attributes;
            attributes.push_back( GLX_RGBA );
            attributes.push_back( GLX_RED_SIZE );
            attributes.push_back( 1 );
            attributes.push_back( GLX_ALPHA_SIZE );
            attributes.push_back( 1 );
            attributes.push_back( GLX_DEPTH_SIZE );
            attributes.push_back( 1 );
            attributes.push_back( GLX_DOUBLEBUFFER );
            attributes.push_back( None );

            const int screen = DefaultScreen( _impl->xDisplay );
            visInfo = glXChooseVisual( _impl->xDisplay, screen,
                                       &attributes.front( ));
            if( !visInfo )
            {
                sendError( ERROR_GLXWINDOW_NO_VISUAL );
                return 0;
            }
        }

        context = glXCreateContext( _impl->xDisplay, visInfo, shCtx, True );
        XFree( visInfo );
    }
#endif

    if( !context )
    {
        sendError( ERROR_GLXWINDOW_CREATECONTEXT_FAILED );
        return 0;
    }
    return context;
}
Exemple #7
0
bool Window::configInitGL( const eq::uint128_t& initID )
{
LBINFO << "-----> Window::configInitGL(" << initID <<
    ", " << getPixelViewport( ) <<
    ", " << getViewport( ) << ")" << std::endl;

    bool init = false;

    LBASSERT( !_window.valid( ));

    if( !eq::Window::configInitGL( initID ))
        goto out;

    {
        const eq::PixelViewport& pvp = getPixelViewport( );
        const eq::DrawableConfig& dc = getDrawableConfig( );

        osg::ref_ptr< osg::GraphicsContext::Traits > traits =
            new osg::GraphicsContext::Traits( );
        traits->x = pvp.x;
        traits->y = pvp.y;
        traits->width = pvp.w;
        traits->height = pvp.h;
        traits->red = traits->blue = traits->green = dc.colorBits;
        traits->alpha = dc.alphaBits;
        traits->stencil = dc.stencilBits;
        traits->doubleBuffer = dc.doublebuffered;
#if 0
        traits->pbuffer =
            ( getIAttribute( IATTR_HINT_DRAWABLE ) == eq::PBUFFER );
#endif
        std::ostringstream version;
        version << dc.glVersion;
        traits->glContextVersion = version.str( );

#if 0
        Window* sharedWindow =
            static_cast< Window* >( getSharedContextWindow( ));
        if( sharedWindow && ( sharedWindow != this ))
            traits->sharedContext = sharedWindow->getGraphicsContext( );
#endif

        _window = new osgViewer::GraphicsWindowEmbedded( traits );

        static_cast< Node* >( getNode( ))->addGraphicsContext( _window );

        const unsigned int maxTexturePoolSize =
            osg::DisplaySettings::instance( )->getMaxTexturePoolSize( );
        const unsigned int maxBufferObjectPoolSize =
            osg::DisplaySettings::instance( )->getMaxBufferObjectPoolSize( );

        if( maxTexturePoolSize > 0 )
            getState( )->setMaxTexturePoolSize( maxTexturePoolSize );
        if( maxBufferObjectPoolSize > 0 )
            getState( )->setMaxBufferObjectPoolSize( maxBufferObjectPoolSize );

        initCapabilities( _window );
    }

    init = true;

out:
    if( !init )
        cleanup( );

LBINFO << "<----- Window::configInitGL(" << initID << ")" << std::endl;

    return init;
}