2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Graphics/Line.h $
15 * Header file for line.cpp
18 * Revision 1.2 2002/06/09 04:41:13 relnev
19 * added copyright header
21 * Revision 1.1.1.1 2002/05/03 03:28:12 root
25 * 2 10/07/98 10:53a Dave
28 * 1 10/07/98 10:49a Dave
30 * 10 5/06/98 5:30p John
31 * Removed unused cfilearchiver. Removed/replaced some unused/little used
32 * graphics functions, namely gradient_h and _v and pixel_sp. Put in new
33 * DirectX header files and libs that fixed the Direct3D alpha blending
36 * 9 3/10/98 4:18p John
37 * Cleaned up graphics lib. Took out most unused gr functions. Made D3D
38 * & Glide have popups and print screen. Took out all >8bpp software
39 * support. Made Fred zbuffer. Made zbuffer allocate dynamically to
40 * support Fred. Made zbuffering key off of functions rather than one
43 * 8 10/03/97 9:10a John
44 * added better antialiased line drawer
46 * 7 6/13/97 5:35p John
47 * added some antialiased bitmaps and lines
49 * 6 11/26/96 6:50p John
50 * Added some more hicolor primitives. Made windowed mode run as current
51 * bpp, if bpp is 8,16,or 32.
53 * 5 10/26/96 2:56p John
54 * Got gradient code working.
56 * 4 10/26/96 1:40p John
57 * Added some now primitives to the 2d library and
58 * cleaned up some old ones.
66 void gr8_line(int x1,int y1,int x2,int y2);
67 void gr8_aaline(vertex *v1, vertex *v2);
70 #define INT_EXCHG(a,b) do { \
76 //#define INT_SCALE(var,arg,num,den) ((var) = ((arg) * (num)) / (den))
77 #define INT_SCALE(var,arg,num,den) ((var) = mul_div(arg, num, den))
79 #define INT_CLIPLINE(x1,y1,x2,y2,XMIN,YMIN,XMAX,YMAX,WHEN_OUTSIDE,WHEN_CLIPPED,WHEN_SWAPPED) do { \
83 { INT_EXCHG(y1,y2); INT_EXCHG(x1,x2); WHEN_SWAPPED; } \
84 if((y2 < YMIN) || (y1 > YMAX)) \
87 if((x2 < XMIN) || (x1 > XMAX)) { \
91 INT_SCALE(temp,(y2 - y1),(XMIN - x1),(x2 - x1)); \
92 if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \
97 INT_SCALE(temp,(y2 - y1),(x2 - XMAX),(x2 - x1)); \
98 if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \
103 INT_SCALE(temp,(x2 - x1),(YMIN - y1),(y2 - y1)); \
109 INT_SCALE(temp,(x2 - x1),(y2 - YMAX),(y2 - y1)); \
116 if((x1 < XMIN) || (x2 > XMAX)) { \
120 INT_SCALE(temp,(y2 - y1),(x1 - XMAX),(x1 - x2)); \
121 if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \
126 INT_SCALE(temp,(y2 - y1),(XMIN - x2),(x1 - x2)); \
127 if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \
132 INT_SCALE(temp,(x1 - x2),(YMIN - y1),(y2 - y1)); \
138 INT_SCALE(temp,(x1 - x2),(y2 - YMAX),(y2 - y1)); \
146 #define FL_EXCHG(a,b) do { \
147 float __temp__ = (a); \
152 #define FL_SCALE(var,arg,num,den) ((var) = ((arg) * (num)) / (den))
154 #define FL_CLIPLINE(x1,y1,x2,y2,XMIN,YMIN,XMAX,YMAX,WHEN_OUTSIDE,WHEN_CLIPPED,WHEN_SWAPPED) do { \
158 { FL_EXCHG(y1,y2); FL_EXCHG(x1,x2); WHEN_SWAPPED; } \
159 if((y2 < YMIN) || (y1 > YMAX)) \
162 if((x2 < XMIN) || (x1 > XMAX)) { \
166 FL_SCALE(temp,(y2 - y1),(XMIN - x1),(x2 - x1)); \
167 if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \
172 FL_SCALE(temp,(y2 - y1),(x2 - XMAX),(x2 - x1)); \
173 if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \
178 FL_SCALE(temp,(x2 - x1),(YMIN - y1),(y2 - y1)); \
184 FL_SCALE(temp,(x2 - x1),(y2 - YMAX),(y2 - y1)); \
191 if((x1 < XMIN) || (x2 > XMAX)) { \
195 FL_SCALE(temp,(y2 - y1),(x1 - XMAX),(x1 - x2)); \
196 if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \
201 FL_SCALE(temp,(y2 - y1),(XMIN - x2),(x1 - x2)); \
202 if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \
207 FL_SCALE(temp,(x1 - x2),(YMIN - y1),(y2 - y1)); \
213 FL_SCALE(temp,(x1 - x2),(y2 - YMAX),(y2 - y1)); \