Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vblank sync



What sort of thread are we talking about below? A cooperative (thread manager) thread, an MP services (preemptive) thread or a raw pthread?

Or does it not matter?


cheers, os.


On 16 Sep 2004, at 02:08, Shaun Wexler wrote:

On Sep 15, 2004, at 1:34 PM, Os wrote:

I'm writing a Carbon app, using agl for OpenGL interfacing. I'm using AGL_SWAP_INTERVAL to lock the buffer swaps to the screen refresh rate.

My app will do OpenGL drawing in response to Carbon events. If I receive events more frequently than the refresh rate, how I can I know this and avoid redundant screen redraws (that will just stall until the next vblank)? Is there a way to know that e.g. aglSwapBuffers() is still pending?

If you're calling AGK to perform your drawing on the main thread, the whole app will block while a VBL-sync'ed swap is pending, so it's all automatic... your app won't run any faster than the graphics allows.


Similarly, is there a mechanism for knowing if a vblank is still a long way off? E.g. if one received an event, one might not want to call the drawing code immediately if you knew that you were likely to get another event in before the next refresh.

Perform all of your drawing in another thread, and use (atomic) flags as semaphores to coordinate them. When new data arrives, test & set a "newData" flag; if FALSE, signal the drawing thread. In your drawing thread (which can block), when it returns from the flushSwap, test for newData; sleep on a semaphore or condition if FALSE, otherwise redraw again. Simple? ;)
--
Shaun Wexler
MacFOH
http://www.macfoh.com


Efficiency is intelligent laziness.

email@hidden
http://www.collective.co.uk/

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden
References: 
 >vblank sync (From: Os <email@hidden>)
 >Re: vblank sync (From: Shaun Wexler <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.