1 /***********************************************************************
12 HISTORIQUE DES MODIFICATIONS :
13 --------------------------------
14 xx-xx-xx : xxx ; Creation.
15 07-02-96 : FMN ; Suppression code inutile:
16 - TxglLink() et TxglUnlink()
17 08-03-96 : FMN ; Suppression variables globales
18 Ajout cmn_delete_from_htbl() dans TxglDestroyWindow()
19 21-03-96 : CAL ; test sur previous_ctx dans TxglDestroyWindow()
20 et dans TxglSetDbuff()
21 01-04-96 : CAL ; Integration MINSK portage WNT
22 15-04-96 : CAL ; Integration travail PIXMAP de Jim ROTH
23 26-04-96 : FMN ; Correction warning de compilation
24 20-06-96 : CAL ; Retrait du XDestroyWindow dans TxglDestroyWindow
25 18-07-96 : FMN ; Suppression code inutile: TxglSetWindow().
26 27-09-96 : CAL ; Portage WNT
27 16-10-96 : GG ; Coder le parametre de GLX_DEPTH_SIZE a 1 plutot
28 que 0 si l'on souhaite accroitre les performances
29 de 50% en utilisant le ZBuffer hardware !!!
30 Si la fenetre fournie a deja le bon visual pas
31 la peine de creer une sous-fenetre.
32 16-10-96 : GG ; Le dithering doit etre active aussi avec 12 plans
33 de maniere a ameliorer la qualite
34 17-10-96 : FMN ; Ajout fonction printVisualInfo()
35 06-11-96 : CAL ; Remise a True du BackDitherProp pour < 12 plans
36 12-11-96 : CAL ; BackDitherProp = True pour <= 8 plans
37 BackDitherProp = False pour > 8 plans
38 29-01-97 : FMN ; Amelioration du tests pour le dithering
39 DitherProp = True pour <= 8 plans red
40 DitherProp = False pour > 8 plans red
41 Suppression de TxglSetDbuff()
42 06-06-97 : FMN ; Meilleure gestion glXMakeCurrent (pb avec LightWoks)
43 Suppression de previous_win
44 02-07-97 : FMN ; Suppression variable ESSAI
45 07-10-97 : FMN ; Simplification WNT
46 13-10-97 : FMN ; Ajout wglShareLists
47 06-02-98 : FMN ; PRO11674: Suppression XSetErrorHandler(0) inutile
48 23-11-98 : CAL ; PRO16603: previous_ctx jamais remis a 0 pour eviter
50 07-12-98 : CAL ; PRO 16311 et PRO 11821
51 02.14.100 : JR : Warnings on WNT
52 14.07.06 : SAN : OCC12977: update previous_ctx properly in TxglDestroyWindow.
53 Old code resulted in crashes on some ATI Radeon cards under Linux.
55 ************************************************************************/
57 #define BUC60691 /*GG 06/06/00 Due to a severe bug in secondary
58 // table hash-code computation not yet solve,
59 // It's necessary to compute the primary hash-key key
60 // correctly under WNT/W98. The actual method is wrong
61 // because a size 4 is used for this table instead
62 // a conventional prime number as under UNIX system (23).
63 // Under W98 sometimes the function wglMakeContext() does
64 // not work for an UNKNOWN reason, the number of DC
65 // seems limited to 5 but nothing tell that the limit is
67 // We try right now to recover this error by creating a new DC.
70 #define RIC120303 /*GG Add new function TxglSetWindow using
71 // the GLXContext defined by the user
72 // Add new function TxglGetContext.
75 #define OCC954 /*SAV: 13/11/02 - check GLRC before deleting it*/
77 /*----------------------------------------------------------------------*/
81 #include <OpenGl_tgl_all.hxx>
82 #include <OpenGl_telem_util.hxx>
85 #include <OpenGl_Memory.hxx>
93 IMPLEMENT_MEMORY_OPERATORS
97 int call_util_osd_getenv ( char*, char*, int );
100 #include <OpenGl_txgl.hxx>
101 int call_util_osd_getenv( char * , char * , int ) ;
103 /*----------------------------------------------------------------------*/
105 * Variables statiques
109 typedef NCollection_DataMap<Tint, GLCONTEXT> GLContextMap;
111 typedef NCollection_DataMap<Tint, HTBL_ENTRY*> GLContextMap;
114 static GLContextMap _Txgl_Map;
118 static int BackDitherProp = False; /* Dithering pour le background */
119 static int DitherProp = True; /* Dithering pour le trace */
120 static GLXContext previous_ctx = 0; /* Use for share display list */
121 static GLXContext dead_ctx; /* Context to be destroyed */
122 static Display *dead_dpy; /* Display associated with dead_ctx */
124 static int BackDitherProp = FALSE; /* Dithering pour le background */
125 static int DitherProp = TRUE; /* Dithering pour le trace */
126 static BOOL s_sysPalInUse; /* Flag to check system colors usage */
127 static HGLRC previous_ctx = 0; /* Use for share display list */
130 /*----------------------------------------------------------------------*/
137 #define CALL_DEF_STRING_LENGTH 132
139 #define WIN_HTBL_SIZE 23
141 /*----------------------------------------------------------------------*/
143 * Fonctions statiques
148 static GLvoid printVisualInfo( Display *, XVisualInfo *glxVisual );
152 static BOOL win95 = FALSE;
155 static int find_pixel_format(HTBL_ENTRY * hte, PIXELFORMATDESCRIPTOR * pfd);
157 __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
158 unsigned hInstance, unsigned long reason_for_call
160 if ( reason_for_call == DLL_PROCESS_ATTACH ) {
165 } /* end __OpenGl_INIT__ */
168 /*----------------------------------------------------------------------*/
171 TxglCreateWindow( DISPLAY *disp, WINDOW par,
172 Tint x, Tint y, Tint w, Tint h, Tint bw,
173 Tfloat bgcolr, Tfloat bgcolg, Tfloat bgcolb )
179 static int sdesc[11];
181 XVisualInfo* vis=NULL;
182 /* XVisualInfo tmplt;*/
183 XSetWindowAttributes cwa;
185 /* Tint i, n, nret;*/
189 char string[CALL_DEF_STRING_LENGTH];
191 XWindowAttributes wattr;
195 unsigned long mask = 0;
196 /* unsigned long background_pixel = 0;*/
198 if (call_util_osd_getenv("CALL_OPENGL_NO_DBF", string, CALL_DEF_STRING_LENGTH))
201 if (call_util_osd_getenv("JWR_PIXMAP_DB", string, CALL_DEF_STRING_LENGTH))
204 XGetWindowAttributes( disp , par , &wattr );
207 sdesc[n] = GLX_RGBA;n++;
209 sdesc[n] = GLX_DEPTH_SIZE;n++;
212 sdesc[n] = GLX_RED_SIZE;n++;
213 sdesc[n] = (wattr.depth <= 8) ? 0 : 1;n++;
215 sdesc[n] = GLX_GREEN_SIZE;n++;
216 sdesc[n] = (wattr.depth <= 8) ? 0 : 1;n++;
218 sdesc[n] = GLX_BLUE_SIZE;n++;
219 sdesc[n] = (wattr.depth <= 8) ? 0 : 1;n++;
222 sdesc[n] = GLX_DOUBLEBUFFER;n++;
227 scr = DefaultScreen( disp );
229 #if defined(__linux) || defined(Linux)
233 unsigned long vmask = VisualIDMask | VisualScreenMask;
234 vinfo.visualid = wattr.visual->visualid;
235 vinfo.screen = DefaultScreen( disp );
236 vis = XGetVisualInfo( disp, vmask, &vinfo, &ninfo);
241 vis = glXChooseVisual( disp, scr, sdesc );
242 if( !vis) return TFailure;
245 printf ("TxglCreateWindow \n");
246 printf ("Informations sur le visual\n");
247 printf ("par visualid %x%x %d\n", wattr.visual->visualid, wattr.visual->visualid);
248 printf ("vis visualid 0x%x %d\n", vis->visualid, vis->visualid);
249 printf ("vis depth %d\n", vis->depth);
250 printf ("vis class %d\n", vis->class);
251 printf ("vis red_mask %ld\n", vis->red_mask);
252 printf ("vis green_mask %ld\n", vis->green_mask);
253 printf ("vis blue_mask %ld\n", vis->blue_mask);
254 printf ("vis colormap_size %d\n", vis->colormap_size);
255 printf ("vis bits_per_rgb %d\n", vis->bits_per_rgb);
256 printVisualInfo( disp, vis );
260 * Le BackDitherProp est utilise pour le clear du background
261 * Pour eviter une difference de couleurs avec la couleur choisie
262 * par l'application (XWindow) il faut desactiver le dithering
263 * au dessus de 8 plans.
265 * Pour le DitherProp:
266 * On cherchera a activer le Dithering que si le Visual a au moins
267 * 8 plans pour le GLX_RED_SIZE. Le test est plus sur car on peut
268 * avoir une profondeur superieure a 12 mais avoir besoin du dithering.
269 * (Carte Impact avec GLX_RED_SIZE a 5 par exemple)
272 glXGetConfig( disp, vis, GLX_RED_SIZE, &value );
282 if ( vis->depth <= 8 ) {
283 BackDitherProp = True;
287 BackDitherProp = False;
291 printf("Dithering %d BackDithering %d \n",DitherProp,BackDitherProp);
294 if (call_util_osd_getenv ("CALL_OPENGL_NO_DITHER", string, CALL_DEF_STRING_LENGTH))
297 if (call_util_osd_getenv ("CALL_OPENGL_NO_BACKDITHER", string, CALL_DEF_STRING_LENGTH))
298 BackDitherProp = False;
301 /* recover display lists from dead_ctx, then destroy it */
302 ctx = glXCreateContext( disp, vis, dead_ctx, GL_TRUE );
303 glXDestroyContext(dead_dpy, dead_ctx);
305 } else if (previous_ctx == 0) {
306 ctx = glXCreateContext( disp, vis, NULL, GL_TRUE );
308 /* ctx est une copie du previous */
309 ctx = glXCreateContext( disp, vis, previous_ctx, GL_TRUE );
313 if( !ctx) return TFailure;
315 cmap = XCreateColormap( disp, par, vis->visual, AllocNone );
317 color.red = (unsigned short) (bgcolr * 0xFFFF);
318 color.green = (unsigned short) (bgcolg * 0xFFFF);
319 color.blue = (unsigned short) (bgcolb * 0xFFFF);
320 color.flags = DoRed | DoGreen | DoBlue;
321 XAllocColor( disp, cmap, &color );
324 cwa.event_mask = StructureNotifyMask;
325 cwa.border_pixel = color.pixel;
326 cwa.background_pixel = color.pixel;
328 mask = CWBackPixel | CWColormap | CWBorderPixel | CWEventMask;
330 if( vis->visualid == wattr.visual->visualid ) {
335 win = XCreateWindow( disp, par, x, y, w, h, bw,
336 vis->depth, InputOutput, vis->visual,
341 printf ("TxglCreateWindow win %x par %x \n", win, par);
344 XSetWindowBackground( disp, win, cwa.background_pixel );
345 XClearWindow( disp, win );
347 /* if in Pixmap double buffering mode, set up pixmap */
349 if (TelTestPixmapDB())
355 printf("setting up pixmap double buffering\n");
357 gc = XCreateGC(disp, win, 0, NULL);
359 pixmap = XCreatePixmap(disp, win, w, h, vis->depth);
361 glxpixmap = glXCreateGLXPixmap(disp, vis, pixmap);
363 glXMakeCurrent(disp, glxpixmap, ctx);
365 glDrawBuffer(GL_FRONT);
367 TelSetPixmapDBParams(disp, win, w, h, vis->depth, gc, pixmap, glxpixmap, ctx);
372 _Txgl_Map.Bind( (Tint)win, ctx );
379 PIXELFORMATDESCRIPTOR pfd;
382 char string[ CALL_DEF_STRING_LENGTH ];
386 os.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
388 if( os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) win95 = TRUE;
391 if ( _Txgl_Map.IsBound( (Tint)par ) ) {
392 hte = _Txgl_Map.ChangeFind( (Tint)par );
396 printf("*TxglCreateWindow.window %d is alreday created\n",par);
401 hte = new HTBL_ENTRY();
403 if ( !hte ) return 0;
404 hte -> hDC = GetDC ( par );
406 iPixelFormat = find_pixel_format(hte, &pfd);
410 printf ("*OpenGL interface: ChoosePixelFormat failed. Error code: %d\n",GetLastError ());
412 ReleaseDC ( par, hte -> hDC );
418 if ( pfd.dwFlags & PFD_NEED_PALETTE )
421 WINDOW_DATA* wd = ( WINDOW_DATA* )GetWindowLong ( par, GWL_USERDATA );
423 WINDOW_DATA* wd = ( WINDOW_DATA* )GetWindowLong ( par, GWLP_USERDATA );
426 InterfaceGraphic_RealizePalette (hte -> hDC, wd -> hPal, FALSE,
427 s_sysPalInUse = pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE);
430 if ( pfd.cColorBits <= 8 )
433 BackDitherProp = TRUE;
436 if (call_util_osd_getenv ("CALL_OPENGL_NO_DITHER", string, CALL_DEF_STRING_LENGTH))
439 if (call_util_osd_getenv ("CALL_OPENGL_NO_BACKDITHER", string, CALL_DEF_STRING_LENGTH))
440 BackDitherProp = FALSE;
442 if ( !SetPixelFormat ( hte -> hDC, iPixelFormat, &pfd ) )
444 printf ("*OpenGL interface: SetPixelFormat failed. Error code %d\n",GetLastError ());
445 ReleaseDC ( par, hte -> hDC );
450 hte -> hGLRC = wglCreateContext ( hte -> hDC );
454 printf ("*OpenGL interface: wglCreateContext failed. Error code: %d\n",GetLastError ());
458 if (previous_ctx == 0 )
460 previous_ctx = hte -> hGLRC;
462 wglShareLists(previous_ctx, hte -> hGLRC);
464 _Txgl_Map.Bind( (Tint)par, hte );
474 TxglSetWindow( DISPLAY *disp, WINDOW par, GLCONTEXT ctx)
478 char string[CALL_DEF_STRING_LENGTH];
479 XWindowAttributes wattr;
481 XGetWindowAttributes( disp , par , &wattr );
483 unsigned long vmask = VisualIDMask | VisualScreenMask;
486 vinfo.visualid = wattr.visual->visualid;
487 vinfo.screen = DefaultScreen( disp );
488 vis = XGetVisualInfo( disp, vmask, &vinfo, &ninfo);
491 if( !vis) return TFailure;
494 printf ("TxglSetWindow \n");
495 printf ("Informations sur le visual\n");
496 printf ("par visualid %x%x %d\n", wattr.visual->visualid, wattr.visual->visualid);
497 printf ("vis visualid 0x%x %d\n", vis->visualid, vis->visualid);
498 printf ("vis depth %d\n", vis->depth);
499 printf ("vis class %d\n", vis->class);
500 printf ("vis red_mask %ld\n", vis->red_mask);
501 printf ("vis green_mask %ld\n", vis->green_mask);
502 printf ("vis blue_mask %ld\n", vis->blue_mask);
503 printf ("vis colormap_size %d\n", vis->colormap_size);
504 printf ("vis bits_per_rgb %d\n", vis->bits_per_rgb);
505 printVisualInfo( disp, vis );
509 * Le BackDitherProp est utilise pour le clear du background
510 * Pour eviter une difference de couleurs avec la couleur choisie
511 * par l'application (XWindow) il faut desactiver le dithering
512 * au dessus de 8 plans.
514 * Pour le DitherProp:
515 * On cherchera a activer le Dithering que si le Visual a au moins
516 * 8 plans pour le GLX_RED_SIZE. Le test est plus sur car on peut
517 * avoir une profondeur superieure a 12 mais avoir besoin du dithering.
518 * (Carte Impact avec GLX_RED_SIZE a 5 par exemple)
523 glXGetConfig( disp, vis, GLX_RED_SIZE, &value );
531 if ( vis->depth <= 8 ) {
532 BackDitherProp = True;
534 BackDitherProp = False;
539 printf("Dithering %d BackDithering %d \n",DitherProp,BackDitherProp);
542 if (call_util_osd_getenv ("CALL_OPENGL_NO_DITHER", string, CALL_DEF_STRING_LENGTH))
545 if (call_util_osd_getenv ("CALL_OPENGL_NO_BACKDITHER", string, CALL_DEF_STRING_LENGTH))
546 BackDitherProp = False;
552 _Txgl_Map.Bind( ( Tint )par, ctx );
558 PIXELFORMATDESCRIPTOR pfd;
561 char string[ CALL_DEF_STRING_LENGTH ];
565 os.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
567 if( os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) win95 = TRUE;
570 if ( _Txgl_Map.IsBound( ( Tint )par ) )
572 hte = _Txgl_Map.ChangeFind( ( Tint )par );
574 printf("*TxglSetWindow.window %d is alreday created\n",par);
578 hte = new HTBL_ENTRY();
580 if ( !hte ) return 0;
582 hte -> hDC = GetDC ( par );
583 iPixelFormat = find_pixel_format(hte, &pfd);
587 printf ("*OpenGL interface: ChoosePixelFormat failed. Error code: %d\n",GetLastError ());
589 ReleaseDC ( par, hte -> hDC );
595 if ( pfd.dwFlags & PFD_NEED_PALETTE )
598 WINDOW_DATA* wd = ( WINDOW_DATA* )GetWindowLong ( par, GWL_USERDATA );
600 WINDOW_DATA* wd = ( WINDOW_DATA* )GetWindowLong ( par, GWLP_USERDATA );
603 InterfaceGraphic_RealizePalette (hte -> hDC, wd -> hPal, FALSE,
604 s_sysPalInUse = pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE);
607 if ( pfd.cColorBits <= 8 )
610 BackDitherProp = TRUE;
613 if (call_util_osd_getenv ("CALL_OPENGL_NO_DITHER", string, CALL_DEF_STRING_LENGTH))
616 if (call_util_osd_getenv ("CALL_OPENGL_NO_BACKDITHER", string, CALL_DEF_STRING_LENGTH))
617 BackDitherProp = FALSE;
619 if ( !SetPixelFormat ( hte -> hDC, iPixelFormat, &pfd ) )
621 printf ("*OpenGL interface: SetPixelFormat failed. Error code %d\n",GetLastError ());
622 ReleaseDC ( par, hte -> hDC );
627 hte -> hGLRC = previous_ctx = ctx;
629 _Txgl_Map.Bind( ( Tint )par, hte );
637 /*----------------------------------------------------------------------*/
640 TxglWinset( DISPLAY *disp, WINDOW win )
648 const GLubyte *errorstring;
650 if ( !_Txgl_Map.IsBound( win ) )
653 ctx = _Txgl_Map.ChangeFind( win );
657 printf ("TxglWinset::glXMakeCurrent %x \n", win);
659 if (TelTestPixmapDB())
661 i = glXMakeCurrent(disp, TelGetGLXPixmap(), ctx);
665 i = glXMakeCurrent(disp, win, ctx); /* TRUE/FALSE */
669 errorcode = glGetError();
670 errorstring = gluErrorString(errorcode);
671 printf("glXMakeCurrent failed: %d %s\n", errorcode, errorstring);
674 return i == True ? TSuccess : TFailure;
681 TStatus retVal = TFailure;
685 if ( !_Txgl_Map.IsBound( ( Tint )win ) ) {
686 printf("OpenGL interface: TxglWinset failed.UNKNOWN win %x\n",win);
689 hte = _Txgl_Map.ChangeFind( ( Tint )win );
693 retVal = (TStatus)ReleaseDC ( win, hte -> hDC );
694 hte -> hDC = GetDC ( win );
697 if ( !wglMakeCurrent ( hte -> hDC, hte -> hGLRC ) )
701 const GLubyte *errorstring;
703 errorcode = glGetError();
704 errorstring = gluErrorString(errorcode);
705 printf("wglMakeCurrent failed: %d %s\n", errorcode, errorstring);
707 printf ("OpenGL interface: wglMakeCurrent failed. Error code: %d\n",GetLastError ());
710 } else retVal = TSuccess;
725 /*----------------------------------------------------------------------*/
728 TxglGetSubWindow( DISPLAY *disp, WINDOW win )
729 /* This function assumes that there is only
730 one child for the parent */
735 Window root, parent, *child, w;
738 if( XQueryTree( disp, win, &root, &parent, &child, &num ) )
740 if (! num) return win;
742 XFree( (char *)child );
756 /*----------------------------------------------------------------------*/
759 TxglDestroyWindow( DISPLAY *disp, WINDOW win )
767 if ( !_Txgl_Map.IsBound(win) )
769 ctx = _Txgl_Map.ChangeFind(win);
771 /* FSXXX sync necessary if non-direct rendering */
774 _Txgl_Map.UnBind( win );
776 if (previous_ctx == ctx) {
777 /* san -- OCC12977: it's important to put some valid GLXContext or null into
778 previous_ctx here, otherwise next glxCreateContext() will crash on some ATI Radeon cards
781 if ( _Txgl_Map.Size() > 0 ) {
782 GLContextMap::Iterator it(_Txgl_Map);
783 previous_ctx = it.Value();
786 * if this is the last remaining context, do not destroy it yet, to avoid
787 * losing any shared display lists (fonts...)
790 glXDestroyContext(disp, ctx);
796 glXDestroyContext(disp, ctx);
805 if ( !_Txgl_Map.IsBound(( Tint )win) )
807 hte = _Txgl_Map.ChangeFind(( Tint )win);
810 /* In release version of application we need to process */
811 /* palette messages in the main application message loop. */
812 /* In debug version we don't have message loop for most */
813 /* cases. So, let's restore system colors here now. */
815 wd = ( WINDOW_DATA* )GetWindowLong ( win, GWL_USERDATA );
817 wd = ( WINDOW_DATA* )GetWindowLong ( win, GWLP_USERDATA );
820 if ( wd != NULL ) InterfaceGraphic_RealizePalette (
821 hte -> hDC, wd -> hPal, TRUE, s_sysPalInUse);
824 if ( --hte -> nUsed == 0 )
827 if ( wglGetCurrentContext() != NULL )
829 wglDeleteContext ( hte -> hGLRC );
830 ReleaseDC ( win, hte -> hDC );
831 _Txgl_Map.UnBind( (Tint ) win );
839 /*----------------------------------------------------------------------*/
847 /*----------------------------------------------------------------------*/
850 TxglGetBackDither(void)
852 return BackDitherProp;
856 /*----------------------------------------------------------------------*/
859 TxglGetContext( WINDOW win )
861 GLCONTEXT ctx = NULL;
862 if ( _Txgl_Map.IsBound( (Tint) win ) )
865 _Txgl_Map.Find( (Tint) win )->hGLRC;
867 _Txgl_Map.Find( win );
874 /*----------------------------------------------------------------------*/
875 enum { ZERO = 0, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN };
880 className( int class )
882 static char *classes[] = {
891 if ( class < ZERO || class > FIVE )
894 return classes[class];
897 /*----------------------------------------------------------------------*/
901 static GLvoid printVisualInfo( DISPLAY *display, XVisualInfo *glxVisual )
904 #define TrueFalse(x) ( x ? "True" : "False" )
909 printf(" X Visual Information ...\n\n" );
910 printf("\tvisualid : 0x%x\n", glxVisual->visualid );
911 printf("\tclass : %s\n\n", className( glxVisual->class ) );
913 glXGetConfig(display, glxVisual, GLX_USE_GL, &tmp);
914 printf( "\tSupport GL ( GLX_USE_GL ) : %s\n", TrueFalse(tmp) );
916 glXGetConfig(display, glxVisual, GLX_LEVEL, &tmp);
917 printf( "\tFramebuffer ( GLX_LEVEL ) : %s\n\n",
918 (tmp < ZERO) ? "Underlay" : (tmp == ZERO ? "Normal" : tmp > ONE ? "Overlay" : "Popup") );
920 glXGetConfig(display, glxVisual, GLX_BUFFER_SIZE, &tmp);
921 printf( "\tFramebuffer depth ( GLX_BUFFER_SIZE ) : %d\n", tmp );
923 glXGetConfig(display, glxVisual, GLX_DOUBLEBUFFER, &tmp);
924 printf( "\tDoublebuffer ( GLX_DOUBLEBUFFER ) : %s\n",
927 glXGetConfig(display, glxVisual, GLX_DEPTH_SIZE, &tmp);
928 printf( "\tDepth buffer depth ( GLX_DEPTH_SIZE ) : %d\n", tmp );
930 glXGetConfig(display, glxVisual, GLX_STENCIL_SIZE, &tmp);
931 printf( "\tStencil buffer depth ( GLX_STENCIL_SIZE ) : %d\n", tmp );
933 glXGetConfig(display, glxVisual, GLX_STEREO, &tmp);
934 printf( "\tStereo Buffer ( GLX_STEREO ) : %s\n",
937 glXGetConfig(display, glxVisual, GLX_AUX_BUFFERS, &tmp);
938 printf( "\tAuxillary Buffers ( GLX_AUX_BUFFERS) : %d\n\n", tmp );
940 glXGetConfig(display, glxVisual, GLX_RGBA, &tmp);
941 printf( "\tColor mode ( GLX_RGBA ) : %s\n", tmp ? "RGBA" :
944 glXGetConfig(display, glxVisual, GLX_RED_SIZE, &tmp);
945 printf( "\tRed Bits ( GLX_RED_SIZE ) : %d\n", tmp );
947 glXGetConfig(display, glxVisual, GLX_GREEN_SIZE, &tmp);
948 printf( "\tGreen Bits ( GLX_GREEN_SIZE ) : %d\n", tmp );
950 glXGetConfig(display, glxVisual, GLX_BLUE_SIZE, &tmp);
951 printf( "\tBlue Bits ( GLX_BLUE_SIZE ) : %d\n", tmp );
953 glXGetConfig(display, glxVisual, GLX_ALPHA_SIZE, &tmp);
954 printf( "\tAlpha Bits ( GLX_ALPHA_SIZE ) : %d\n\n", tmp );
956 glXGetConfig(display, glxVisual, GLX_ACCUM_RED_SIZE, &tmp);
957 printf( "\tRed Accumulation Bits ( GLX_ACCUM_RED_SIZE ) : %d\n", tmp );
959 glXGetConfig(display, glxVisual, GLX_ACCUM_GREEN_SIZE, &tmp);
960 printf( "\tGreen Accumulation Bits ( GLX_ACCUM_GREEN_SIZE ) : %d\n", tmp );
962 glXGetConfig(display, glxVisual, GLX_ACCUM_BLUE_SIZE, &tmp);
963 printf( "\tBlue Accumulation Bits ( GLX_ACCUM_BLUE_SIZE ) : %d\n", tmp );
965 glXGetConfig(display, glxVisual, GLX_ACCUM_ALPHA_SIZE, &tmp);
966 printf( "\tAlpha Accumulation Bits ( GLX_ACCUM_ALPHA_SIZE ) : %d\n\n", tmp );
970 int find_pixel_format(HTBL_ENTRY * hte, PIXELFORMATDESCRIPTOR * pfd)
972 int iPixelFormat = 0;
975 PIXELFORMATDESCRIPTOR pfd0;
976 char string[ CALL_DEF_STRING_LENGTH ];
978 const int cBits[] = { 32, 24 };
979 const int dBits[] = { 32, 24, 16 };
981 if (call_util_osd_getenv ("CALL_OPENGL_NO_DBF",
982 string, CALL_DEF_STRING_LENGTH))
985 pfd0.nSize = sizeof ( PIXELFORMATDESCRIPTOR );
987 pfd0.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
988 pfd0.dwFlags |= ( DBuffer ) ? PFD_DOUBLEBUFFER : PFD_SUPPORT_GDI;
989 pfd0.iPixelType = PFD_TYPE_RGBA;
993 pfd0.cGreenShift = 0;
997 pfd0.cAlphaShift = 0;
999 pfd0.cAccumRedBits = 0;
1000 pfd0.cAccumGreenBits = 0;
1001 pfd0.cAccumBlueBits = 0;
1002 pfd0.cAccumAlphaBits = 0;
1003 pfd0.cStencilBits = 0;
1004 pfd0.cAuxBuffers = 0;
1005 pfd0.iLayerType = PFD_MAIN_PLANE;
1007 pfd0.dwLayerMask = 0;
1008 pfd0.dwVisibleMask = 0;
1009 pfd0.dwDamageMask = 0;
1013 for (i = 0; i < sizeof(dBits) / sizeof(int); i++) {
1015 pfd0.cDepthBits = dBits[i];
1017 for (j = 0; j < sizeof(cBits) / sizeof(int); j++) {
1019 pfd0.cColorBits = cBits[j];
1020 iPixelFormat = ChoosePixelFormat ( hte -> hDC, &pfd0 );
1023 pfd->cDepthBits = 0;
1024 pfd->cColorBits = 0;
1025 DescribePixelFormat (hte -> hDC, iPixelFormat,
1026 sizeof ( PIXELFORMATDESCRIPTOR ), pfd);
1027 if (pfd->cColorBits >= cBits[j] && pfd->cDepthBits >= dBits[i])
1030 iGood = iPixelFormat;
1033 if (j < sizeof(cBits) / sizeof(int))
1037 if ( !iPixelFormat )
1038 iPixelFormat = iGood;
1040 return iPixelFormat;
1044 /*----------------------------------------------------------------------*/