home *** CD-ROM | disk | FTP | other *** search
/ Graphics Programming Black Book (Special Edition) / BlackBook.bin / disk1 / source / chapterg / lg-2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-18  |  1.8 KB  |  49 lines

  1. /* Demonstrates non-antialiased drawing in 640x480 Hicolor (32K color) mode on 
  2. an ET4000-based SuperVGA with a Sierra Hicolor DAC installed. 
  3.   Tested with Borland C++ 4.02 in small model by Jim Mischel 12/16/94. 
  4.   Requires: L26-1.C, FILCNVX.C, L22-4.ASM, and either L26-3.C or L26-4.ASM.
  5. */
  6.  
  7. #include <conio.h>
  8. #include <dos.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include "polygon.h"
  12. /* Draws the polygon described by the point list PointList in color
  13.    Color, with all vertices offset by (x,y) */
  14. #define DRAW_POLYGON(PointList,Color,x,y) {                 \
  15.    Polygon.Length = sizeof(PointList)/sizeof(struct Point); \
  16.    Polygon.PointPtr = PointList;                            \
  17.    FillCnvxPolyDrvr(&Polygon, Color, x, y, DrawHCLineList);}
  18.  
  19. void main(void);
  20. extern int SetHCMode(int);
  21. extern int FillCnvxPolyDrvr(struct PointListHeader *, int, int, int,
  22.    void (*)());
  23. extern void DrawHCLineList(struct HLineList *, int);
  24. int BitmapWidthInBytes = 640*2; /* # of bytes per raster line */
  25.  
  26. void main()
  27. {
  28.    struct PointListHeader Polygon;
  29.    static struct Point Face0[] = {{396,276},{422,178},{338,88},{288,178}};
  30.    static struct Point Face1[] = {{306,300},{396,276},{288,178},{210,226}};
  31.    static struct Point Face2[] = {{338,88},{266,146},{210,226},{288,178}};
  32.    union REGS regset;
  33.  
  34.    /* Attempt to enable 640x480 Hicolor mode */
  35.    if (SetHCMode(0x2E) == 0)
  36.       { printf("No Hicolor DAC detected\n"); exit(0); };
  37.  
  38.    /* Draw the cube */
  39.    DRAW_POLYGON(Face0, 0x1F, 0, 0);       /* full-intensity blue */
  40.    DRAW_POLYGON(Face1, 0x1F << 5, 0, 0);  /* full-intensity green */
  41.    DRAW_POLYGON(Face2, 0x1F << 10, 0, 0); /* full-intensity red */
  42.    getch();    /* wait for a keypress */
  43.  
  44.    /* Return to text mode and exit */
  45.    regset.x.ax = 0x0003;   /* AL = 3 selects 80x25 text mode */
  46.    int86(0x10, ®set, ®set);
  47. }
  48.  
  49.