home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / windows / x / 16562 < prev    next >
Encoding:
Text File  |  1992-09-11  |  2.4 KB  |  63 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!cs.utexas.edu!torn!maccs!xenidis
  3. From: xenidis@maccs.dcss.mcmaster.ca (Jimi X)
  4. Subject: Re: Simple page-flipping animation on X-Windows
  5. Message-ID: <1992Sep11.185357.5467@maccs.dcss.mcmaster.ca>
  6. Organization: Department of Computer Science, McMaster University
  7. References: <1992Sep8.223544.20768@cbnewsl.cb.att.com>
  8. Date: Fri, 11 Sep 1992 18:53:57 GMT
  9. Lines: 52
  10.  
  11. In article <1992Sep8.223544.20768@cbnewsl.cb.att.com> conty@cbnewsl.cb.att.com (OtakuRoach) writes:
  12. >
  13. >I didn't see this on the 600+ backlogged postings, neither did I see a
  14. >FAQ, sooo:
  15. >
  16. >    As a project for a CompGraphics course, I need to animate some
  17. >    lines converging into a wireframe image.  The program is already
  18. >    written, but I'm drawing everything to the same GC, which can be
  19. >    rather annoying if I have to erase and redraw the screen several
  20. >    times per second.  I was thinking of perhaps creating another GC,
  21. >    and do a GC-flipping routine.  Now, how do I go about determining
  22. >    which GC is displayed on the screen?  My professor wasn't of any
  23. >    help.  He doesn't use X for his work, and the class assignments
  24. >    assume MS-DOS with VGA graphics (I'm the weird guy doing his
  25. >    assignments on X because he doesn't have a PC).
  26. >
  27. >If you can help, please e-mail at the address below.  Thank you.
  28. >No, I'm not a regular reader of comp.windows.x.
  29. >-- 
  30. >                E n r i q u e  C o n t y
  31. >            The Incredible Man-with-no-Life
  32. >                  jester@ihlpl.att.com
  33. >            Disclaimer: You're not dealing with AT&T
  34.  
  35. The best way to do this, at least from what I have used, is to create two GC's
  36. one GC is for drawing and another GC for "undrawing".
  37.  
  38. Draw your figure using the XDrawLines() Xlib functions that draws more than
  39. one line in a single X Protocol Routine then XFlush() your display.
  40.  
  41. To animate use the XDrawLines() again with your undraw GC and then 
  42. XDrawLines() with your draw GC and then flush.
  43.  
  44. This emulates page flipping because after a draw request you only see that 
  45. figure when you:
  46.     
  47.     a) fill up the Request Queue
  48.     b) force the queue to be flushed [XFlush]
  49.  
  50. This Works wonders with machines that have a large Request Queue ( >= 64k )
  51.  
  52. To REALLY SPEED things up.  get a hold of the Source for these Xlib Functions
  53. and cat them together excluding the commands that flush sync and do thing that
  54. is not necessary between them and then flush at the end.
  55.  
  56. It may also be better to calculate the horizontal and vertical span and use 
  57. XClearArea() but I doubt it.
  58.  
  59.  
  60. GOOD LUCK
  61.             -jimi x
  62.  
  63.