7fd59977 |
1 | /*********************************************************************** |
2 | |
3 | FONCTION : |
4 | ---------- |
5 | file OpenGl_undefined : |
6 | |
7 | |
8 | REMARQUES: |
9 | ---------- |
10 | |
11 | |
12 | HISTORIQUE DES MODIFICATIONS : |
13 | -------------------------------- |
14 | xx-xx-xx : xxx ; Creation. |
15 | 20-02-96 : FMN ; Suppression code inutile: |
16 | 01-04-96 : CAL ; Integration MINSK portage WNT |
17 | 22-04-96 : FMN ; Suppression prototype inutile. |
18 | 25-06-96 : FMN ; Suppression utilisation de glScissor. |
19 | 02-07-96 : FMN ; Modification parametre glViewport. |
20 | 21-10-96 : FMN ; Suppression LMC_COLOR fait dans OpenGl_execstruct.c |
21 | 04-02-97 : FMN ; Suppression call_togl_ps, call_togl_xwd ... |
22 | 02-04-97 : FMN ; Correction call_tox_rect, on repasse en GL_BACK a la fin.call_tox_rect |
23 | 05-01-98 : FMN ; Suppression WNT inutile |
24 | Suppression call_tox_set_colormap_mapping() |
25 | |
26 | ************************************************************************/ |
27 | |
28 | /*----------------------------------------------------------------------*/ |
29 | /* |
30 | * Includes |
31 | */ |
32 | |
33 | #include <string.h> |
34 | #include <stdio.h> |
35 | |
36 | #include <OpenGl_tgl_all.hxx> |
37 | |
38 | #include <GL/gl.h> |
39 | #ifndef WNT |
40 | # include <GL/glx.h> |
41 | #else |
42 | # include <InterfaceGraphic_WNT.hxx> |
43 | #endif /* WNT */ |
44 | |
45 | #include <InterfaceGraphic_Aspect.hxx> |
46 | #include <InterfaceGraphic_Graphic3d.hxx> |
47 | #include <InterfaceGraphic_Visual3d.hxx> |
48 | |
49 | #include <OpenGl_txgl.hxx> |
50 | #include <OpenGl_tgl_tox.hxx> |
51 | #include <OpenGl_tsm.hxx> |
52 | #include <OpenGl_tsm_ws.hxx> |
53 | #include <OpenGl_telem_view.hxx> |
54 | #include <OpenGl_telem_util.hxx> |
55 | #include <OpenGl_telem_inquire.hxx> |
56 | #include <OpenGl_tgl_elems.hxx> |
57 | #include <OpenGl_tgl_funcs.hxx> |
58 | |
59 | /*static GLboolean lighting_mode;*/ |
60 | extern DISPLAY *call_thedisplay; |
61 | #ifndef WNT |
62 | /*static GC gcx;*/ |
63 | #endif /* WNT */ |
64 | /*static int ft=1;*/ |
65 | |
66 | /*----------------------------------------------------------------------*/ |
67 | /* |
68 | * Constantes |
69 | */ |
70 | |
71 | #define XTRACE |
72 | |
73 | #define CALL_DEF_BUFFER_SIZE 1024 |
74 | #define CALL_DEF_STRING_LENGTH 132 |
75 | |
76 | /*----------------------------------------------------------------------*/ |
77 | EXPORT void call_togl_build_matrix ( |
78 | CALL_DEF_VIEW * aview, |
79 | CALL_DEF_MATRIX4X4 gl_ori_matrix, CALL_DEF_MATRIX4X4 gl_map_matrix, |
80 | CALL_DEF_MATRIX4X4 eval_ori_matrix, CALL_DEF_MATRIX4X4 eval_map_matrix ) |
81 | { |
82 | int i, j; |
83 | for (i=0; i<3; i++) |
84 | for (j=0; j<3; j++) |
85 | if (i == j) { |
86 | gl_ori_matrix[i][j] = ( float )1.0; |
87 | gl_map_matrix[i][j] = ( float )1.0; |
88 | eval_ori_matrix[i][j] = ( float )1.0; |
89 | eval_map_matrix[i][j] = ( float )1.0; |
90 | } |
91 | else { |
92 | gl_ori_matrix[i][j] = ( float )0.0; |
93 | gl_map_matrix[i][j] = ( float )0.0; |
94 | eval_ori_matrix[i][j] = ( float )0.0; |
95 | eval_map_matrix[i][j] = ( float )0.0; |
96 | } |
97 | } |
98 | |
99 | /*----------------------------------------------------------------------*/ |
100 | EXPORT void call_togl_element_type ( |
101 | long Id, |
102 | long elem_num, |
103 | long *elem_type ) |
104 | { |
105 | #ifdef PHIGS_VERSION |
106 | Pint err_ind; /* OUT error indicator */ |
107 | Pint size; /* OUT element size */ |
108 | Pint type; /* OUT element type */ |
109 | Pint cur_index; /* OUT element pointer value */ |
110 | |
111 | type = 0; |
112 | call_func_open_struct (Id); |
113 | call_func_set_elem_ptr (elem_num); |
114 | call_func_inq_elem_ptr (&err_ind, &cur_index); |
115 | /* it is not the end */ |
116 | if ((elem_num==cur_index) && (! err_ind)) { |
117 | call_func_inq_cur_elem_type_size |
118 | (&err_ind, &type, &size); |
119 | if (err_ind) type = 0; |
120 | } |
121 | call_func_close_struct (); |
122 | |
123 | switch (type) |
124 | { |
125 | case CALL_PHIGS_ELEM_POLYLINE3 : |
126 | case CALL_PHIGS_ELEM_POLYLINE : |
127 | case CALL_PHIGS_ELEM_POLYLINE_SET3_DATA : |
128 | *elem_type = 1; |
129 | break; |
130 | |
131 | case CALL_PHIGS_ELEM_FILL_AREA3 : |
132 | case CALL_PHIGS_ELEM_FILL_AREA : |
133 | case CALL_PHIGS_ELEM_FILL_AREA_SET3 : |
134 | case CALL_PHIGS_ELEM_FILL_AREA_SET : |
135 | case CALL_PHIGS_ELEM_FILL_AREA_SET3_DATA : |
136 | case CALL_PHIGS_ELEM_SET_OF_FILL_AREA_SET3_DATA : |
137 | *elem_type = 2; |
138 | break; |
139 | |
140 | case CALL_PHIGS_ELEM_TRI_STRIP3_DATA : |
141 | *elem_type = 3; |
142 | break; |
143 | |
144 | case CALL_PHIGS_ELEM_QUAD_MESH3_DATA : |
145 | *elem_type = 4; |
146 | break; |
147 | |
148 | case CALL_PHIGS_ELEM_TEXT3 : |
149 | case CALL_PHIGS_ELEM_TEXT : |
150 | case CALL_PHIGS_ELEM_ANNO_TEXT_REL3 : |
151 | case CALL_PHIGS_ELEM_ANNO_TEXT_REL : |
152 | *elem_type = 5; |
153 | break; |
154 | |
155 | case CALL_PHIGS_ELEM_POLYMARKER3 : |
156 | case CALL_PHIGS_ELEM_POLYMARKER : |
157 | *elem_type = 6; |
158 | break; |
159 | |
160 | default : |
161 | *elem_type = 0; |
162 | break; |
163 | } |
164 | #endif |
165 | TelType type; |
166 | Tint cur_index; |
167 | Tint err_ind=0; |
168 | Tint size; |
169 | |
170 | type = TelNil; |
171 | |
172 | call_func_open_struct (Id); |
173 | call_func_set_elem_ptr (elem_num); |
174 | if( TsmGetCurElemPtr( &cur_index ) == TFailure ) |
175 | err_ind = 1; |
176 | /* it is not the end */ |
177 | if ((elem_num==cur_index) && (! err_ind)) |
178 | TelInqCurElemTypeSize( &type, &size ); |
179 | call_func_close_struct (); |
180 | |
181 | switch (type) |
182 | { |
183 | case CALL_PHIGS_ELEM_POLYLINE_SET3_DATA : |
184 | *elem_type = 1; |
185 | break; |
186 | |
187 | case CALL_PHIGS_ELEM_FILL_AREA3 : |
188 | case CALL_PHIGS_ELEM_FILL_AREA_SET3 : |
189 | *elem_type = 2; |
190 | break; |
191 | |
192 | case CALL_PHIGS_ELEM_TRI_STRIP3_DATA : |
193 | *elem_type = 3; |
194 | break; |
195 | |
196 | case CALL_PHIGS_ELEM_QUAD_MESH3_DATA : |
197 | *elem_type = 4; |
198 | break; |
199 | |
200 | case CALL_PHIGS_ELEM_ANNO_TEXT_REL3 : |
201 | |
202 | *elem_type = 5; |
203 | break; |
204 | |
205 | case CALL_PHIGS_ELEM_POLYMARKER3 : |
206 | *elem_type = 6; |
207 | break; |
208 | |
209 | default : |
210 | *elem_type = 0; |
211 | break; |
212 | } |
213 | *elem_type = 0; |
214 | } |
215 | |
216 | /*----------------------------------------------------------------------*/ |
217 | EXPORT int call_togl_inquiremat ( |
218 | CALL_DEF_VIEW * aview, |
219 | CALL_DEF_MATRIX4X4 ori_matrix, |
220 | CALL_DEF_MATRIX4X4 map_matrix ) |
221 | { |
222 | TEL_VIEW_REP rep; |
223 | int i, j, error; |
224 | view_map3 map; |
225 | |
226 | TelGetViewRepresentation( aview->WsId, aview->ViewId, &rep ); |
227 | if(aview->Orientation.IsCustomMatrix) { |
228 | /* OCC18942: Trying to return the current matrices instead of calculating them anew. |
229 | This in particular allows using application-defined matrices. */ |
230 | } else { |
231 | memcpy( &map.win, &rep.extra.map.window, sizeof( Tlimit ) ); |
232 | memcpy( &map.proj_vp, &rep.extra.map.viewport, sizeof( Tlimit3 ) ); |
233 | switch(rep.extra.map.proj){ |
234 | default: |
235 | case TelParallel : map.proj_type = TYPE_PARAL; break; |
236 | case TelPerspective : map.proj_type = TYPE_PERSPECT; break; |
237 | } |
238 | map.proj_ref_point.x = rep.extra.map.prp[0]; |
239 | map.proj_ref_point.y = rep.extra.map.prp[1]; |
240 | map.proj_ref_point.z = rep.extra.map.prp[2]; |
241 | map.view_plane = rep.extra.map.vpd; |
242 | map.back_plane = rep.extra.map.bpd; |
243 | map.front_plane = rep.extra.map.fpd; |
244 | |
245 | call_func_eval_ori_matrix3( (point3 *)rep.extra.vrp, |
246 | (vec3 *)rep.extra.vpn, |
247 | (vec3 *)rep.extra.vup, |
248 | &error, rep.orientation_matrix ); |
249 | if( error ) |
250 | return 1; |
251 | |
252 | call_func_eval_map_matrix3( &map, &error, rep.mapping_matrix ); |
253 | |
254 | if( error ) |
255 | return 1; |
256 | } |
257 | for( i = 0; i < 4; i++ ) |
258 | for( j = 0; j < 4; j++ ) |
259 | { |
260 | ori_matrix[i][j] = rep.orientation_matrix[j][i]; |
261 | map_matrix[i][j] = rep.mapping_matrix[j][i]; |
262 | } |
263 | |
264 | return 0; |
265 | } |
266 | |
267 | /*----------------------------------------------------------------------*/ |
268 | int call_tox_window_exists ( WINDOW w ) |
269 | { |
270 | return (1); |
271 | } |
272 | |
273 | /*----------------------------------------------------------------------*/ |
274 | extern void |
275 | call_tox_rect( int wsid, WINDOW win, int u, int v ) |
276 | { |
277 | #define STEP 2.0 |
278 | Tint w, h; |
279 | CMN_KEY_DATA k; |
280 | float p[3]; |
281 | float r[3] = { ( float )0.0, ( float )1.0, ( float )1.0 }; |
282 | |
283 | TsmGetWSAttri( wsid, WSWidth, &k ); |
284 | w = k.ldata; |
285 | TsmGetWSAttri( wsid, WSHeight, &k ); |
286 | h = k.ldata; |
287 | |
288 | TxglWinset( call_thedisplay, win ); |
289 | glViewport( 0, 0, w, h); |
290 | glMatrixMode( GL_MODELVIEW ); |
291 | glLoadIdentity(); |
292 | glMatrixMode(GL_PROJECTION); |
293 | glLoadIdentity(); |
294 | glOrtho( 0.0, ( GLdouble ) w, 0.0, ( GLdouble ) h, -100000.0, 100000.0 ); |
295 | |
296 | p[0] = ( float )(u-STEP); |
297 | p[1] = ( float )(v-STEP); |
298 | p[2] = ( float )(-9999.0); |
299 | glDrawBuffer(GL_FRONT) ; |
300 | glColor3fv( r ); |
301 | glBegin(GL_QUADS); |
302 | glVertex3fv( p ); |
303 | p[0] = ( float )(u+STEP); |
304 | glVertex3fv( p ); |
305 | p[1] = ( float )(v+STEP); |
306 | glVertex3fv( p ); |
307 | p[0] = ( float )(u-STEP); |
308 | glVertex3fv( p ); |
309 | glEnd(); |
310 | |
311 | TelFlush(0); |
312 | |
313 | glDrawBuffer(GL_BACK) ; |
314 | } |
315 | |
316 | /*----------------------------------------------------------------------*/ |
317 | |
318 | #if !defined(GLU_VERSION_1_2) |
319 | void gluTessBeginContour() { |
320 | printf(" UNIMPLEMENTED function gluTessBeginContour()\n"); |
321 | } |
322 | void gluTessBeginPolygon() { |
323 | printf(" UNIMPLEMENTED function gluTessBeginPolygon()\n"); |
324 | } |
325 | void gluTessEndPolygon() { |
326 | printf(" UNIMPLEMENTED function gluTessEndPolygon()\n"); |
327 | } |
328 | void gluTessEndContour() { |
329 | printf(" UNIMPLEMENTED function gluTessEndContour()\n"); |
330 | } |
331 | #endif |
332 | |
333 | /*----------------------------------------------------------------------*/ |