home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / macraysh.sit / Code / Source / picture.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-11  |  1.2 KB  |  66 lines

  1. /*
  2.  * picture.c
  3.  *
  4.  * Complete rewrite of the Rayshade functions.
  5.  * 
  6.  * I should really maintain current compatibility by including a lot of hash defines
  7.  * however I simply do not have enough time to do this.
  8.  */
  9.  
  10. #include <MacHeaders>
  11. #include "rayshade.h"
  12. #include "picture.h"
  13. #include "viewing.h"
  14. #include "options.h"
  15. #include "stats.h"
  16.  
  17. extern void DrawMacWindow(short x, short y, unsigned short r, unsigned short g, unsigned short b) ;
  18. extern void OpenMacWindow(short width, short height) ;
  19.  
  20. /*
  21.  * Convert floating-point (0.-1.) to unsigned char (0-255), with no gamma
  22.  * correction.
  23.  */
  24. unsigned short correct(Float x)
  25. {
  26.     /*
  27.      * Truncate values < 0 or > 1.
  28.      */
  29.     if (x <= 0.0)
  30.         return (unsigned short) 0;
  31.     if (x >= 1.0)
  32.         return (unsigned short) 65535;
  33.     return (unsigned short)(x * 65535.0);
  34. }
  35.  
  36. void PictureStart(char **argv)
  37. {
  38.     OpenMacWindow((short)Screen.xsize, (short)Screen.ysize) ;
  39. }
  40.  
  41.  
  42. void PictureWriteLine(int y, Pixel *buf)
  43. {
  44.     register short i;
  45.     register unsigned short r,g,b ;
  46.  
  47.     for (i = 0; i < Screen.xsize; i++) {
  48.         r = CORRECT(buf[i].r) ;
  49.         g = CORRECT(buf[i].g) ;
  50.         b = CORRECT(buf[i].b) ;
  51.         DrawMacWindow(i,(short)Screen.ysize-(short)y-1, r, g, b) ;
  52.     }
  53. }
  54.  
  55. void
  56. PictureFrameEnd()
  57. {
  58. }
  59.  
  60. void
  61. PictureEnd()
  62. {
  63.     RefreshWindow();
  64. }
  65.  
  66.