예제 #1
0
void Window::configExit()
{
    WindowRef window = getCarbonWindow();
    setCarbonWindow( 0 );

    AGLContext context = getAGLContext();

    if( getIAttribute( WindowSettings::IATTR_HINT_FULLSCREEN ) == ON )
    {
        LBASSERT( !window );
        exitEventHandler();
    }
    else if( window )
    {
        Global::enterCarbon();
        aglSetWindowRef( context, 0 );
        DisposeWindow( window );
        Global::leaveCarbon();
    }

    configExitFBO();
    exitGLEW();

    if( context )
    {
        Global::enterCarbon();
        aglSetCurrentContext( 0 );
        aglDestroyContext( context );
        Global::leaveCarbon();
        setAGLContext( 0 );
    }

    LBVERB << "Destroyed AGL window and context" << std::endl;
}
예제 #2
0
bool Window::configInitAGLFullscreen()
{
    AGLContext context = getAGLContext();
    if( !context )
    {
        sendError( ERROR_AGLWINDOW_NO_CONTEXT );
        return false;
    }

    Global::enterCarbon();
    aglEnable( context, AGL_FS_CAPTURE_SINGLE );

    const PixelViewport& pvp = getPixelViewport();
    if( !aglSetFullScreen( context, pvp.w, pvp.h, 0, 0 ))
        LBWARN << "aglSetFullScreen to " << pvp << " failed: " << aglError()
               << std::endl;

    // Do focus hell
    ProcessSerialNumber selfProcess = { 0, kCurrentProcess };
    SetFrontProcess( &selfProcess );

    Global::leaveCarbon();

    setPixelViewport( pvp );

    if( getIAttribute( WindowSettings::IATTR_HINT_DRAWABLE ) != OFF )
        initEventHandler();
    return true;
}
예제 #3
0
bool Window::configInitAGLPBuffer()
{
    AGLContext context = getAGLContext();
    if( !context )
    {
        setError( ERROR_AGLWINDOW_NO_CONTEXT );
        return false;
    }

    // PBuffer
    const PixelViewport& pvp = getWindow()->getPixelViewport();
    AGLPbuffer pbuffer;
    if( !aglCreatePBuffer( pvp.w, pvp.h, GL_TEXTURE_RECTANGLE_EXT, GL_RGBA,
                           0, &pbuffer ))
    {
        setError( ERROR_AGLWINDOW_CREATEPBUFFER_FAILED );
        LBWARN << getError() << ": " << AGLERROR << std::endl;
        return false;
    }

    // attach to context
    if( !aglSetPBuffer( context, pbuffer, 0, 0, aglGetVirtualScreen( context )))
    {
        setError( ERROR_AGLWINDOW_SETPBUFFER_FAILED );
        LBWARN << getError() << ": " << AGLERROR << std::endl;
        return false;
    }

    setAGLPBuffer( pbuffer );
    return true;
}
예제 #4
0
bool Window::configInitAGLWindow()
{
    AGLContext context = getAGLContext();
    if( !context )
    {
        sendError( ERROR_AGLWINDOW_NO_CONTEXT );
        return false;
    }

    // window
    const bool decoration =
        getIAttribute(WindowSettings::IATTR_HINT_DECORATION) != OFF;
    WindowAttributes winAttributes = ( decoration ?
                                       kWindowStandardDocumentAttributes :
                                       kWindowNoTitleBarAttribute |
                                       kWindowNoShadowAttribute   |
                                       kWindowResizableAttribute  ) |
                                     kWindowStandardHandlerAttribute | kWindowInWindowMenuAttribute;

    // top, left, bottom, right
    const PixelViewport& pvp = getPixelViewport();
    const int32_t menuHeight = decoration ? EQ_AGL_MENUBARHEIGHT : 0 ;
    Rect windowRect = { short( pvp.y + menuHeight ), short( pvp.x ),
                        short( pvp.getYEnd() + menuHeight ),
                        short( pvp.getXEnd( ))
                      };
    WindowRef windowRef;

    Global::enterCarbon();
    const OSStatus status = CreateNewWindow( kDocumentWindowClass,
                            winAttributes,
                            &windowRect, &windowRef );
    if( status != noErr )
    {
        sendError( ERROR_AGLWINDOW_CREATEWINDOW_FAILED )
                << lexical_cast< std::string >( status );
        Global::leaveCarbon();
        return false;
    }

    // window title
    const std::string& name = getName();
    std::stringstream windowTitle;

    if( name.empty( ))
    {
        windowTitle << "Equalizer";
#ifndef NDEBUG
        windowTitle << " (" << getpid() << ")";
#endif
    }
    else
        windowTitle << name;

    CFStringRef title = CFStringCreateWithCString( kCFAllocatorDefault,
                        windowTitle.str().c_str(),
                        kCFStringEncodingMacRoman );
    SetWindowTitleWithCFString( windowRef, title );
    CFRelease( title );

    if( !aglSetWindowRef( context, windowRef ))
    {
        sendError( ERROR_AGLWINDOW_SETWINDOW_FAILED ) << aglError();
        Global::leaveCarbon();
        return false;
    }

    // show
    ShowWindow( windowRef );

    // Do focus hell
    ProcessSerialNumber selfProcess = { 0, kCurrentProcess };
    SetFrontProcess( &selfProcess );

    Global::leaveCarbon();
    setCarbonWindow( windowRef );

    return true;
}