7fd59977 |
1 | /*********************************************************************** |
2 | |
3 | FONCTION : |
4 | ---------- |
5 | File OpenGl_subrvis : |
6 | |
7 | TEST : |
8 | ------ |
9 | |
10 | Le main TestOfDesktop.c permet de tester cette classe. |
11 | |
12 | |
13 | REMARQUES: |
14 | ---------- |
15 | |
16 | |
17 | HISTORIQUE DES MODIFICATIONS : |
18 | -------------------------------- |
19 | xx-xx-xx : xxx ; Creation. |
20 | 07-02-96 : FMN ; Suppression code inutile: |
21 | - TxglLink() et TxglUnlink() |
22 | 19-03-96 : CAL ; Ajout de la fonction subr_resize. |
23 | appele par togl_ratio_window |
24 | 21-03-96 : CAL ; Dans subr_doublebuffer et subr_open_ws |
25 | retrait des lignes qui donnaient un background |
26 | noir a la fenetre. |
27 | 01-04-96 : CAL ; Integration MINSK portage WNT |
28 | 02-07-96 : FMN ; Suppression WSWSHeight, WSWSWidth et WSType |
29 | 17-07-96 : FMN ; Modification de call_subr_hlhsr(). |
30 | 18-07-96 : FMN ; Ajout appel TxglWinset() pour le Resize. |
31 | 01-08-96 : FMN ; Ajout appel reaffichage dans le resize. |
32 | 25-11-96 : FMN ; PRO6577: Ajout WSUpdateState pour call_subr_set_background. |
33 | 29-01-97 : FMN ; Suppression de call_subr_doublebuffer(). |
34 | 05-02-97 : FMN ; Suppression variables inutiles. |
35 | 12-02-97 : FMN ; Suppression de call_facilities_list.DepthCueing |
36 | 14-02-97 : FMN ; Ajout WSUpdateState pour call_subr_transparency. |
37 | 30-06-97 : FMN ; Appel de la toolkit OpenGl_LightBox. |
38 | 02-07-97 : FMN ; Ajout init generale par contexte. |
39 | (GL_POLYGON_OFFSET_EXT, glLightModelf, glHint). |
40 | 03-07-97 : FMN ; Test Headlight. |
41 | 08-09-97 : CAL ; subr_open_ws retourne 0 si pb. (gere par togl_view) |
42 | 07-10-97 : FMN ; Simplification WNT |
43 | 03-10-97 : FMN ; Meilleure gestion des EXT, ajout QueryExtension |
44 | 17-11-97 : FMN ; Suppression redraw sur le resize. |
45 | 05-12-97 : FMN ; Double gestion du glPolygonOffsetEXT |
46 | 17-12-97 : FMN ; Probleme compilation SGI |
47 | 03-03-98 : FMN ; Simplification gestion du glPolygonOffsetEXT |
48 | 15-03-98 : FMN ; Suppression variable WSNeedsClear |
49 | 17-03-98 : FMN ; Ajout mode animation |
50 | 08-07-98 : FMN ; Changement du nom de la primitive call_togl_erase_immediat_mode() |
51 | -> call_togl_erase_animation_mode. |
52 | 22-10-98 : FMN ; Amelioration des perfs: glHint utilise GL_FASTEST. |
53 | 14-12-98 : BGN; Developpement (S3989, Phase "triedre") |
54 | 29-03-01 : GG; glPolygonOffsetEXT is no more available |
55 | since OGL 1.2 |
56 | 20-08-01 : GG ; Add functions call_subr_enable_polygon_offset () |
57 | and call_subr_disable_polygon_offset () |
58 | |
59 | ************************************************************************/ |
60 | |
61 | #ifdef WNT |
62 | #define BUC60579 /*GG_240999 Under WNT,resets the ws attributes for each |
63 | // created view-manager and not only for the first |
64 | */ |
65 | #endif |
66 | |
67 | #define IMP190100 /*GG Reverse the front & back depth cueing planes |
68 | // position. |
69 | */ |
70 | |
71 | #define RIC120302 /*GG Use TxglSetWindow instead TxglCreateWindow |
72 | // when a GLXContext is given |
73 | // Add call_subr_displayCB function |
74 | */ |
75 | |
76 | #define BUC61044 /* 25/10/01 SAV ; added functionality to control gl depth testing |
77 | from higher API */ |
78 | #define BUC61045 /* 25/10/01 SAV ; added functionality to control gl lighting |
79 | from higher API */ |
80 | |
81 | #define OCC1188 /*SAV added control of the background image*/ |
82 | |
83 | /*----------------------------------------------------------------------*/ |
84 | /* |
85 | * Includes |
86 | */ |
87 | |
88 | #include <stdio.h> |
89 | |
90 | #include <OpenGl_tgl_all.hxx> |
91 | |
92 | |
93 | #include <InterfaceGraphic.hxx> |
94 | #include <InterfaceGraphic_Labels.hxx> |
95 | #include <InterfaceGraphic_Graphic3d.hxx> |
96 | #include <InterfaceGraphic_Visual3d.hxx> |
97 | |
98 | #include <OpenGl_inquire.hxx> |
99 | |
100 | #include <OpenGl_Extension.hxx> |
101 | |
102 | #include <OpenGl_cmn_varargs.hxx> |
103 | #include <OpenGl_tsm.hxx> |
104 | #include <OpenGl_tsm_ws.hxx> |
105 | #include <OpenGl_telem_view.hxx> |
106 | #include <OpenGl_telem_util.hxx> |
107 | #include <OpenGl_telem_pick.hxx> |
108 | #include <OpenGl_LightBox.hxx> |
109 | #include <OpenGl_telem_highlight.hxx> |
110 | #include <OpenGl_telem_depthcue.hxx> |
111 | #include <OpenGl_txgl.hxx> |
112 | #include <OpenGl_tgl_subrvis.hxx> |
113 | #include <OpenGl_tgl_pick.hxx> |
114 | #include <OpenGl_tgl_funcs.hxx> |
115 | #include <OpenGl_telem_filters.hxx> |
116 | #include <OpenGl_tgl_tox.hxx> |
117 | #include <OpenGl_tgl.hxx> |
118 | #include <OpenGl_animation.hxx> |
119 | #include <OpenGl_triedron.hxx> |
120 | #include <OpenGl_tgl_util.hxx> |
121 | #include <OpenGl_Memory.hxx> |
122 | #include <OpenGl_graduatedtrihedron.hxx> |
123 | |
124 | /*----------------------------------------------------------------------*/ |
125 | /* |
126 | * Constantes |
127 | */ |
128 | |
129 | static Tint attri_init = 0; |
130 | |
131 | /*----------------------------------------------------------------------*/ |
132 | |
133 | #ifndef WNT |
134 | static Bool WaitForNotify(Display *d, XEvent *e, char *arg) { |
135 | return (e->type == MapNotify) && (e->xmap.window == (Window)arg); |
136 | } |
137 | #endif |
138 | |
139 | /*----------------------------------------------------------------------*/ |
140 | |
141 | static int offsetStatus=0; |
142 | #ifdef GL_EXT_polygon_offset |
143 | static GLfloat offsetFactor=1.0,offsetUnits=0.0; |
144 | #elif GL_POLYGON_OFFSET_EXT |
145 | static GLfloat offsetFactor=0.5,offsetUnits=0.0005; |
146 | #endif |
147 | void call_subr_enable_polygon_offset( ) |
148 | { |
149 | if( offsetStatus < 0 ) return; |
150 | |
151 | #ifdef GL_EXT_polygon_offset |
152 | if( offsetStatus == 0 ) { |
153 | if (QueryExtension("GL_EXT_polygon_offset")) { |
154 | char svalue[64]; |
155 | if( call_util_osd_getenv ("CALL_OPENGL_POLYGON_OFFSET", |
156 | svalue,sizeof(svalue)) ) { |
157 | float v1,v2; |
158 | int n = sscanf(svalue,"%f %f",&v1,&v2); |
159 | if( n > 0 ) offsetFactor = v1; |
160 | if( n > 1 ) offsetUnits = v2; |
161 | printf(" $$$ CALL_OPENGL_POLYGON_OFFSET %f %f\n", |
162 | offsetFactor,offsetUnits); |
163 | } |
164 | offsetStatus = 1; |
165 | } else { |
166 | offsetStatus = -1; |
167 | } |
168 | } |
169 | |
170 | if( offsetStatus > 0 ) { |
171 | #ifdef GL_POLYGON_OFFSET_FILL |
172 | glPolygonOffset(offsetFactor,offsetUnits); |
173 | glEnable(GL_POLYGON_OFFSET_FILL); |
174 | #elif GL_POLYGON_OFFSET_EXT |
175 | glPolygonOffsetEXT(offsetFactor,offsetUnits); |
176 | glEnable(GL_POLYGON_OFFSET_EXT); |
177 | #endif |
178 | } |
179 | #else |
180 | offsetStatus = -1; |
181 | #endif /* GL_EXT_polygon_offset */ |
182 | } |
183 | |
184 | void |
185 | call_subr_disable_polygon_offset( ) |
186 | { |
187 | if( offsetStatus > 0 ) { |
188 | #ifdef GL_POLYGON_OFFSET_FILL |
189 | glDisable(GL_POLYGON_OFFSET_FILL); |
190 | #elif GL_POLYGON_OFFSET_EXT |
191 | glDisable(GL_POLYGON_OFFSET_EXT); |
192 | #endif |
193 | } |
194 | } |
195 | |
196 | /*----------------------------------------------------------------------*/ |
197 | |
198 | int |
199 | call_subr_open_ws( CALL_DEF_VIEW * aview ) |
200 | { |
201 | CMN_KEY_DATA data; |
202 | WINDOW win; |
203 | TEL_HIGHLIGHT hrep = { TelHLForcedColour, {{ ( float )1.0, ( float )1.0, ( float )1.0 }} }; |
204 | TEL_DEPTHCUE dcrep = { TelDCSuppressed, {( float )0.0, ( float )1.0}, {( float )1.0, ( float )0.0}, {{( float )0.0, ( float )0.0, ( float )0.0}} }; |
205 | Tint width, height; |
206 | Tfloat bgcolr, bgcolg, bgcolb; /* background color */ |
207 | #ifdef OCC1188 |
208 | TSM_BG_TEXTURE bgTexture; |
209 | #endif |
210 | |
211 | #ifndef WNT |
212 | XEvent event; |
213 | Window root; |
214 | int newx, newy; |
215 | unsigned int newwidth, newheight, newbw, newdepth; |
216 | #else |
217 | RECT cr; |
218 | #endif /* WNT */ |
219 | |
220 | width = ( Tint )aview->DefWindow.dx; |
221 | height = ( Tint )aview->DefWindow.dy; |
222 | |
223 | /* background color */ |
224 | bgcolr = aview->DefWindow.Background.r, |
225 | bgcolg = aview->DefWindow.Background.g, |
226 | bgcolb = aview->DefWindow.Background.b; |
227 | |
228 | #ifdef RIC120302 |
229 | if( aview->GContext ) |
230 | win = TxglSetWindow( call_thedisplay, /*(HWND)*/(WINDOW)aview->DefWindow.XWindow, |
231 | /*(HGLRC)*/(GLCONTEXT)aview->GContext ); |
232 | else |
233 | #endif /*RIC120302*/ |
234 | win = TxglCreateWindow( call_thedisplay, /*(HWND)*/(WINDOW)aview->DefWindow.XWindow, |
235 | 0, 0, width, height, 0, bgcolr, bgcolg, bgcolb ); |
236 | #ifndef WNT |
237 | if( win != aview->DefWindow.XWindow ) { |
238 | XMapWindow( call_thedisplay, win ); |
239 | XIfEvent(call_thedisplay, &event, WaitForNotify, (char *) win); |
240 | } |
241 | #endif /* WNT */ |
242 | |
243 | if( TxglWinset( call_thedisplay, (WINDOW) win ) == TFailure ) |
244 | return 0; |
245 | else { |
246 | TsmRegisterWsid( aview->WsId ); |
247 | data.ldata = (Tint) win; |
248 | TsmSetWSAttri( aview->WsId, WSWindow, &data ); |
249 | #ifndef WNT |
250 | XGetGeometry ( |
251 | call_thedisplay, win, &root, |
252 | &newx, &newy,&newwidth, &newheight, &newbw, &newdepth |
253 | ); |
254 | width = newwidth; |
255 | height = newheight; |
256 | #else |
257 | GetClientRect ( win, &cr ); |
258 | width = cr.right; |
259 | height = cr.bottom; |
260 | #endif /* WNT */ |
261 | #ifdef OCC1188 |
262 | bgTexture.texId = 0; |
263 | data.pdata = &bgTexture; |
264 | TsmSetWSAttri( aview->WsId, WSBgTexture, &data ); |
265 | #endif |
266 | data.ldata = width; |
267 | TsmSetWSAttri( aview->WsId, WSWidth, &data ); |
268 | data.ldata = height; |
269 | TsmSetWSAttri( aview->WsId, WSHeight, &data ); |
270 | data.ldata = -1; |
271 | TsmSetWSAttri( aview->WsId, WSViewStid, &data ); |
272 | data.ldata = TOn; |
273 | TsmSetWSAttri( aview->WsId, WSDbuff, &data ); |
274 | data.ldata = TNotDone; |
275 | TsmSetWSAttri( aview->WsId, WSUpdateState, &data ); |
276 | data.ldata = TOff; |
277 | TsmSetWSAttri( aview->WsId, WSTransparency, &data ); |
278 | TelSetHighlightRep( aview->WsId, 0, &hrep ); |
279 | TelSetDepthCueRep( aview->WsId, 0, &dcrep ); |
280 | TelInitWS( aview->WsId, width, height, bgcolr, bgcolg, bgcolb ); |
281 | |
282 | #ifdef BUC61044 |
283 | /* 24/10/01 : SAV ; setting OGL depth testing enabled by default */ |
284 | data.ldata = TOn; |
285 | TsmSetWSAttri( aview->WsId, WSDepthTest, &data ); |
286 | #endif |
287 | #ifdef BUC61045 |
288 | /* 24/10/01 : SAV ; setting flag to control GL_LIGHTING (used in triedron) */ |
289 | data.ldata = TOn; |
290 | TsmSetWSAttri( aview->WsId, WSGLLight, &data ); |
291 | #endif |
292 | |
293 | #ifdef BUC60579 |
294 | TsmInitAttributes(); |
295 | #else |
296 | if( !attri_init ) { |
297 | TsmInitAttributes(); |
298 | attri_init = 1; |
299 | } |
300 | #endif |
301 | |
302 | /* |
303 | * Init generale du contexte |
304 | */ |
305 | |
306 | /* Eviter d'avoir les faces mal orientees en noir. */ |
307 | /* Pourrait etre utiliser pour detecter les problemes d'orientation */ |
308 | glLightModeli((GLenum)GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); |
309 | |
310 | /* Optimisation pour le Fog et l'antialiasing */ |
311 | glHint( GL_FOG_HINT, GL_FASTEST ); |
312 | glHint( GL_POINT_SMOOTH_HINT, GL_FASTEST ); |
313 | glHint( GL_LINE_SMOOTH_HINT, GL_FASTEST ); |
314 | glHint( GL_POLYGON_SMOOTH_HINT, GL_FASTEST ); |
315 | |
316 | /* Polygon Offset */ |
317 | call_subr_enable_polygon_offset(); |
318 | |
319 | return 1; |
320 | |
321 | } /* TxglWinset */ |
322 | } |
323 | |
324 | /*----------------------------------------------------------------------*/ |
325 | |
326 | void |
327 | call_subr_resize (CALL_DEF_VIEW * aview) |
328 | { |
329 | CMN_KEY_DATA data; |
330 | WINDOW win; |
331 | Tint width, height; |
332 | Tfloat bgcolr, bgcolg, bgcolb; |
333 | Tint wswidth, wsheight; |
334 | Tint wsviewstid; |
335 | /* Tint swap = 1;*/ /* swap buffers ? yes */ |
336 | |
337 | #ifndef WNT |
338 | /* XEvent event;*/ |
339 | Window root; |
340 | int newx, newy; |
341 | unsigned int newwidth, newheight, newbw, newdepth; |
342 | #else |
343 | RECT cr; |
344 | #endif /* WNT */ |
345 | |
346 | #ifdef TRACE |
347 | printf("call_subr_resize \n"); |
348 | #endif |
349 | /* Recuperation de la definition precedente de la ws */ |
350 | TsmGetWSAttri (aview->WsId, WSWidth, &data); |
351 | wswidth = data.ldata; |
352 | TsmGetWSAttri (aview->WsId, WSHeight, &data); |
353 | wsheight = data.ldata; |
354 | TsmGetWSAttri (aview->WsId, WSViewStid, &data); |
355 | wsviewstid = data.ldata; |
356 | |
357 | /* S'il s'agit du togl_ratio_window initial alors on ne fait rien */ |
358 | if (wsviewstid == -1) return; |
359 | |
360 | /* |
361 | * Si l'on resize une fenetre qui a la meme taille que la taille |
362 | * precedente alors on ne fait rien |
363 | */ |
364 | if ((wswidth == (Tint) aview->DefWindow.dx) && |
365 | (wsheight == (Tint) aview->DefWindow.dy)) return; |
366 | |
367 | #ifndef WNT |
368 | TsmGetWSAttri (aview->WsId, WSWindow, &data); |
369 | win = data.ldata; |
370 | |
371 | XResizeWindow (call_thedisplay, win, |
372 | (unsigned int) aview->DefWindow.dx, |
373 | (unsigned int) aview->DefWindow.dy); |
374 | |
375 | XSync (call_thedisplay, False); |
376 | |
377 | /* Mettre a jour ses attributs */ |
378 | XGetGeometry (call_thedisplay, win, &root, |
379 | &newx, &newy,&newwidth, &newheight, &newbw, &newdepth); |
380 | width = newwidth; |
381 | height = newheight; |
382 | |
383 | /* background color */ |
384 | bgcolr = aview->DefWindow.Background.r, |
385 | bgcolg = aview->DefWindow.Background.g, |
386 | bgcolb = aview->DefWindow.Background.b; |
387 | |
388 | /* Rendre courant le Drawable et le Context */ |
389 | if (TxglWinset (call_thedisplay, (Window) win) == TSuccess) { |
390 | |
391 | data.ldata = width; |
392 | TsmSetWSAttri (aview->WsId, WSWidth, &data); |
393 | data.ldata = height; |
394 | TsmSetWSAttri (aview->WsId, WSHeight, &data); |
395 | TelInitWS (aview->WsId, width, height, bgcolr, bgcolg, bgcolb); |
396 | } |
397 | |
398 | #else |
399 | |
400 | /* On detruit l'ancienne sous-fenetre de la window graphique */ |
401 | TsmGetWSAttri (aview->WsId, WSWindow, &data); |
402 | win = (WINDOW) data.ldata; |
403 | /* |
404 | * On recree une nouvelle sous-fenetre de la window graphique |
405 | * avec la nouvelle dimension |
406 | */ |
407 | /* background color */ |
408 | bgcolr = aview->DefWindow.Background.r, |
409 | bgcolg = aview->DefWindow.Background.g, |
410 | bgcolb = aview->DefWindow.Background.b; |
411 | /* Rendre courant le Drawable et le Context */ |
412 | if (TxglWinset (call_thedisplay, win) == TSuccess) { |
413 | //if (TxglWinset (call_thedisplay, GET_GL_CONTEXT()) == TSuccess) { |
414 | /* Mettre a jour la sous-fenetre associee */ |
415 | /* Mettre a jour ses attributs */ |
416 | GetClientRect ( win, &cr ); |
417 | width = cr.right; |
418 | height = cr.bottom; |
419 | data.ldata = width; |
420 | TsmSetWSAttri (aview->WsId, WSWidth, &data); |
421 | data.ldata = height; |
422 | TsmSetWSAttri (aview->WsId, WSHeight, &data); |
423 | TelInitWS (aview->WsId, width, height, bgcolr, bgcolg, bgcolb); |
424 | } |
425 | #endif /* WNT */ |
426 | |
427 | return; |
428 | } |
429 | |
430 | /*----------------------------------------------------------------------*/ |
431 | |
432 | void |
433 | call_subr_antialiasing( CALL_DEF_VIEW * aview, Tint tag ) |
434 | { |
435 | CMN_KEY k; |
436 | Tint fl = tag ? TOn : TOff; |
437 | |
438 | call_func_set_edit_mode( TEditReplace ); |
439 | call_func_open_struct( aview->ViewId ); |
440 | call_func_set_elem_ptr(0); |
441 | call_func_set_elem_ptr_label(View_LABAliasing); |
442 | call_func_offset_elem_ptr(1); |
443 | k.data.ldata = fl; |
444 | TsmAddToStructure( TelAntiAliasing, 1, &k ); |
445 | call_func_close_struct(); |
446 | return; |
447 | } |
448 | |
449 | /*----------------------------------------------------------------------*/ |
450 | |
451 | void |
452 | call_subr_hlhsr( CALL_DEF_VIEW * aview, int tag ) |
453 | { |
454 | CMN_KEY_DATA data; |
455 | |
456 | data.ldata = (tag ? TOn : TOff); |
457 | TsmSetWSAttri( aview->WsId, WSZbuffer, &data ); |
458 | return; |
459 | } |
460 | |
461 | |
462 | /*----------------------------------------------------------------------*/ |
463 | |
464 | void |
465 | call_subr_depthcueing( CALL_DEF_VIEW * aview, Tint tag ) |
466 | { |
467 | TEL_DEPTHCUE rep; |
468 | # define CALL_DEF_DEPTH_CUEING_INDEX 1 |
469 | |
470 | if( !tag ) |
471 | { |
472 | call_func_set_edit_mode(CALL_PHIGS_EDIT_REPLACE); |
473 | call_func_open_struct(aview->ViewId); |
474 | call_func_set_elem_ptr(0); |
475 | call_func_set_elem_ptr_label(View_LABDepthCueing); |
476 | call_func_offset_elem_ptr(1); |
477 | call_func_appl_data(0); |
478 | call_func_close_struct(); |
479 | } |
480 | else |
481 | { |
482 | rep.mode = CALL_PHIGS_ALLOWED; |
483 | rep.planes[0] = aview->Context.DepthBackPlane; |
484 | rep.planes[1] = aview->Context.DepthFrontPlane; |
485 | #ifdef TRACE |
486 | printf(" $$$ DepthFrontPlane %f DepthBackPlane %f FrontPlaneDistance %f BackPlaneDistance %f\n",aview->Context.DepthFrontPlane,aview->Context.DepthBackPlane,aview->Mapping.FrontPlaneDistance,aview->Mapping.BackPlaneDistance); |
487 | #endif |
488 | rep.planes[0] = |
489 | #ifdef IMP190100 |
490 | (aview->Context.DepthFrontPlane - |
491 | aview->Mapping.BackPlaneDistance) / |
492 | #else |
493 | (aview->Mapping.FrontPlaneDistance - |
494 | aview->Context.DepthFrontPlane) / |
495 | #endif |
496 | (aview->Mapping.FrontPlaneDistance - |
497 | aview->Mapping.BackPlaneDistance); |
498 | |
499 | rep.planes[1] = |
500 | #ifdef IMP190100 |
501 | (aview->Context.DepthBackPlane - |
502 | aview->Mapping.BackPlaneDistance) / |
503 | #else |
504 | (aview->Mapping.FrontPlaneDistance - |
505 | aview->Context.DepthBackPlane) / |
506 | #endif |
507 | (aview->Mapping.FrontPlaneDistance - |
508 | aview->Mapping.BackPlaneDistance); |
509 | |
510 | if(rep.planes[0] < 0.) |
511 | rep.planes[0] = ( float )0.0; |
512 | else if(rep.planes[0] > 1.) |
513 | rep.planes[0] = ( float )1.0; |
514 | if(rep.planes[1] < 0.) |
515 | rep.planes[1] = ( float )0.0; |
516 | else if(rep.planes[1] > 1.) |
517 | rep.planes[1] = ( float )1.0; |
518 | #ifdef IMP190100 |
519 | if(rep.planes[1] > rep.planes[0]) |
520 | { |
521 | rep.planes[1] = ( float )0.0; |
522 | rep.planes[0] = ( float )1.0; |
523 | } |
524 | #else |
525 | if(rep.planes[0] > rep.planes[1]) |
526 | { |
527 | rep.planes[0] = ( float )0.0; |
528 | rep.planes[1] = ( float )1.0; |
529 | } |
530 | #endif |
531 | |
532 | #ifdef TRACE |
533 | printf(" plane[0] %f plane[1] %f\n",rep.planes[0],rep.planes[1]); |
534 | #endif |
535 | rep.scales[0] = ( float )1.; |
536 | rep.scales[1] = ( float )0.; |
537 | rep.col.rgb[0] = aview->DefWindow.Background.r; |
538 | rep.col.rgb[1] = aview->DefWindow.Background.g; |
539 | rep.col.rgb[2] = aview->DefWindow.Background.b; |
540 | TelSetDepthCueRep(aview->WsId, CALL_DEF_DEPTH_CUEING_INDEX, &rep); |
541 | |
542 | call_func_set_edit_mode(CALL_PHIGS_EDIT_REPLACE); |
543 | call_func_open_struct(aview->ViewId); |
544 | call_func_set_elem_ptr(0); |
545 | call_func_set_elem_ptr_label(View_LABDepthCueing); |
546 | call_func_offset_elem_ptr(1); |
547 | call_func_dcue_ind(CALL_DEF_DEPTH_CUEING_INDEX); |
548 | call_func_close_struct(); |
549 | } |
550 | return; |
551 | } |
552 | |
553 | /*----------------------------------------------------------------------*/ |
554 | |
555 | TStatus |
556 | call_subr_get_view_index( Tint stid, Tint *ind ) |
557 | { |
558 | tsm_node node; |
559 | Tint i, num; |
560 | |
561 | if( TsmGetStructure( stid, &num, &node ) == TSuccess ) |
562 | { |
563 | for( i = 0; i < num; i++ ) |
564 | { |
565 | if( node->elem.el == TelViewIndex ) |
566 | { |
567 | *ind = node->elem.data.ldata; |
568 | return TSuccess; |
569 | } |
570 | } |
571 | } |
572 | return TFailure; |
573 | } |
574 | |
575 | /*----------------------------------------------------------------------*/ |
576 | |
577 | void |
578 | call_subr_pick( CALL_DEF_PICK *apick ) |
579 | { |
580 | Tint depth; |
581 | TPickOrder order; |
582 | TStatus stat; |
583 | |
584 | static int *listid, *listelem, *listpickid; |
585 | |
586 | TEL_PICK_PATH path_list[CALL_MAX_DEPTH_LENGTH]; |
587 | TEL_PICK_REPORT rep; |
588 | |
589 | Tint i; |
590 | |
591 | if( listid ) |
592 | { |
593 | //cmn_freemem( listid ); |
594 | delete[] listid; |
595 | //cmn_freemem( listelem ); |
596 | delete[] listelem; |
597 | //cmn_freemem( listpickid ); |
598 | delete[] listpickid; |
599 | listid = listelem = listpickid = 0; |
600 | } |
601 | |
602 | order = apick->Context.order == 0 ? PTOP_FIRST : PBOTTOM_FIRST; |
603 | |
604 | depth = apick->Context.depth < CALL_MAX_DEPTH_LENGTH ? |
605 | apick->Context.depth : CALL_MAX_DEPTH_LENGTH ; |
606 | |
607 | rep.pick_path = path_list; |
608 | |
609 | stat = TPick( apick->WsId, apick->x, apick->y, apick->Context.aperture, |
610 | apick->Context.aperture, order, depth, &rep ); |
611 | |
612 | if( stat == TSuccess ) |
613 | { |
614 | apick->Pick.depth = rep.depth; |
615 | |
616 | #ifdef TRACE |
617 | printf( "\n\n\tPICK REPORT FOLLOWS" ); |
618 | printf( "\n\t*******************\n" ); |
619 | printf( "\ndepth = %d\torder = %s\n", rep.depth, |
620 | order == PTOP_FIRST ? "TopFirst" : "BottomFirst" ); |
621 | #endif |
622 | |
623 | //cmn_memreserve( listid, rep.depth, 0 ); |
624 | listid = new int[rep.depth]; |
625 | //cmn_memreserve( listelem, rep.depth, 0 ); |
626 | listelem = new int[rep.depth]; |
627 | //cmn_memreserve( listpickid, rep.depth, 0 ); |
628 | listpickid = new int[rep.depth]; |
629 | if( !listid || !listelem || !listpickid ) |
630 | return; |
631 | apick->Pick.listid = listid; |
632 | apick->Pick.listelem = listelem; |
633 | apick->Pick.listpickid = listpickid; |
634 | |
635 | for( i = 0; i < rep.depth; i++ ) |
636 | { |
637 | listelem[i] = path_list[i].el_num; |
638 | listpickid[i] = path_list[i].pick_id; |
639 | listid[i] = path_list[i].struct_id; |
640 | #ifdef TRACE |
641 | printf( "\n\tSTRUCTURE ID [%d] = %ld", i, listid[i] ); |
642 | printf( "\n\tPICK ID [%d] = %ld", i, listpickid[i] ); |
643 | printf( "\n\tELEMENT ID [%d] = %ld", i, listelem[i] ); |
644 | #endif |
645 | } |
646 | #ifdef TRACE |
647 | printf("\n"); |
648 | #endif |
649 | } |
650 | |
651 | return; |
652 | } |
653 | |
654 | |
655 | /*----------------------------------------------------------------------*/ |
656 | |
657 | void |
658 | call_subr_set_light_src_rep( CALL_DEF_LIGHT * alight ) |
659 | { |
660 | TEL_LIGHT rep; |
661 | |
662 | switch( alight->LightType ) |
663 | { |
664 | case 0 : /* TOLS_AMBIENT */ |
665 | rep.type = CALL_PHIGS_LIGHT_AMBIENT; |
666 | rep.col.rgb[0] = alight->Color.r; |
667 | rep.col.rgb[1] = alight->Color.g; |
668 | rep.col.rgb[2] = alight->Color.b; |
669 | break; |
670 | |
671 | case 1 : /* TOLS_DIRECTIONAL */ |
672 | rep.type = CALL_PHIGS_LIGHT_DIRECTIONAL; |
673 | rep.col.rgb[0] = alight->Color.r; |
674 | rep.col.rgb[1] = alight->Color.g; |
675 | rep.col.rgb[2] = alight->Color.b; |
676 | rep.dir[0] = alight->Direction.x; |
677 | rep.dir[1] = alight->Direction.y; |
678 | rep.dir[2] = alight->Direction.z; |
679 | break; |
680 | |
681 | case 2 : /* TOLS_POSITIONAL */ |
682 | rep.type = CALL_PHIGS_LIGHT_POSITIONAL; |
683 | rep.col.rgb[0] = alight->Color.r; |
684 | rep.col.rgb[1] = alight->Color.g; |
685 | rep.col.rgb[2] = alight->Color.b; |
686 | rep.pos[0] = alight->Position.x; |
687 | rep.pos[1] = alight->Position.y; |
688 | rep.pos[2] = alight->Position.z; |
689 | rep.atten[0] = alight->Attenuation[0]; |
690 | rep.atten[1] = alight->Attenuation[1]; |
691 | break; |
692 | |
693 | case 3 : /* TOLS_SPOT */ |
694 | rep.type = CALL_PHIGS_LIGHT_SPOT; |
695 | rep.col.rgb[0] = alight->Color.r; |
696 | rep.col.rgb[1] = alight->Color.g; |
697 | rep.col.rgb[2] = alight->Color.b; |
698 | rep.pos[0] = alight->Position.x; |
699 | rep.pos[1] = alight->Position.y; |
700 | rep.pos[2] = alight->Position.z; |
701 | rep.dir[0] = alight->Direction.x; |
702 | rep.dir[1] = alight->Direction.y; |
703 | rep.dir[2] = alight->Direction.z; |
704 | rep.shine = alight->Concentration; |
705 | rep.atten[0] = alight->Attenuation[0]; |
706 | rep.atten[1] = alight->Attenuation[1]; |
707 | rep.angle = alight->Angle; |
708 | break; |
709 | } |
710 | |
711 | rep.HeadLight = alight->Headlight; |
712 | AddLight( alight->WsId, alight->LightId, &rep ); |
713 | |
714 | return; |
715 | } |
716 | |
717 | /*----------------------------------------------------------------------*/ |
718 | |
719 | void |
720 | call_subr_set_background( Tint ws, tel_colour rgb ) |
721 | { |
722 | CMN_KEY_DATA data; |
723 | CMN_KEY_DATA key; |
724 | |
725 | /* Mise a jour de l'update_mode */ |
726 | key.ldata = TNotDone; |
727 | TsmSetWSAttri( ws, WSUpdateState, &key ); |
728 | |
729 | data.pdata = rgb->rgb; |
730 | TsmSetWSAttri( ws, WSBackground, &data ); |
731 | return; |
732 | } |
733 | |
734 | /*----------------------------------------------------------------------*/ |
735 | |
736 | void |
737 | call_subr_set_gradient_background( Tint ws, Tint type, tel_colour color1, tel_colour color2 ) |
738 | { |
739 | CMN_KEY_DATA data; |
740 | CMN_KEY_DATA key; |
741 | TSM_BG_GRADIENT bgGradient; |
742 | |
743 | /* Mise a jour de l'update_mode */ |
744 | key.ldata = TNotDone; |
745 | TsmSetWSAttri( ws, WSUpdateState, &key ); |
746 | |
747 | bgGradient.type = (TSM_GradientType)type; |
748 | bgGradient.color1 = *color1; |
749 | bgGradient.color2 = *color2; |
750 | data.pdata = &bgGradient; |
751 | TsmSetWSAttri( ws, WSBgGradient, &data ); |
752 | return; |
753 | } |
754 | |
755 | |
756 | /*----------------------------------------------------------------------*/ |
757 | |
758 | void |
759 | call_subr_close_ws( CALL_DEF_VIEW * aview ) |
760 | { |
761 | CMN_KEY_DATA key; |
762 | #ifdef OCC1188 |
763 | tsm_bg_texture texture; |
764 | |
765 | TsmGetWSAttri( aview->WsId, WSBgTexture, &key ); |
766 | texture = (tsm_bg_texture)key.pdata; |
767 | |
768 | if( texture == 0 ) |
769 | return; |
770 | |
771 | if ( texture->texId != 0 ) |
772 | glDeleteTextures( 1,(GLuint *)&(texture->texId) ); |
773 | #endif |
774 | |
775 | TsmGetWSAttri( aview->WsId, WSWindow, &key ); |
776 | #ifdef RIC120302 |
777 | if( !aview->GContext ) |
778 | #endif |
779 | TxglDestroyWindow( call_thedisplay, (WINDOW) key.ldata ); |
780 | |
781 | TglDeleteFiltersForWS( aview->WsId ); |
782 | RemoveWksLight( aview->WsId ); |
783 | call_triedron_erase (aview); /* BGN 09-12-98 */ |
784 | call_graduatedtrihedron_erase( aview->WsId ); |
785 | TelDeleteViewsForWS( aview->WsId ); |
786 | TelDeleteHighlightsForWS( aview->WsId ); |
787 | TelDeleteDepthCuesForWS( aview->WsId ); |
788 | |
789 | TsmUnregisterWsid( aview->WsId ); |
790 | return; |
791 | } |
792 | |
793 | /*----------------------------------------------------------------------*/ |
794 | |
795 | void |
796 | call_subr_transparency (int wsid, int viewid, int tag) |
797 | { |
798 | CMN_KEY_DATA data; |
799 | CMN_KEY_DATA key; |
800 | |
801 | /* Est-il necessaire de faire de la transparence ? */ |
802 | TsmGetWSAttri( wsid, WSTransparency, &data ); |
803 | if (data.ldata != tag) |
804 | { |
805 | data.ldata = (tag ? TOn : TOff); |
806 | TsmSetWSAttri( wsid, WSTransparency, &data ); |
807 | |
808 | /* Mise a jour de l'update_mode */ |
809 | key.ldata = TNotDone; |
810 | TsmSetWSAttri( wsid, WSUpdateState, &key ); |
811 | (void) call_togl_erase_animation_mode(); |
812 | } |
813 | } |
814 | |
815 | #ifdef RIC120302 |
816 | /*----------------------------------------------------------------------*/ |
817 | int |
818 | call_subr_displayCB( CALL_DEF_VIEW * aview, int reason ) |
819 | { |
820 | int status = 0; |
821 | if( aview->GDisplayCB ) { |
822 | Aspect_GraphicCallbackStruct callData; |
823 | CMN_KEY_DATA data; |
824 | WINDOW win; |
825 | |
826 | TsmGetWSAttri (aview->WsId, WSWindow, &data); |
827 | win = (WINDOW) data.ldata; |
828 | |
829 | callData.reason = reason; |
830 | callData.display = call_thedisplay; |
831 | callData.window = win; |
832 | callData.wsID = aview->WsId; |
833 | callData.viewID = aview->ViewId; |
834 | callData.gcontext = TxglGetContext(win); |
835 | |
836 | status = (*aview->GDisplayCB) |
837 | ( aview->DefWindow.XWindow, aview->GClientData, &callData ); |
838 | } |
839 | |
840 | return status; |
841 | } |
842 | #endif |