🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #37405

Re: Question about XCopyArea

#37405
From: Heather Rose
Date: Tue, 27 Feb 1990 02:14
70 lines
3150 bytes
In article <1990Feb16.010419.2462@athena.mit.edu> bjaspan@athena.mit.edu (Barr3y Jaspan) writes:
>In article <401@ai.etl.army.mil>, anneb@ai.etl.army.mil (Anne Brink) writes:
>> I'm working on a graphics application in X, and I need a fast copy
>routine for
>> pixmaps. I'm calling it several zillion times in the space of oh, a few
>> minutes, and it takes over the entire machine.  Right now, I have the code
>> looping forever,  with 5-7 XCopyArea() calls followed by a mouse click check 
>> in each iteration....
>
>It sounds like the problem you are having is that the XCopyArea requests
>get to the server faster than it can possibly deal with them, so they get
>queued.  When you click a mouse button, it also goes on the queue and isn't
>handled until all the XCopyAreas are.
>
>I am finishing up a Xlib video game that does some very similar hosing of the
>server.. basically, each "tick" every object in the game is told to move, and
>every object that actually moves does two XCopyAreas (one to erase itself, 
>one to draw itself in the new position.)  This results in zillions of calls
>to XCopyArea.

This sounds like good advice to me.  Since the original poster mentioned she
was using SunView, I'll mention that if you are using XView, you can easily
implement the "tick" with the notify_set_itimer_func().  The flushing and
syncing is done by the toolkit, but you can add more if you like.

There is an example of using a notify timer for animation in the online
O'Reilly examples.  I have included the relevant code snippets below...

FYI:  clock interrupt on sun3's and sun4's is about 10ms.  So resolution
as seen from a UNIX process is about 20ms.  About 2 to 2.5 images each second 
might be reasonable X11 animation--depends on how long each image takes to 
display.  I would suggest experimenting.  

Although a realtime video system (using special display hardware) would be 
more along the line of about 30 frames each second.  Of course, you want the 
window system to politely move out of it's way ;-)

Regards,

Heather

------------------

/* from "animate.c" */

struct itimerval timer;
...

turn it on or adjust time:

	timer.it_value.tv_usec = some value;
	timer.it_interval.tv_usec = some other value;

	notify_set_itimer_func(frame, animate,
		ITIMER_REAL, &timer, NULL);

turn it off:

	notify_set_itimer_func(frame, NOTIFY_FUNC_NULL, 
		ITIMER_REAL, NULL, NULL);

then the proc that is called each "tick":

Notify_value
animate(/* optional parameters */)
{
	draw your stuff or do whatever

	return NOTIFY_DONE;
}
Technical Details
Message-ID: <132260@sun.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sun!kimba!hvr
References: <401@ai.etl.army.mil> <1990Feb16.010419.2462@athena.mit.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sun!kimba!hvr
From: hvr@kimba.Sun.COM (Heather Rose)
Newsgroups: comp.windows.x
Subject: Re: Question about XCopyArea
Keywords: XSun (is there a way around this?)
Message-ID: <132260@sun.Eng.Sun.COM>
Date: 27 Feb 90 02:14:21 GMT
References: <401@ai.etl.army.mil> <1990Feb16.010419.2462@athena.mit.edu>
Sender: news@sun.Eng.Sun.COM
Reply-To: hvr@sun.UUCP (Heather Rose)
Distribution: na
Organization: Sun Microsystems, Mountain View
Lines: 70