Changeset 117ebd7e7f293625f016d4da8d04484e6c447a19
- Timestamp:
- 04/01/08 01:07:34 (1 year ago)
- git-parent:
- Files:
-
- modules/video_output/opengllayer.m (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/video_output/opengllayer.m
r978372f r117ebd7 239 239 vout_sys_t *p_sys = p_vout->p_sys; 240 240 241 p_vout->p_sys->b_frame_available = 0;241 p_vout->p_sys->b_frame_available = VLC_FALSE; 242 242 243 243 [CATransaction performSelectorOnMainThread:@selector(begin) … … 254 254 255 255 /* Free the texture buffer*/ 256 if( p_sys->pp_buffer[0] )free( p_sys->pp_buffer[0] );257 if( p_sys->pp_buffer[1] )free( p_sys->pp_buffer[1] );256 free( p_sys->pp_buffer[0] ); 257 free( p_sys->pp_buffer[1] ); 258 258 } 259 259 … … 297 297 /* Give a buffer where the image will be rendered */ 298 298 p_pic->p->p_pixels = p_sys->pp_buffer[p_new_index]; 299 300 299 } 301 300 … … 313 312 } 314 313 315 p_sys->b_frame_available = 1;314 p_sys->b_frame_available = VLC_TRUE; 316 315 } 317 316 … … 395 394 { 396 395 vout_thread_t * p_vout = [arg pointerValue]; 397 p_vout->p_sys->o_layer = [[VLCVoutLayer layerWithVout: p_vout] retain];396 p_vout->p_sys->o_layer = [[VLCVoutLayer layerWithVout:p_vout] retain]; 398 397 [p_vout->p_sys->o_cocoa_container addVoutLayer:p_vout->p_sys->o_layer]; 399 398 } … … 420 419 - (BOOL)canDrawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp 421 420 { 422 /* Only draw the frame when if have a frame that was previously rendered */ 423 BOOL ret = p_vout->p_sys->b_frame_available; 424 p_vout->p_sys->b_frame_available = VLC_FALSE; 425 return ret; 421 /* Only draw the frame if we have a frame that was previously rendered */ 422 return p_vout->p_sys->b_frame_available; // Flag is cleared by drawInCGLContext:pixelFormat:forLayerTime:displayTime: 426 423 } 427 424 … … 449 446 p_vout->fmt_out.i_height, 450 447 VLCGL_FORMAT, VLCGL_TYPE, p_vout->p_sys->pp_buffer[p_vout->p_sys->i_index] ); 451 452 448 453 449 glClear( GL_COLOR_BUFFER_BIT ); … … 467 463 468 464 CGLUnlockContext( glContext ); 469 p_vout->p_sys->b_frame_available = VLC_FALSE; 470 } 471 472 - (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask 473 { 474 GLuint attribs[] = 475 { 476 NSOpenGLPFANoRecovery, 477 NSOpenGLPFAWindow, 478 NSOpenGLPFAAccelerated, 479 NSOpenGLPFADoubleBuffer, 480 NSOpenGLPFAColorSize, 24, 481 NSOpenGLPFAAlphaSize, 8, 482 NSOpenGLPFADepthSize, 24, 483 NSOpenGLPFAStencilSize, 8, 484 NSOpenGLPFAAccumSize, 0, 485 0 486 }; 487 488 NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) attribs]; 465 466 p_vout->p_sys->b_frame_available = VLC_FALSE; 467 } 468 469 // - (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask 470 // { 471 // GLuint attribs[] = 472 // { 473 // NSOpenGLPFANoRecovery, 474 // NSOpenGLPFAWindow, 475 // NSOpenGLPFAAccelerated, 476 // NSOpenGLPFADoubleBuffer, 477 // NSOpenGLPFAColorSize, 24, 478 // NSOpenGLPFAAlphaSize, 8, 479 // NSOpenGLPFADepthSize, 24, 480 // NSOpenGLPFAStencilSize, 8, 481 // NSOpenGLPFAAccumSize, 0, 482 // 0 483 // }; 484 // 485 // NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) attribs]; 486 // 487 // return [fmt CGLPixelFormatObj]; 488 // } 489 490 - (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat 491 { 492 CGLContextObj context = [super copyCGLContextForPixelFormat:pixelFormat]; 493 494 CGLLockContext( context ); 489 495 490 return [super copyCGLPixelFormatForDisplayMask:mask];//[fmt CGLPixelFormatObj]; 491 } 492 493 - (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat 494 { 495 CGLContextObj context = [super copyCGLContextForPixelFormat:pixelFormat]; 496 496 CGLSetCurrentContext( context ); 497 497 498 498 /* Swap buffers only during the vertical retrace of the monitor. … … 502 502 GLint params = 1; 503 503 CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval, 504 ¶ms );504 ¶ms ); 505 505 506 /* Make sure our texture will gets drawn at the right resolution */507 GLint dim[2] = { p_vout->p_sys->i_tex_width, p_vout->p_sys->i_tex_height};508 NSLog(@"asking for %dx%d", p_vout->p_sys->i_tex_width, p_vout->p_sys->i_tex_height);509 CGLSetParameter(context, kCGLCPSurfaceBackingSize, dim);510 CGLEnable (context, kCGLCESurfaceBackingSize);511 512 CGLSetCurrentContext( context );513 506 InitTextures( p_vout ); 514 507 515 glDisable( GL_BLEND);516 glDisable( GL_DEPTH_TEST);517 glDepthMask( GL_FALSE);518 glDisable( GL_CULL_FACE);508 glDisable( GL_BLEND ); 509 glDisable( GL_DEPTH_TEST ); 510 glDepthMask( GL_FALSE ); 511 glDisable( GL_CULL_FACE) ; 519 512 glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); 520 513 glClear( GL_COLOR_BUFFER_BIT ); 521 514 515 CGLUnlockContext( context ); 522 516 return context; 523 517 } … … 532 526 CGLUnlockContext( glContext ); 533 527 } 534 535 528 @end
