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.
67 #define INT_EXCHG(a,b) do { \
73 //#define INT_SCALE(var,arg,num,den) ((var) = ((arg) * (num)) / (den))
74 #define INT_SCALE(var,arg,num,den) ((var) = mul_div(arg, num, den))
76 #define INT_CLIPLINE(x1,y1,x2,y2,XMIN,YMIN,XMAX,YMAX,WHEN_OUTSIDE,WHEN_CLIPPED,WHEN_SWAPPED) do { \
80 { INT_EXCHG(y1,y2); INT_EXCHG(x1,x2); WHEN_SWAPPED; } \
81 if((y2 < YMIN) || (y1 > YMAX)) \
84 if((x2 < XMIN) || (x1 > XMAX)) { \
88 INT_SCALE(temp,(y2 - y1),(XMIN - x1),(x2 - x1)); \
89 if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \
94 INT_SCALE(temp,(y2 - y1),(x2 - XMAX),(x2 - x1)); \
95 if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \
100 INT_SCALE(temp,(x2 - x1),(YMIN - y1),(y2 - y1)); \
106 INT_SCALE(temp,(x2 - x1),(y2 - YMAX),(y2 - y1)); \
113 if((x1 < XMIN) || (x2 > XMAX)) { \
117 INT_SCALE(temp,(y2 - y1),(x1 - XMAX),(x1 - x2)); \
118 if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \
123 INT_SCALE(temp,(y2 - y1),(XMIN - x2),(x1 - x2)); \
124 if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \
129 INT_SCALE(temp,(x1 - x2),(YMIN - y1),(y2 - y1)); \
135 INT_SCALE(temp,(x1 - x2),(y2 - YMAX),(y2 - y1)); \
143 #define FL_EXCHG(a,b) do { \
144 float __temp__ = (a); \
149 #define FL_SCALE(var,arg,num,den) ((var) = ((arg) * (num)) / (den))
151 #define FL_CLIPLINE(x1,y1,x2,y2,XMIN,YMIN,XMAX,YMAX,WHEN_OUTSIDE,WHEN_CLIPPED,WHEN_SWAPPED) do { \
155 { FL_EXCHG(y1,y2); FL_EXCHG(x1,x2); WHEN_SWAPPED; } \
156 if((y2 < YMIN) || (y1 > YMAX)) \
159 if((x2 < XMIN) || (x1 > XMAX)) { \
163 FL_SCALE(temp,(y2 - y1),(XMIN - x1),(x2 - x1)); \
164 if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \
169 FL_SCALE(temp,(y2 - y1),(x2 - XMAX),(x2 - x1)); \
170 if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \
175 FL_SCALE(temp,(x2 - x1),(YMIN - y1),(y2 - y1)); \
181 FL_SCALE(temp,(x2 - x1),(y2 - YMAX),(y2 - y1)); \
188 if((x1 < XMIN) || (x2 > XMAX)) { \
192 FL_SCALE(temp,(y2 - y1),(x1 - XMAX),(x1 - x2)); \
193 if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \
198 FL_SCALE(temp,(y2 - y1),(XMIN - x2),(x1 - x2)); \
199 if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \
204 FL_SCALE(temp,(x1 - x2),(YMIN - y1),(y2 - y1)); \
210 FL_SCALE(temp,(x1 - x2),(y2 - YMAX),(y2 - y1)); \