home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / sgi / 18358 < prev    next >
Encoding:
Text File  |  1992-12-29  |  4.5 KB  |  141 lines

  1. Newsgroups: comp.sys.sgi
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uimrl7.mrl.uiuc.edu!ercolessi
  3. From: ercolessi@uimrl3.mrl.uiuc.edu (furio ercolessi)
  4. Subject: Re: winopen() with no graphics
  5. References:  <BzzHC2.9AM@sidefx.uucp>
  6. Message-ID: <BzzusE.n4H@news.cso.uiuc.edu>
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. Reply-To: ercolessi@uimrl3.mrl.uiuc.edu (furio ercolessi)
  9. Organization: MRL - UIUC
  10. Date: Tue, 29 Dec 1992 00:02:37 GMT
  11. Keywords: getgdesc winopen
  12. Lines: 127
  13.  
  14. In article <BzzHC2.9AM@sidefx.uucp>, mark@sidefx.uucp (Mark Elendt) writes:
  15. |>If you have no graphics console and you try to do a winopen(), the
  16. |>call doesn't fail, it actually terminates your process or hangs.
  17. |>Apparently, there is no getgdesc() call to determine whether it is
  18. |>possible to do a winopen() safely.
  19. |>
  20. |>Of course this problem really crops up if an application is run from
  21. |>a dumb terminal or run at night after everyone has logged out.
  22. |>
  23. |>Sometimes, the graphics are nice if the user is using an application
  24. |>interactively, but not necessary if the application is run in batch
  25. |>mode.  Occasionally, the user leaves options on for the interactive
  26. |>graphics when doing batch runs and it would be nice if the program
  27. |>didn't terminate on them.
  28. |>
  29. |>Any ideas?
  30.  
  31. I asked the same question some time ago, and Michael Portuesi
  32. of SGI offered the answer below.   The solution is SGI-specific,
  33. but unfortunately I need to run my program on both SGI and
  34. RS/6000s, so I eventually gave up and just ask the user if
  35. he/she is sitting in front of a GL device, and call winopen() only
  36. if the answer was 'yes'.
  37.  
  38. ---------------------------------------------------
  39. From: portuesi@tweezers.esd.sgi.com (Michael Portuesi)
  40. Newsgroups: comp.sys.sgi,comp.unix.aix
  41. Subject: Re: How to ask GL whether the server is there
  42. Message-ID: <m7f868s@zola.esd.sgi.com>
  43. Date: 18 Jun 92 16:02:19 GMT
  44. Organization: Silicon Graphics, Inc.  Mountain View, CA
  45.  
  46. I know of one solution, but it involves making some Xlib calls.
  47. This is quoted from the current issue of "Pipeline", a publication
  48. of our Customer Support Division.  I've changed the code ever
  49. so slightly for correctness.
  50.  
  51. --------------
  52.  
  53. Determining if an X Server is GL-Capable
  54.  
  55. Since GL capability is not currently implemented as a standard
  56. X extension, there is no standard way to determine if an X
  57. server is GL-capable.  However, there is a "string" that an
  58. application can query the server to determine if it is a Silicon
  59. Graphics X server:
  60.  
  61.     int major_opcode, first_event, first_error;
  62.  
  63.     Bool SGIserver = XQueryExtension(display, "SGI-SUNDRY-NONSTANDARD",
  64.                      &major_opcode,
  65.                      &first_event,
  66.                      &first_error);
  67.  
  68.     if (SGIserver) {
  69.         printf("The display is an SGI X server.\n");
  70.     } else {
  71.         printf("The display is not an SGI X server.\n");
  72.     }
  73.  
  74. The above code is known to work for IRIX 4.0.* releases.  Silicon
  75. Graphics is planning to provide a standard way to query an X
  76. server to determine if it has a GL extension.  The above code
  77. may not work in future IRIX releases.
  78.  
  79. --------------
  80.  
  81. The programming example as printed in the pipeline leaves out
  82. a few details to make it complete.  First, you will need to include
  83. Xlib.h in your code.  You will need to make sure that Xlib.h is
  84. included before gl.h.  Secondly, you will need to open a display
  85. on the X server you're curious about before making the
  86. XQueryExtension call.
  87.  
  88. Here's a self-contained program I wrote based on the above code
  89. fragment, that shows everything you need to do.  Enjoy.
  90.  
  91. /*
  92.  * sgix.c - determine if an X server is a Silicon graphics X server.
  93.  *
  94.  * to compile on an SGI system:
  95.  *
  96.  * cc sgix.c -o sgix -lX11
  97.  *
  98.  */
  99.  
  100. #include <X11/Xlib.h>
  101. #include <stdio.h>
  102.  
  103. main(int argc, char* argv[])
  104. {
  105.     Display* display;
  106.     int major_opcode, first_event, first_error;
  107.     Bool SGIserver;
  108.  
  109.     if (argc > 1) {
  110.         display = XOpenDisplay(argv[1]);
  111.     } else {
  112.     display = XOpenDisplay(NULL);    /* use default DISPLAY env variable */
  113.     }
  114.  
  115.     if (display == NULL) {
  116.     printf("%s: can't open connection.\n", argv[0]);
  117.     exit(1);
  118.     }
  119.  
  120.     SGIserver = XQueryExtension(display, "SGI-SUNDRY-NONSTANDARD",
  121.                 &major_opcode,
  122.                 &first_event,
  123.                 &first_error);
  124.  
  125.     if (SGIserver) {
  126.     printf("The display is an SGI X server.\n");
  127.     } else {
  128.     printf("The display is not an SGI X server.\n");
  129.     }
  130.  
  131.     XCloseDisplay(display);
  132. }
  133.  
  134.  
  135.  
  136. --
  137. Furio Ercolessi
  138. Materials Research Laboratory           |   Intl School for Advanced Studies
  139. Univ. of Illinois at Urbana-Champaign   |   Trieste, Italy
  140. furio@uiuc.edu                          |   furio@sissa.it
  141.