• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSOpenGLView - forcing an update.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOpenGLView - forcing an update.


  • Subject: Re: NSOpenGLView - forcing an update.
  • From: John Clayton <email@hidden>
  • Date: Fri, 23 Nov 2007 12:13:51 +0100

Alistair,

Thanks - I've found something interesting.

The custom NSOpenGLView was NOT specified as being double-buffered in the NIB.

I changed it to be double buffered, and then re-ran the program and the behaviour is now:

- on startup, moving my slider back and forth does not refresh the video frame.

- if I then resize the window, and then move the slider - everything works PERFECTLY.


the drawRect: looks like this:

- (void)drawRect:(NSRect)r
{
	if(_textureContext == 0)
		return;	

	float w = self.frame.size.width;
	float h = self.frame.size.height;

	// the movie is already positioned... just get the current frame.
	CVImageBufferRef imageBuffer = 0;
	QTVisualContextCopyImageForTime(_textureContext,
									kCFAllocatorDefault,
									0,
									&imageBuffer);

	NSRect rect = NSMakeRect(0, 0, w, h);
	CIImage* theImage = 0;

	if(imageBuffer)
	{
		theImage = [CIImage imageWithCVImageBuffer:imageBuffer];
		CGSize cgTexSize = CVImageBufferGetDisplaySize(imageBuffer);
		rect = rectAdjustedToAspectRatio(NSMakeRect(0, 0, w, h),
										 NSMakeSize(cgTexSize.width, cgTexSize.height));

		CVBufferRelease(imageBuffer);
		imageBuffer = 0;

		[_ciContext drawImage: theImage
					   inRect: NSRectToCGRect(rect)
					 fromRect: [theImage extent]];
	}

	// thanks to Alistair!
	[[self openGLContext] flushBuffer];

	// ensures that the context can free released resources regularly
	QTVisualContextTask(_textureContext);
}

so I basically need to force a resize and then things work great after that.

BTW: I set up the view outlet by placing an NSOpenGLView on the NIB, and then setting the type of that view to my GLRenderView class, and then I have the following properties:
- double buffer
- accelerated rendering
- no recovery


everything else is defaulted.

any ideas as to what this odd startup bug might be?

Thanks for the tip - very nice.

--
john clayton

On 23/11/2007, at 12:03 PM, Alastair Houghton wrote:

On 23 Nov 2007, at 09:08, John Clayton wrote:

I would like to know how I can force a bog standard NSOpenGLView to refresh its content. Is it as simple as saying :
[theView setNeedsDisplay:YES]


???

Cos when I do this, my draw method does get called (i.e. drawRect:), but the image on the view itself does not change. When I resize the view, the image is then updated immediately. Anyone else seen this kinda of thing before?

Is your NSOpenGLView double-buffered? If so, are you calling the - flushBuffer method at appropriate times?


Kind regards,

Alastair.

--
http://alastairs-place.net



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSOpenGLView - forcing an update.
      • From: Alastair Houghton <email@hidden>
References: 
 >NSOpenGLView - forcing an update. (From: John Clayton <email@hidden>)
 >Re: NSOpenGLView - forcing an update. (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Re: NSOpenGLView - forcing an update.
  • Next by Date: Re: NSOpenGLView - forcing an update.
  • Previous by thread: Re: NSOpenGLView - forcing an update.
  • Next by thread: Re: NSOpenGLView - forcing an update.
  • Index(es):
    • Date
    • Thread