/* Programme test des routines de remplissage de polygone A lier avec L40-1.C et L40-2.C ou L40-5.ASM en modèle small. Testé avec Borland C++ 4.02 par Jim Mischel 12/16/94. */ #include #include #include "polygon.h" #define DRAW_POLYGON(PointList,Color,Shape,X,Y) \ Polygon.Length = sizeof(PointList)/sizeof(struct Point); \ Polygon.PointPtr = PointList; \ FillPolygon(&Polygon, Color, Shape, X, Y); void main(void); extern int FillPolygon(struct PointListHeader *, int, int, int, int); void main() { int i, j; struct PointListHeader Polygon; static struct Point Polygon1[] = {{0,0},{100,150},{320,0},{0,200},{220,50},{320,200}}; static struct Point Polygon2[] = {{0,0},{320,0},{320,200},{0,200},{0,0},{50,50}, {270,50},{270,150},{50,150},{50,50}}; static struct Point Polygon3[] = {{0,0},{10,0},{105,185},{260,30},{15,150},{5,150},{5,140}, {260,5},{300,5},{300,15},{110,200},{100,200},{0,10}}; static struct Point Polygon4[] = {{0,0},{30,-20},{30,0},{0,20},{-30,0},{-30,-20}}; static struct Point Triangle1[] = {{30,0},{15,20},{0,0}}; static struct Point Triangle2[] = {{30,20},{15,0},{0,20}}; static struct Point Triangle3[] = {{0,20},{20,10},{0,0}}; static struct Point Triangle4[] = {{20,20},{20,0},{0,10}}; union REGS regset; /* Paramètre l'affichage en mode 13h du VGA, mode 320x200 256 en couleurs */ regset.x.ax = 0x0013; int86(0x10, ®set, ®set); /* Affiche trois polygones complexes */ DRAW_POLYGON(Polygon1, 15, COMPLEX, 0, 0); getch(); /* attend une touche clavier */ DRAW_POLYGON(Polygon2, 5, COMPLEX, 0, 0); getch(); /* attend une touche clavier */ DRAW_POLYGON(Polygon3, 3, COMPLEX, 0, 0); getch(); /* attend une touche clavier */ /* Affiche quelques polygones adjacents non convexes */ for (i=0; i<5; i++) { for (j=0; j<8; j++) { DRAW_POLYGON(Polygon4, 16+i*8+j, NONCONVEX, 40+(i*60), 30+(j*20)); } } getch(); /* attend une touche clavier */ /* affiche des triangles adjacents à l'écran */ for (j=0; j<=80; j+=20) { for (i=0; i<290; i += 30) { DRAW_POLYGON(Triangle1, 2, CONVEX, i, j); DRAW_POLYGON(Triangle2, 4, CONVEX, i+15, j); } } for (j=100; j<=170; j+=20) { /* affiche une rangée de triangles pointant vers la droite */ for (i=0; i<290; i += 20) { DRAW_POLYGON(Triangle3, 40, CONVEX, i, j); } /* affiche une rangée de triangles pointant vers la gauche à mi-chemin entre une rangée de triangles pointant vers la droite et la prochaine rangée pour s'insérer entre les deux */ for (i=0; i<290; i += 20) { DRAW_POLYGON(Triangle4, 1, CONVEX, i, j+10); } } getch(); /* attend une touche clavier */ /* Revient en mode texte et quitte */ regset.x.ax = 0x0003; int86(0x10, ®set, ®set); }