-- (void)goFullScreen
-{
- /* Create the new pixel format */
- NSOpenGLPixelFormatAttribute attribs[] =
- {
- NSOpenGLPFAAccelerated,
- NSOpenGLPFANoRecovery,
- NSOpenGLPFADoubleBuffer,
- NSOpenGLPFAColorSize, 24,
- NSOpenGLPFAAlphaSize, 8,
- NSOpenGLPFADepthSize, 24,
- NSOpenGLPFAFullScreen,
- NSOpenGLPFAScreenMask,
- /* TODO multi monitor support */
- CGDisplayIDToOpenGLDisplayMask( kCGDirectMainDisplay ),
- 0
- };
- NSOpenGLPixelFormat * fmt = [[NSOpenGLPixelFormat alloc]
- initWithAttributes: attribs];
- if( !fmt )
- {
- msg_Warn( p_vout, "Cannot create NSOpenGLPixelFormat" );
- return;
- }
-
- /* Create the new OpenGL context */
- /* TODO have the shared context working so we don't have to
- re-init textures */
- fullScreenContext = [[NSOpenGLContext alloc]
- initWithFormat: fmt shareContext: nil];
- if( !fullScreenContext )
- {
- msg_Warn( p_vout, "Failed to create new NSOpenGLContext" );
- return;
- }
- currentContext = fullScreenContext;
-
- /* Capture display, switch to fullscreen */
- /* XXX we should capture only the display the user wants the
- picture on */
- if( CGCaptureAllDisplays() != CGDisplayNoErr )
- {
- msg_Warn( p_vout, "CGCaptureAllDisplays() failed" );
- return;
- }
- [fullScreenContext setFullScreen];
- [fullScreenContext makeCurrentContext];
-
- /* Ratio */
- unsigned width = CGDisplayPixelsWide( kCGDirectMainDisplay );
- unsigned height = CGDisplayPixelsHigh( kCGDirectMainDisplay );
- int stretch = config_GetInt( p_vout, "macosx-stretch" );
- int fill = config_GetInt( p_vout, "macosx-fill" );
- int bigRatio = ( height * p_vout->output.i_aspect <
- width * VOUT_ASPECT_FACTOR );
- if( stretch )
- {
- f_x = 1.0;
- f_y = 1.0;
- }
- else if( ( bigRatio && !fill ) || ( !bigRatio && fill ) )
- {
- f_x = (float) height * p_vout->output.i_aspect /
- width / VOUT_ASPECT_FACTOR;
- f_y = 1.0;
- }
- else
- {
- f_x = 1.0;
- f_y = (float) width * VOUT_ASPECT_FACTOR /
- p_vout->output.i_aspect / height;
- }
-
- /* Update viewport, re-init textures */
- glViewport( 0, 0, width, height );
- [self initTextures];
-
- /* Redraw the last picture */
- [self setNeedsDisplay: YES];
-
- isFullScreen = 1;
-}
-
-- (void)exitFullScreen
-{
- /* Free current OpenGL context */
- [NSOpenGLContext clearCurrentContext];
- [fullScreenContext clearDrawable];
- [fullScreenContext release];
- CGReleaseAllDisplays();
-
- currentContext = [self openGLContext];
- [self initTextures];
- [self reshape];
-
- /* Redraw the last picture */
- [self setNeedsDisplay: YES];
-
- isFullScreen = 0;
-}
-
-- (void) cleanUp
-{
- if( isFullScreen )
- {
- [self exitFullScreen];
- }
- initDone = 0;
-}
-