Graphics.h
上传用户:lhwx1029
上传日期:2013-03-07
资源大小:1173k
文件大小:5k
源码类别:

3D图形编程

开发平台:

Visual C++

  1. #if ((!defined(_CI_)) && (!defined(_RGB_)))
  2.  #error Either _CI_ or _RGB_ must be declared.
  3. #endif
  4. #if ((!defined(_Z_BUFFER_)) && (!defined(_PAINTER_)))
  5.  #error Either _Z_BUFFER_ or _PAINTER_ must be declared.
  6. #endif
  7. #if ((!defined(_STEREO_)) && (!defined(_MONO_)))
  8.  #error Either _STEREO_ or _MONO_ must be declared.
  9. #endif
  10. #if !defined(_GRAPHICS_H_)
  11. #define _GRAPHICS_H_
  12. /** 3DGPL *************************************************
  13.  * ()                                                     *
  14.  * Header for 2D graphics stuff.                          *
  15.  *                                                        *
  16.  * Ifdefs:                                                *
  17.  *  _CI_                     Colour/Intensity model;      *
  18.  *  _RGB_                    RGB model;                   *
  19.  *  _Z_BUFFER_               Depth array;                 *
  20.  *  _PAINTER_                Back to front order;         *
  21.  *  _STEREO_                 Interlaced 2 page image;     *
  22.  *  _MONO_                   Single page.                 * 
  23.  *                                                        *
  24.  * Files:                                                 *
  25.  *  grp-base.c               Basic graphics;              *
  26.  *  grp-text.c               Text;                        *
  27.  *  grp-poly.c               Polygon rendering.           * 
  28.  *                                                        *
  29.  * (c) 1995-98 Sergei Savchenko, (savs@cs.mcgill.ca)      *
  30. **********************************************************/
  31. #include "RayTracing.h"           /* HW_pixel */
  32. #define G_MAX_POLYGON_VERTICES  16          /* points in a polygon */
  33. #define G_Z_MAPPING_SWITCH    1024          /* when switch linear/non-linear */
  34. #define G_P                     16          /* fixed point precision */
  35. #if defined(_CI_)
  36.  #if defined(_Z_BUFFER_)                    /* Z I Tx Ty */
  37.   #define G_LNG_FLAT     3                  /* X Y Z */
  38.   #define G_LNG_SHADED   4                  /* X Y Z I */
  39.   #define G_LNG_TEXTURED 6                  /* X Y Z I Tx Ty */
  40.  #endif
  41.  #if defined(_PAINTER_)                     /* I Tx Ty */
  42.   #define G_LNG_FLAT     2                  /* X Y */
  43.   #define G_LNG_SHADED   3                  /* X Y I */
  44.   #define G_LNG_TEXTURED 5                  /* X Y I Tx Ty */
  45.  #endif
  46. #endif
  47. #if defined(_RGB_)
  48.  #if defined(_Z_BUFFER_)                    /* Z R G B Tx Ty */
  49.   #define G_LNG_FLAT     3                  /* X Y Z */
  50.   #define G_LNG_SHADED   6                  /* X Y Z R G B */
  51.   #define G_LNG_TEXTURED 8                  /* X Y Z R G B Tx Ty */
  52.  #endif
  53.  #if defined(_PAINTER_)                     /* R G B Tx Ty */
  54.   #define G_LNG_FLAT     2                  /* X Y */
  55.   #define G_LNG_SHADED   5                  /* X Y R G B */
  56.   #define G_LNG_TEXTURED 7                  /* X Y R G B Tx Ty */
  57.  #endif
  58. #endif
  59. extern HW_pixel *G_c_buffer;
  60. extern long G_c_buffer_size;
  61. void G_init_graphics(void);
  62. #if defined(_STEREO_)
  63.  #define G_LEFT_EYE  0x0                    /* render image for left eye */
  64.  #define G_RIGHT_EYE 0x1                    /* render image for right eye */
  65. void G_page(int page_no);
  66. #endif
  67. #if defined(_CI_)
  68. void G_clear(HW_pixel colour,int intensity);
  69. void G_pixel(int *vertex,HW_pixel colour);
  70. void G_dot(int *vertex,HW_pixel colour,int intensity);
  71. void G_line(int *vertex1,int *vertex2,
  72.             HW_pixel colour,int intensity
  73.    );
  74. void G_text(int x,int y,char *txt,
  75.             HW_pixel colour,int intensity
  76.    );
  77. void G_flat_polygon(int *edges,int length,
  78.                     HW_pixel colour,int intensity
  79.                    );
  80. #endif
  81. #if defined(_RGB_)
  82. void G_clear(HW_pixel colour,int red,int green,int blue);
  83. void G_pixel(int *vertex,HW_pixel colour);
  84. void G_dot(int *vertex,HW_pixel colour,int red,int green,int blue);
  85. void G_line(int *vertex1,int *vertex2,
  86.             HW_pixel colour,int red,int green,int blue
  87.            );
  88. void G_text(int x,int y,char *txt,
  89.             HW_pixel colour,int red,int green,int blue
  90.            );
  91. void G_flat_polygon(int *edges,int length,
  92.                     HW_pixel colour,int red,int green,int blue
  93.                    );
  94. #endif
  95. void G_shaded_polygon(int *edges,int length,HW_pixel colour);
  96. void G_lin_textured_polygon(int *edges,int length,
  97.                             HW_pixel *texture,
  98.                             int log_texture_size
  99.                            );
  100. void G_prp_textured_polygon(int *edges,int length,
  101.                             int *O,int *u,int *v,
  102.                             HW_pixel *texture,
  103.                             int log_texture_size,
  104.                             int log_texture_scale
  105.                            );
  106. /*********************************************************/
  107. #endif