1 /***********************************************************************
5 File Include OpenGl_telem_util :
12 HISTORIQUE DES MODIFICATIONS :
13 --------------------------------
14 xx-xx-xx : xxx ; Creation.
15 22-04-96 : FMN ; Ajout TelReadImage TelDrawImage
16 23-12-96 : CAL ; Probleme dans la macro vecmag
17 12-02-97 : FMN ; Suppression TelEnquireFacilities()
18 07-10-97 : FMN ; Simplification WNT
19 23-12-97 : FMN ; Suppression TelBackInteriorStyle, TelBackInteriorStyleIndex
21 ************************************************************************/
23 #ifndef OPENGL_TELEM_UTIL_H
24 #define OPENGL_TELEM_UTIL_H
27 #define IMP190100 /*GG To avoid too many REDRAW in immediat mode,
28 // Add TelMakeFrontAndBackBufCurrent() function
32 #define BUC60823 /* GG 05/03/01 Avoid to crash in normal computation
33 // between confused points
41 #include <OpenGl_telem.hxx>
44 * ShortRealLast () = 3.40282346638528860e+38
45 * ShortRealFirst () = 3.40282346638528860e+38
47 #define shortreallast() (3.e+38)
48 #define shortrealfirst() (-3.e+38)
50 /* vector manipulation macros */
51 #define square(a) ((a)*(a))
54 #define vecadd(a,b,c) { (a)[0]=(b)[0]+(c)[0]; \
55 (a)[1]=(b)[1]+(c)[1]; \
56 (a)[2]=(b)[2]+(c)[2]; }
59 #define vecsub(a,b,c) { (a)[0]=(b)[0]-(c)[0]; \
60 (a)[1]=(b)[1]-(c)[1]; \
61 (a)[2]=(b)[2]-(c)[2]; }
64 #define vecdot(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])
67 #define veccrs(a,b,c) { Tfloat x, y, z; \
68 x = (b)[1]*(c)[2] - (b)[2]*(c)[1]; \
69 y = (b)[2]*(c)[0] - (b)[0]*(c)[2]; \
70 z = (b)[0]*(c)[1] - (b)[1]*(c)[0]; \
75 #define vecscl(a,b) { (b)[0] *= (a); (b)[1] *= (a); (b)[2] *= (a); }
77 /* magnitude square */
78 #define vecmg2(a) (square((a)[0])+square((a)[1])+square((a)[2]))
81 #define vecmag(a) (sqrt((double)vecmg2(a)))
85 #define vecnrmd(a,d) ( d = (Tfloat)vecmag(a), \
86 ( d > 1e-10 ? (a[0] /= d, a[1] /= d, a[2] /= d, d) : (Tfloat)0. ) )
87 #define vecnrm(a) { Tfloat d; vecnrmd(a,d); }
89 #define vecnrm(a) { Tfloat d; d = ( Tfloat )vecmag(a); \
90 (a)[0] /= d; (a)[1] /= d; (a)[2] /= d; }
93 /* angle between two vectors */
94 #define vecang(a,b,d) { d = (Tfloat)(vecmag(a)*vecmag(b)); \
96 d = d < -1.0F ? -1.0F : d > 1.0F ? 1.0F : d; \
97 d = ( Tfloat )acos(d); }
99 /* point along a vector at a distance */
100 #define vecgnd(a,b,c,d) { Tfloat w; w = d/vecmag(c); \
101 (a)[0] = (b)[0]+(c)[0]*w; \
102 (a)[1] = (b)[1]+(c)[1]*w; \
103 (a)[2] = (b)[2]+(c)[2]*w; }
105 #define veccpy(a,b) ((a)[0]=(b)[0],(a)[1]=(b)[1],(a)[2]=(b)[2])
107 /* end vector macros */
115 #define matcpy(d,s) { *((Tmatrix3Struct*)(d)) = *((Tmatrix3Struct*)(s)); }
117 (d)[0][0]=(s)[0][0],(d)[0][1]=(s)[0][1],(d)[0][2]=(s)[0][2],(d)[0][3]=(s)[0][3],
118 (d)[1][0]=(s)[1][0],(d)[1][1]=(s)[1][1],(d)[1][2]=(s)[1][2],(d)[1][3]=(s)[1][3],
119 (d)[2][0]=(s)[2][0],(d)[2][1]=(s)[2][1],(d)[2][2]=(s)[2][2],(d)[2][3]=(s)[2][3],
120 (d)[3][0]=(s)[3][0],(d)[3][1]=(s)[3][1],(d)[3][2]=(s)[3][2],(d)[3][3]=(s)[3][3]
123 #define matdump(m) { \
125 for (i=0; i<4; i++) {\
127 for (j=0; j<4; j++) \
128 printf ("%f ", m[i][j]); \
133 extern Tint TelRemdupnames( Tint*, Tint ); /* list, num */
135 extern int TelGetPolygonNormal( tel_point, Tint*, Tint, Tfloat* );
136 extern int TelGetNormal( Tfloat*, Tfloat*, Tfloat*, Tfloat* );
138 extern void TelGetNormal( Tfloat*, Tfloat*, Tfloat*, Tfloat* );
140 /* point1, point2, point3, normal */
141 extern Tint TelIsBackFace( Tmatrix3, Tfloat* ); /* normal */
142 extern Tint TelIsBackFacePerspective( Tmatrix3, Tfloat*, Tfloat*, Tfloat* );
143 /* matrix, point 1, point 2, point 3 */
144 extern void TelMultiplymat3( Tmatrix3, Tmatrix3, Tmatrix3 );
145 /* mat out, mat in, mat in */
146 extern void TelTransposemat3( Tmatrix3 ); /* mat in out */
147 extern void TelTranpt3( Tfloat [4], Tfloat [4], Tmatrix3 ); /* out, in, mat */
149 extern void TelInitWS( Tint, Tint, Tint, Tfloat, Tfloat, Tfloat );
150 /* ws, width, height, bgcolr, bgcolg, bgcolb */
151 extern void TelSwapBuffers( Tint );
152 extern void TelCopyBuffers( Tint, GLenum, GLenum,
153 Tfloat, Tfloat, Tfloat, Tfloat, Tfloat, Tfloat, Tint );
154 extern TStatus TelProjectionRaster( Tint ws, Tfloat x, Tfloat y, Tfloat z,
155 Tfloat *xr, Tfloat *yr);
156 extern TStatus TelUnProjectionRaster( Tint ws, Tint xr, Tint yr,
157 Tfloat *x, Tfloat *y, Tfloat *z);
159 TelUnProjectionRasterWithRay(Tint ws, Tint xr, Tint yr, Tfloat *x, Tfloat *y, Tfloat *z,
160 Tfloat *dx, Tfloat *dy, Tfloat *dz);
161 extern Tint TelBackBufferRestored(void);
162 extern void TelSetBackBufferRestored( Tint );
163 extern void TelEnable( Tint );
164 extern void TelDisable( Tint );
165 extern void TelFlush( Tint );
167 extern void TelSetFrontFaceAttri(
168 Tint, /* interior_style */
169 Tint, /* back_interior_style */
170 Tint, /* interior_index */
171 Tint, /* back_interior_index */
172 Tint, /* front_shading_method */
173 Tint, /* back_shading_method */
174 Tint, /* front_lighting_model */
175 Tint, /* back_lighting_model */
176 tel_surf_prop, /* surf_prop */
177 tel_surf_prop, /* back_surf_prop */
178 tel_colour, /* interior_colour */
179 tel_colour /* back_interior_colour */
181 extern void TelSetBackFaceAttri(
182 Tint, /* interior_style */
183 Tint, /* back_interior_style */
184 Tint, /* interior_index */
185 Tint, /* back_interior_index */
186 Tint, /* front_shading_method */
187 Tint, /* back_shading_method */
188 Tint, /* front_lighting_model */
189 Tint, /* back_lighting_model */
190 tel_surf_prop, /* surf_prop */
191 tel_surf_prop, /* back_surf_prop */
192 tel_colour, /* interior_colour */
193 tel_colour /* back_interior_colour */
196 extern void TelReadImage(Tint , GLenum , Tint , Tint , Tint , Tint , unsigned int *);
197 extern void TelDrawImage(Tint , GLenum , Tint , Tint , Tint , Tint , unsigned int *);
198 extern void TelReadDepths(Tint , Tint , Tint , Tint , Tint , float *);
200 extern void TelMakeFrontBufCurrent(Tint );
201 extern void TelMakeBackBufCurrent(Tint );
203 extern void TelMakeFrontAndBackBufCurrent(Tint );
207 extern void TelSetPixmapDBParams(Display *dpy,
209 int width, int height, int depth, GC gc,
213 extern GLXPixmap TelGetGLXPixmap(void);
214 extern void TelSetPixmapDB(int flag);
215 extern int TelTestPixmapDB(void);
216 extern void TelDrawBuffer(GLenum buf);