1 /* Copyright (C) 1992-1998 The Geometry Center
2  * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
3  *
4  * This file is part of Geomview.
5  *
6  * Geomview is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published
8  * by the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * Geomview is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Geomview; see the file COPYING.  If not, write
18  * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19  * USA, or visit http://www.gnu.org.
20  */
21 #ifndef MGPSP_H
22 #define MGPSP_H
23 
24 typedef struct {
25 	Pt3Coord	x, y, z, w;
26         ColorA		vcol;
27 	int		drawnext;
28 	} CPoint3;
29 
30 /*****************************************************************************/
31 
32 #define		MGX_NULL		0
33 #define		MGX_END			0
34 #define		MGX_BGNLINE		1
35 #define		MGX_BGNPOLY		2
36 #define		MGX_BGNEPOLY		3
37 #define		MGX_BGNSLINE		4
38 #define		MGX_BGNSPOLY		5
39 #define		MGX_BGNSEPOLY		6
40 #define		MGX_VERTEX		7
41 #define		MGX_CVERTEX		8
42 #define		MGX_COLOR		9
43 #define		MGX_ECOLOR		10
44 
45 #define		PRIM_LINE		1
46 #define		PRIM_POLYGON		2
47 #define		PRIM_EPOLYGON		3
48 #define		PRIM_SLINE		4 /* smooth shaded primitives */
49 #define		PRIM_SPOLYGON		5
50 #define		PRIM_SEPOLYGON		6
51 #define		PRIM_INVIS		7
52 
53 /*****************************************************************************/
54 
55 typedef struct _mgpsprim {
56   int                   mykind; /* kind of primitive */
57   int                   index;  /* index into array of vertices */
58   int                   numvts; /* number of vertices */
59   float                 depth;  /* z value for sorting (at least for now) */
60   int                   color[3]; /* rgb color of polygon */
61   int                   ecolor[3]; /* edge color of polygon */
62   int                   ewidth; /* edge width */
63 } mgpsprim;
64 
65 /*****************************************************************************/
66 
67 typedef struct _mgps_sort
68 {
69   vvec 		 primsort;	/* pointers to mgx11prim array elements*/
70   vvec		 prims;		/* array of mgx11prim structures */
71   int            primnum;	/* number of primitives */
72   int		 cprim;		/* current primitive being stored */
73 
74   vvec		 pverts;	/* array of vertices */
75   int            pvertnum;
76   int		 cvert;		/* current vertex being stored */
77   int		 maxverts;	/* maximum number of vertices */
78 
79 } mgps_sort;
80 
81 /*****************************************************************************/
82 
83 typedef struct mgpscontext {
84     struct mgcontext mgctx;	/* The mgcontext */
85     FILE *file;
86     char filepath[280];
87     unsigned char *buf;
88     float *zbuf;
89     int xsize, ysize;
90     float zrange;
91     int znudge;			/* znudge for drawing lines closer */
92     float znudgeby;		/* how much of a nudge ? */
93     long znear, zfar;		/* Current Z-buffer limits */
94     vvec room;			/* Scratch space */
95 #if 0
96     int  pvertnum;		/* number of vertices */
97     vvec pverts;		/* Primitve vertices */
98 #endif
99     mgps_sort *mysort;          /* sorting structure */
100     int	sizelock;		/* for prohibiting size change from within mg
101 				   when the cam window is part of a larger
102 				   hierarchy of windows as with Widgets */
103     int born;
104 } mgpscontext;
105 
106 #define MAXZNUDGE	8	/* Max depth of mgbuf_closer()/farther() */
107 
108 #define _mgpsc		((mgpscontext*)_mgc)
109 
110 extern void mgps_add(int primtype, int ndata, void *data, void *cdata);
111 
112 extern void mgps_init_zrange();
113 extern int mgps_primclip(mgpsprim *aprim);
114 
115 #endif
116 
117