1 /*----------------------------------------------------------------------*/
2 /* Standard Graphics Package Header File */
3 /*----------------------------------------------------------------------*/
10 /* Write modes for CPIX_?????() routines */
27 #define LS_SOLID 0xffff
28 #define LS_DASH1 0xff00
29 #define LS_DASH2 0xf0f0
30 #define LS_DASH3 0xcccc
31 #define LS_DASH4 0xff3e
32 #define LS_DOTTED 0xaaaa
40 int open; /* TRUE if device is open for output */
41 int xsize, ysize; /* Size of device in pixels */
42 int xmin, ymin; /* smallest coordinates */
43 int xmax, ymax; /* Maximum coordinates */
44 int colormax; /* Maximum color number of device */
45 int style; /* Current linestyle of device */
46 int width; /* Current width of device */
47 int color; /* Current color of device */
48 int icurx, icury; /* Current position */
49 int icwidth, icheight; /* Size of characters in pixels */
50 int cfore, cback; /* Character foregnd & backgnd colors */
51 float asp; /* Aspect ratio. Multipy x coord */
52 int (*dotfunc)(int x1, int y1, int color); /* Dot function for device */
53 int (*linefunc)(int x1, int y1, int x2, int y2, int color); /* Line function for device */
54 unsigned int nbytes; /* Size of buffer in bytes */
55 char *buf; /* Pointer to buffer */
56 unsigned int bufseg, bufoff; /* Buffer memory location */
57 int mode; /* Device mode */
61 float width, height; /* size of characters in NDC */
62 float textangle; /* text angle in radians */
63 float charupangle; /* character up angle */
64 int font; /* font for characters */
65 int updir, textdir; /* text direct & character orientation */
66 int fore, back; /* foreground & background color */
67 /* if back = -1, then transparent back */
71 int foregnd, backgnd; /* current foregound & background colors */
72 int linestyle; /* current 16 bit linestyle */
73 int linewidth; /* current width of line (in pixels) */
74 int marktype; /* current marker type */
75 int markcolor; /* current marker color */
76 float xndc, yndc; /* current position in NDC */
79 typedef struct device_st DEVICE;
80 typedef struct charsp_st CHARSPEC;
81 typedef struct state_st GRFSTATE;
83 struct point {double x, y, z;};
86 /******************************************************************
90 * Max R. Dursteler Dec 1983 *
91 * 12405 Village Square Terrace *
92 * Rockville Md. 20852 *
93 ******************************************************************
98 /* Flagcodes for motion directions */
99 #define XPLUS 001 /* right */
100 #define XMINUS 002 /* left */
101 #define YPLUS 004 /* up */
102 #define YMINUS 010 /* down */
104 /* Codes for marker symbols */
105 #define POINT 0 /* small dot */
106 #define SQUARE 1 /* empty square */
107 #define FSQUARE 2 /* filled square */
108 #define DIAMOND 3 /* empty diamond */
109 #define FDIAMOND 4 /* filled diamond */
110 #define CROSS 5 /* cross */
111 #define XCROSS 6 /* x */
112 #define CERCLE 7 /* open circle */
113 #define FCERCLE 8 /* filled circle */
114 #define BSQUARE 9 /* big open square */
115 #define BDIAMOND 10 /* big open diamond */
117 #define NMARKERS 11 /* Number of available symbol types */
119 /*-------------------------------------------------------------------------*/
121 #define PSET 0 /* codes for raster merging */
127 /*-------------------------------------------------------------------------*/
129 #define X_STKMIN 10 /* joystick specific values */
134 #define X_LOCMAX (X_STKMAX - X_STKMIN); /* range from readloc() */
135 #define Y_LOCMAX (Y_STKMAX - Y_STKMIN); /* = 0 to LOCMAX */
137 #define JOYSTK1 0 /* device names */
140 #define BUTT_DONE 2 /* Right joystick button to end a command */
141 #define BUTT_START 1 /* Left joystick button to start a command */
142 #define BUTT_BOTH 3 /* Both buttons pressed */
144 #define RL_ERROR -1 /* readloc() return codes */
148 /*-------------------------------------------------------------------------*/
156 typedef struct raster_st RASTER;
158 /*-------------------------------------------------------------------------*/
160 typedef double GRFMTX_2D[3][3];
161 typedef double GRFMTX_3D[4][4];
165 void circle(const double r);
166 void drawarc(double start, double stop, const double r);
168 int cliprect(double *x1, double *y1, double *x2, double *y2, const double rect[4]);
170 void crt_line(int x1, int y1, int x2, int y2, int color);
171 int prtline(int func, int x1, int y1, int x2, int y2, int arg1, int arg2);
172 void crt_line_style(int style);
174 void crt_wdot(int x, int y, int c);
175 void ega_wdot(int x, int y, int c);
176 void prtdot(int x, int y, int c);
178 void cpix_set(int x, int y, int c);
179 void cpix_init(void);
180 void cpix_set_wrt_mode(int mode);
181 void cpix_calc_addr(void);
182 void cpix_set_addr(int addr);
183 void cpix_inc_col(void);
184 int cpix_get_addr(void);
185 void cpix_term(void);
186 void cpix_setcolor(int c);
187 void cpix_set_at_addr(int addr, int c);
188 void cpix_inc_row(void);
189 void cpix_set_color(int c);
191 int ctm_xlat_pre_2(double x, double y);
192 int ctm_xlat_post_2(double x, double y);
193 int ctm_scale_pre_2(double sx, double sy);
194 int ctm_scale_post_2(double sx, double sy);
195 int ctm_rotate_pre_2(double theta);
196 int ctm_rotate_post_2(double theta);
197 int ctm_shear_pre_2(double shrx, double shry);
198 int ctm_shear_post_2(double shrx, double shry);
199 int xlat_gmtx_2(GRFMTX_2D m, double x, double y);
200 int scale_gmtx_2(GRFMTX_2D m, double sx, double sy);
201 int shear_gmtx_2(GRFMTX_2D m, double shrx, double shry);
202 int rotate_gmtx_2(GRFMTX_2D m, double theta);
203 int ident_gmtx_2(GRFMTX_2D m);
204 int mult_gmtx_2(GRFMTX_2D a, GRFMTX_2D b, GRFMTX_2D c);
205 int invert_gmtx_2(GRFMTX_2D a, GRFMTX_2D b);
206 double determ_gmtx_2(GRFMTX_2D a);
208 int drawbox(double xmin, double ymin, double xmax, double ymax);
210 int gptrace(int state);
211 int viewprt3(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax);
212 int window3(double xmin, double ymin, double xmax, double ymax);
213 int setproj(int pr, double x, double y, double z);
214 int setvrp(double x, double y, double z);
215 int setvpn(double x, double y, double z);
216 int setvup(double x, double y, double z);
217 int viewdepth(double front, double back);
218 int gpfrontclip(int on_off);
219 int gpbackclip(int on_off);
222 int calcrot(double rot[5][5]);
223 int calcpertrans(void);
224 int calcpartrans(void);
225 int matident(double mtx[5][5]);
226 int matmult(double premtx[5][5], double postmtx[5][5], double result[5][5]);
227 int crossprod(struct point *v, struct point *w, struct point *result);
228 int transform(double mtx[5][5], double *x, double *y, double *z);
229 int homotrans(double mtx[5][5], double *x, double *y, double *z, double *w);
230 int moveabs3(double x, double y, double z);
231 int moverel3(double xr, double yr, double zr);
232 int lineabs3(double x, double y, double z);
233 int linerel3(double xr, double yr, double zr);
234 int drawline(double xinput, double yinput, double zinput);
235 int mastertondc(double *x, double *y, double *z);
236 int checkchange(void);
239 int matwrite(double mtx[5][5]);
240 int pyr_edge(double x, double y, double z, int *pos);
241 int clippyramid(double *x1, double *y1, double *z1, double *x2, double *y2, double *z2, int *accept);
242 int cube_edge(double x, double y, double z, int *pos);
243 int clipcube(double *x1, double *y1, double *z1, double *x2, double *y2, double *z2, int *accept);
245 int pickbox(int dev, int *xmin, int *ymin, int *xmax, int *ymax, int xtab[], int ytab[]);
247 int pickloc(int dev, int *xloc, int *yloc, int xtab[], int ytab[]);
249 int readblock(char array[], int x1, int y1, int x2, int y2);
250 int writeblock(char array[], int x1, int y1, int mode);
251 char *allocblock(int x1, int y1, int x2, int y2);
253 int readloc(int dev, int *x, int *y);
254 int loc_to_ndc(int xloc, int yloc, float *xndc, float *yndc);
255 int readbutt(int dev);
258 int window2(double xmin, double ymin, double xmax, double ymax);
259 int window_2(double xmin, double ymin, double xmax, double ymax);
260 int viewprt2(double xmin, double ymin, double xmax, double ymax);
261 int viewport_2(double xmin, double ymin, double xmax, double ymax);
263 int calc_wc_to_ndc(void);
264 int calc_ndc_to_mc(void);
265 int wc_to_ndc(double xw, double yw, double *xn, double *yn);
266 int ndc_to_wc(double xn, double yn, double *xw, double *yw);
268 int linestyle(int style);
269 int line_abs_2(double x, double y);
270 int lineabs2(double x, double y);
271 int move_abs_2(double x, double y);
272 int moveabs2(double x, double y);
273 int line_rel_2(double x, double y);
274 int linerel2(double x, double y);
275 int move_rel_2(double x, double y);
276 int moverel2(double x, double y);
277 int draw_text(char *message);
278 int drawtext(char *message);
279 int polylnabs2(double x[], double y[], int n);
280 int markabs2(double x, double y);
281 int markrel2(double x, double y);
282 int pntabs2(double x, double y);
283 int pntrel2(double x, double y);
285 int ctm_get_2(GRFMTX_2D m);
286 int ctm_set_2(GRFMTX_2D m);
287 int ctm_pre_mult_2(GRFMTX_2D m);
288 int ctm_post_mult_2(GRFMTX_2D m);
291 int initdevice(int dev, int mode, int xsize, int ysize);
292 int opendevice(int dev);
293 int closedevice(int dev);
294 int termdevice(int dev);
295 void stylus(double x, double y, int beam);
296 int pntndc(double x, double y);
297 int markndc(double x, double y);
298 GRFSTATE *inqstate(void);
299 int gp_set_aspect(int dev, double asp);
300 void setlinestyle(int style);
301 int setlinewidth(int wid);
302 DEVICE *inqdev(int dev);
303 int settext(double width, double height, double textangle, int font);
304 int settextclr(int fore, int back);
305 int setcolor(int fore);
306 int setbackg(int back);
307 int initmarker(int marker, int color);
308 int settextdir(int direction);
309 int charsize(double wid, double height);
310 int textangle(double angle);
311 int drivtext(char *message);
313 int flushdevice(int dev);
315 int wrtsymbol(int sym, int x, int y, DEVICE *dev);
316 int wrtchar(int ch, int x, int y, CHARSPEC *cspec, DEVICE *dev);
317 int wrttext(char txtstr[], int x, int y, CHARSPEC *cspec, DEVICE *dev);
318 void crtcolor(int mode, int *f, int *b);
320 int trackloc(int dev, int *xloc, int *yloc, int (*loc_on)(int x, int y), int (*loc_off)(int x, int y));