ADC Home > Reference Library > Technical Q&As > Legacy Documents > Graphics & Imaging >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

NOTE: This Technical Q&A has been retired. Please see the Technical Q&As page for current documentation.

QD3D Is Not Thread-Safe


Q: I am trying to do rendering in a cooperative thread while another thread is doing something else. I thought I would yield from within a rendering loop, but it seems the rendering loop gets executed only once no matter how lengthy the rendering is. Could someone give me some suggestions?

A: The current version of QuickDraw 3D is not thread safe so I would not recommend that you do this. Also QuickDraw itself is not thread safe, so it would be dangerous to even have two threads that do any drawing at all.

However, if you are doing QD3D stuff in one thread and no drawing in the other thread, you could potentially get 3D to yield time by installing a view idle handler. I haven't not tried this from a threaded application, but you may want to give it a go.

Here is a small snippet that shows how you'd define and install the view idle method:


TQ3Status MyIdleMethod( TQ3ViewObject view,  const void *idleData) 
;
TQ3Status MyIdleMethod( TQ3ViewObject view,  const void *idleData)
{
	TQ3Status 	returnResult = kQ3Success ;
	/* do whatever you need to do here */ 
	
	/* 
	 * NOTE: don't do anything that is particulalry time consuming 
	 * or your rendering will take forever!!	
	 */
	return returnResult ;
}

...
		/* install the idle proc defined earlier */
		myStatus = Q3View_SetIdleMethod ( gDocument.fView, MyIdleMethod, NULL ) 
;
...

Note that you'll be called more often from the wireframe renderer than the interactive renderer. Your mileage may vary so you'll need to play around with this stuff.

[Jul 11 1997]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.