1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: sgp.h,v 1.2 2000/04/28 14:14:16 kevin Exp $
7 ** Revision 1.2 2000/04/28 14:14:16 kevin
8 ** *** empty log message ***
11 ** This program is free software; you can redistribute it and/or modify
12 ** it under the terms of the GNU General Public License (version 2) as
13 ** published by the Free Software Foundation.
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ** GNU General Public License for more details.
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program; if not, write to the Free Software
22 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 ******************************************************************************/
24 /*----------------------------------------------------------------------*/
25 /* Standard Graphics Package Header File */
26 /*----------------------------------------------------------------------*/
43 #define LS_SOLID 0xffff
44 #define LS_DASH1 0xff00
45 #define LS_DASH2 0xf0f0
46 #define LS_DASH3 0xcccc
47 #define LS_DASH4 0xff3e
48 #define LS_DOTTED 0xaaaa
56 int open; /* TRUE if device is open for output */
57 int xsize, ysize; /* Size of device in pixels */
58 int xmin, ymin; /* smallest coordinates */
59 int xmax, ymax; /* Maximum coordinates */
60 int colormax; /* Maximum color number of device */
61 int style; /* Current linestyle of device */
62 int width; /* Current width of device */
63 int color; /* Current color of device */
64 int icurx, icury; /* Current position */
65 int icwidth, icheight; /* Size of characters in pixels */
66 int cfore, cback; /* Character foregnd & backgnd colors */
67 float asp; /* Aspect ratio. Multipy x coord */
68 int (*dotfunc)(int x1, int y1, int color); /* Dot function for device */
69 int (*linefunc)(int x1, int y1, int x2, int y2, int color); /* Line function for device */
70 unsigned int nbytes; /* Size of buffer in bytes */
71 char *buf; /* Pointer to buffer */
72 unsigned int bufseg, bufoff; /* Buffer memory location */
73 int mode; /* Device mode */
77 float width, height; /* size of characters in NDC */
78 float textangle; /* text angle in radians */
79 float charupangle; /* character up angle */
80 int font; /* font for characters */
81 int updir, textdir; /* text direct & character orientation */
82 int fore, back; /* foreground & background color */
83 /* if back = -1, then transparent back */
87 int foregnd, backgnd; /* current foregound & background colors */
88 int linestyle; /* current 16 bit linestyle */
89 int linewidth; /* current width of line (in pixels) */
90 int marktype; /* current marker type */
91 int markcolor; /* current marker color */
92 float xndc, yndc; /* current position in NDC */
95 typedef struct device_st DEVICE;
96 typedef struct charsp_st CHARSPEC;
97 typedef struct state_st GRFSTATE;
99 struct point {double x, y, z;};
102 /******************************************************************
106 * Max R. Dursteler Dec 1983 *
107 * 12405 Village Square Terrace *
108 * Rockville Md. 20852 *
109 ******************************************************************
114 /* Flagcodes for motion directions */
115 #define XPLUS 001 /* right */
116 #define XMINUS 002 /* left */
117 #define YPLUS 004 /* up */
118 #define YMINUS 010 /* down */
120 /* Codes for marker symbols */
121 #define POINT 0 /* small dot */
122 #define SQUARE 1 /* empty square */
123 #define FSQUARE 2 /* filled square */
124 #define DIAMOND 3 /* empty diamond */
125 #define FDIAMOND 4 /* filled diamond */
126 #define CROSS 5 /* cross */
127 #define XCROSS 6 /* x */
128 #define CERCLE 7 /* open circle */
129 #define FCERCLE 8 /* filled circle */
130 #define BSQUARE 9 /* big open square */
131 #define BDIAMOND 10 /* big open diamond */
133 #define NMARKERS 11 /* Number of available symbol types */
135 /*-------------------------------------------------------------------------*/
137 #define PSET 0 /* codes for raster merging */
143 /*-------------------------------------------------------------------------*/
145 #define X_STKMIN 10 /* joystick specific values */
150 #define X_LOCMAX (X_STKMAX - X_STKMIN); /* range from readloc() */
151 #define Y_LOCMAX (Y_STKMAX - Y_STKMIN); /* = 0 to LOCMAX */
153 #define JOYSTK1 0 /* device names */
156 #define BUTT_DONE 2 /* Right joystick button to end a command */
157 #define BUTT_START 1 /* Left joystick button to start a command */
158 #define BUTT_BOTH 3 /* Both buttons pressed */
160 #define RL_ERROR -1 /* readloc() return codes */
164 /*-------------------------------------------------------------------------*/
172 typedef struct raster_st RASTER;
174 /*-------------------------------------------------------------------------*/
176 typedef double GRFMTX_2D[3][3];
177 typedef double GRFMTX_3D[4][4];
181 void circle(const double r);
182 void drawarc(double start, double stop, const double r);
184 int cliprect(double *x1, double *y1, double *x2, double *y2, const double rect[4]);
186 void crt_line(int x1, int y1, int x2, int y2, int color);
187 int prtline(int func, int x1, int y1, int x2, int y2, int arg1, int arg2);
188 void crt_line_style(int style);
190 void crt_wdot(int x, int y, int c);
191 void ega_wdot(int x, int y, int c);
192 void prtdot(int x, int y, int c);
194 void cpix_set(int x, int y, int c);
195 void cpix_init(void);
196 void cpix_set_wrt_mode(int mode);
197 void cpix_calc_addr(void);
198 void cpix_set_addr(int addr);
199 void cpix_inc_col(void);
200 int cpix_get_addr(void);
201 void cpix_term(void);
202 void cpix_setcolor(int c);
203 void cpix_set_at_addr(int addr, int c);
204 void cpix_inc_row(void);
205 void cpix_set_color(int c);
207 int ctm_xlat_pre_2(double x, double y);
208 int ctm_xlat_post_2(double x, double y);
209 int ctm_scale_pre_2(double sx, double sy);
210 int ctm_scale_post_2(double sx, double sy);
211 int ctm_rotate_pre_2(double theta);
212 int ctm_rotate_post_2(double theta);
213 int ctm_shear_pre_2(double shrx, double shry);
214 int ctm_shear_post_2(double shrx, double shry);
215 int xlat_gmtx_2(GRFMTX_2D m, double x, double y);
216 int scale_gmtx_2(GRFMTX_2D m, double sx, double sy);
217 int shear_gmtx_2(GRFMTX_2D m, double shrx, double shry);
218 int rotate_gmtx_2(GRFMTX_2D m, double theta);
219 int ident_gmtx_2(GRFMTX_2D m);
220 int mult_gmtx_2(GRFMTX_2D a, GRFMTX_2D b, GRFMTX_2D c);
221 int invert_gmtx_2(GRFMTX_2D a, GRFMTX_2D b);
222 double determ_gmtx_2(GRFMTX_2D a);
224 int drawbox(double xmin, double ymin, double xmax, double ymax);
226 int gptrace(int state);
227 int viewprt3(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax);
228 int window3(double xmin, double ymin, double xmax, double ymax);
229 int setproj(int pr, double x, double y, double z);
230 int setvrp(double x, double y, double z);
231 int setvpn(double x, double y, double z);
232 int setvup(double x, double y, double z);
233 int viewdepth(double front, double back);
234 int gpfrontclip(int on_off);
235 int gpbackclip(int on_off);
238 int calcrot(double rot[5][5]);
239 int calcpertrans(void);
240 int calcpartrans(void);
241 int matident(double mtx[5][5]);
242 int matmult(double premtx[5][5], double postmtx[5][5], double result[5][5]);
243 int crossprod(struct point *v, struct point *w, struct point *result);
244 int transform(double mtx[5][5], double *x, double *y, double *z);
245 int homotrans(double mtx[5][5], double *x, double *y, double *z, double *w);
246 int moveabs3(double x, double y, double z);
247 int moverel3(double xr, double yr, double zr);
248 int lineabs3(double x, double y, double z);
249 int linerel3(double xr, double yr, double zr);
250 int drawline(double xinput, double yinput, double zinput);
251 int mastertondc(double *x, double *y, double *z);
252 int checkchange(void);
255 int matwrite(double mtx[5][5]);
256 int pyr_edge(double x, double y, double z, int *pos);
257 int clippyramid(double *x1, double *y1, double *z1, double *x2, double *y2, double *z2, int *accept);
258 int cube_edge(double x, double y, double z, int *pos);
259 int clipcube(double *x1, double *y1, double *z1, double *x2, double *y2, double *z2, int *accept);
261 int pickbox(int dev, int *xmin, int *ymin, int *xmax, int *ymax, int xtab[], int ytab[]);
263 int pickloc(int dev, int *xloc, int *yloc, int xtab[], int ytab[]);
265 int readblock(char array[], int x1, int y1, int x2, int y2);
266 int writeblock(char array[], int x1, int y1, int mode);
267 char *allocblock(int x1, int y1, int x2, int y2);
269 int readloc(int dev, int *x, int *y);
270 int loc_to_ndc(int xloc, int yloc, float *xndc, float *yndc);
271 int readbutt(int dev);
274 int window2(double xmin, double ymin, double xmax, double ymax);
275 int window_2(double xmin, double ymin, double xmax, double ymax);
276 int viewprt2(double xmin, double ymin, double xmax, double ymax);
277 int viewport_2(double xmin, double ymin, double xmax, double ymax);
279 int calc_wc_to_ndc(void);
280 int calc_ndc_to_mc(void);
281 int wc_to_ndc(double xw, double yw, double *xn, double *yn);
282 int ndc_to_wc(double xn, double yn, double *xw, double *yw);
284 int linestyle(int style);
285 int line_abs_2(double x, double y);
286 int lineabs2(double x, double y);
287 int move_abs_2(double x, double y);
288 int moveabs2(double x, double y);
289 int line_rel_2(double x, double y);
290 int linerel2(double x, double y);
291 int move_rel_2(double x, double y);
292 int moverel2(double x, double y);
293 int draw_text(char *message);
294 int drawtext(char *message);
295 int polylnabs2(double x[], double y[], int n);
296 int markabs2(double x, double y);
297 int markrel2(double x, double y);
298 int pntabs2(double x, double y);
299 int pntrel2(double x, double y);
301 int ctm_get_2(GRFMTX_2D m);
302 int ctm_set_2(GRFMTX_2D m);
303 int ctm_pre_mult_2(GRFMTX_2D m);
304 int ctm_post_mult_2(GRFMTX_2D m);
307 int initdevice(int dev, int mode, int xsize, int ysize);
308 int opendevice(int dev);
309 int closedevice(int dev);
310 int termdevice(int dev);
311 void stylus(double x, double y, int beam);
312 int pntndc(double x, double y);
313 int markndc(double x, double y);
314 GRFSTATE *inqstate(void);
315 int gp_set_aspect(int dev, double asp);
316 void setlinestyle(int style);
317 int setlinewidth(int wid);
318 DEVICE *inqdev(int dev);
319 int settext(double width, double height, double textangle, int font);
320 int settextclr(int fore, int back);
321 int setcolor(int fore);
322 int setbackg(int back);
323 int initmarker(int marker, int color);
324 int settextdir(int direction);
325 int charsize(double wid, double height);
326 int textangle(double angle);
327 int drivtext(char *message);
329 int flushdevice(int dev);
331 int wrtsymbol(int sym, int x, int y, DEVICE *dev);
332 int wrtchar(int ch, int x, int y, CHARSPEC *cspec, DEVICE *dev);
333 int wrttext(char txtstr[], int x, int y, CHARSPEC *cspec, DEVICE *dev);
334 void crtcolor(int mode, int *f, int *b);
336 int trackloc(int dev, int *xloc, int *yloc, int (*loc_on)(int x, int y), int (*loc_off)(int x, int y));