home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fastgpi.zip / fastgpi.doc < prev    next >
Text File  |  1994-09-01  |  3KB  |  70 lines

  1. Method for Getting Fast Graphics through the OS/2 GPI
  2. -----------------------------------------------------
  3.  
  4.   People are often surprised and dismayed to find that the GPI can be
  5. very slow if it is used naively. One of the biggest mistakes is to try to
  6. write a large number of pixels using GpiSetPel(). To reassure people that
  7. fast screen writes CAN be achieved with the GPI and without needing to
  8. go to the MMPM direct-screen support (DIVE), I have provided this little
  9. example. As a bonus, it also shows how to use bitmaps, how to write a
  10. multi-threaded application, how to use semaphores, and how to set up a
  11. gray-scale palette. Also, you can learn about classical wave behavior
  12. and its difference equation representation!
  13.  
  14.   The basic technique for fast screen writes is to make a bitmap that
  15. corresponds to the screen. Then, using GpiSetBitmapBits(), this bitmap
  16. is updated and then blitted to the screen. This requires only two GPI
  17. calls to write an arbitrary number of pixels, instead of doing a call to
  18. set the color and a call to write the pixel for EACH pixel.
  19.  
  20.   Here are miscellaneous notes.
  21.  
  22. 1)  The example implements a simulation of two interfering circular wave
  23.     sources in two dimensions. The output is displayed with a 32-level
  24.     grayscale.
  25.  
  26. 2)  A 256-color display at 1024x768 is assumed. The 256 colors are required
  27.     to get the gray-scale palette. That could be dispensable for other
  28.     applications. I have not tried this at other resolutions, but things
  29.     should work OK (or could be easily adjusted for).
  30.  
  31. 3)  Built with GCC/2 2.5.4.
  32.  
  33. 4)  The screens are written very fast [DisplayPlane()] but there is delay
  34.     between the screen writes due to the many thousands of floating-point
  35.     calculations needed to simulate the wave behavior. Most applications
  36.     will not be so compute-bound.
  37.  
  38. 5)  There may be a more direct method for getting the RGB mappings than
  39.     that used in PrepareGraphics(). Any ideas?
  40.  
  41. 6)  This trick is suitable for applications where you want to write a lot
  42.     of points often. If the drawing is sparse, you may be better off with
  43.     straight GPI calls (I haven't really analyzed this yet).
  44.  
  45. 7)  If you doubt the effectiveness of this trick, try implementing it with
  46.     GpiSetPel(). You'll be reminded of the DOS BIOS!
  47.  
  48. 8)  The example is multithreaded; one thread does the model, one does the main
  49.     window handling. Down with clock icons!!!
  50.  
  51. 9)  Thanks to George Thiruvathakal for providing the array support package.
  52.     It makes possible the highly efficient shifting of planes required at
  53.     each epoch update (an operation not possible with straightforward
  54.     3-dimensional C array syntax).
  55.  
  56. 10) Permission to use as a guide for your own applications. Have fun!
  57.     Feedback to:
  58.  
  59.     Donald Graft   dgraft@gate.net
  60.  
  61.   The following files make up the example application:
  62.  
  63.     build.cmd   -- command file to build the application. Assumes GCC/2 2.5.4.
  64.     fastgpi.def -- module definition file
  65.     fastgpi.c   -- main file
  66.     fastgpi.exe -- the executable
  67.     fastgpi.doc -- this file
  68.     a-float.h   -- header for array package
  69.     a-float.c   -- array package code
  70.