home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Zone / VRZONE.ISO / mac / PC / REND386 / POLYBLIT / F3DKITN.H < prev    next >
C/C++ Source or Header  |  1992-02-05  |  4KB  |  112 lines

  1. extern unsigned int dpaddr;        /* video write base */
  2.  
  3. extern unsigned long l_hold, r_hold;          /* used to hold old x data for edge */
  4.  
  5. extern int l_clip;         /* clipping rectangle for polys and lines */
  6. extern int r_clip;      /* max. 0,319,0,199              */
  7. extern int t_clip;
  8. extern int b_clip;
  9.  
  10. typedef struct lp {           /* set of points for clipping or line dwg */
  11.             int x1, y1, x2, y2;
  12.           } lpoints;
  13.  
  14. extern void far vsync();                /* pause till vert. retrace */
  15. extern void far vga_reg(int reg);     /* load VGA register:  */
  16.                     /* reg = reg# + 256*value */
  17.  
  18. extern void far load_color(int color);  /* load VGA color register */
  19. extern void far set_vmode(int mode);    /* set video mode thru BIOS */
  20. extern void far set_vpage(int page);    /* set video page thru BIOS */
  21.  
  22.  
  23. #define PUT 0        /* defines of VGA write modes */
  24. #define AND 1           /* for use with setup_hdwe()  */
  25. #define OR  2
  26. #define XOR 3
  27.  
  28. extern void far setup_hdwe(int mode);  /* setup VGA for bunch of line */
  29.                        /* or poly draws: once per set */
  30.  
  31. extern void far reset_hdwe();  /* reset VGA to BIOS state after drawing */
  32.  
  33.              /* clear video page to solid color: 10 mS */
  34.              /* returns -1 if bad page #         */
  35. extern int far clr_page(int page, int color);
  36.  
  37.             /* copy one page to another for use as */
  38.             /* background: 21 mS per call          */
  39.             /* returns -1 if bad page #            */
  40. extern int far copy_page(int source, int dest);
  41.  
  42.             /* fast VGA line draw: about 15600 24-pixel */
  43.             /* vectors/sec (horizontal much faster)     */
  44. extern void far vgaline(int x1, int y1, int x2, int y2, int color);
  45.  
  46.             /* line draw using lpoint structure   */
  47. extern void vgalines(lpoints *points, int color);
  48.  
  49.             /* Fast Cohen-Sutherland line clipper */
  50.             /* modifies data in points, returns   */
  51.             /* 0 if not clipped, 1 if clipped,    */
  52.             /* -1 if undrawable                   */
  53.             /* 2 - 10 uS per call                 */
  54. extern int clipper (lpoints far *points);
  55.  
  56.             /* does C-S clipping and draws line   */
  57.             /* returns same codes as C-S clipper  */
  58. extern int clipline (lpoints *points, int color);
  59.  
  60. #define HOLD 0x8000     /* use in x1 or x2 to continue poly side */
  61.  
  62.  
  63. /* NOTE: for all polys, height is 1 less than expected.  This is
  64.    because of the coordinate system used, and aliasing.  So a
  65.    poly with (0,0) (10,0) (0,10) will fill vertical lines 0-9 only.
  66.    This is OK, since real 3D figures consist of overlapping polys.
  67. */
  68.  
  69.             /* draws trapeziodal poly slice FAST   */
  70.             /* x1 is top left, x2 is top right,    */
  71.             /* y1 is top, y3 is bottom.  No clipping  */
  72.             /* is performed.  l_incr and r_incr    */
  73.             /* set slope of sides.               */
  74.             /* if x1 or x2 = HOLD, continues that  */
  75.             /* side from last tpoly call.  Use     */
  76. extern int far tpoly(int x1,int x2, long l_incr, long r_incr,
  77.                             int y1, int y3);
  78.  
  79.                    /* compute (x1-x2)/(y1-y2) << 16 */
  80.                    /* used for tpoly...             */
  81.                    /* returns x1-x2 if y1==y2       */
  82. extern long far compute_slope(int x1, int x2, int y1, int y2);
  83.  
  84. void set_gmode();              /* enters 320x200x16 mode, clears screen */
  85. void restore_gmode();          /* enters 320x200x16 mode w/o  clearing screen */
  86. void exit_gmode();             /* exits to text mode */
  87.  
  88. int set_drawpage(int page);    /* set page for drawing on (0-7)   */
  89.  
  90.              /* set displayed page: uses BIOS   */
  91.              /* call, so DON'T use in interrupt */
  92.              /* routines! If WAIT is 1, will    */
  93.              /* sync with vert. retrace (pause) */
  94. int set_vidpage(int page, int wait);
  95.  
  96.  
  97.                    /* draw and fill 3-sided polygon    */
  98.                    /* automatically clipped to bounds  */
  99.                    /* not a "pretty poly" fill, so     */
  100.                    /* sliver polys break up.           */
  101.                    /* 5800 polys/sec for 24x24         */
  102. poly3(int x1, int y1, int x2, int y2, int x3, int y3, int color);
  103.  
  104.                 /* N-sided poly fill (unclipped)    */
  105.                 /* 3800 30x30 polys/sec             */
  106.                 /* args: ptr to x and y arrays      */
  107.                 /* # of vertices (COUNTERCLOCKWISE) */
  108.                 /* color of poly             */
  109. polyn(int *xp, int *yp, int count, int color);
  110.  
  111.  
  112.