home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / graphics / opengl-faq / part3 < prev   
Encoding:
Text File  |  1995-10-12  |  16.8 KB  |  433 lines

  1. Newsgroups: comp.answers,comp.graphics.api.opengl,news.answers
  2. Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!grapevine.lcs.mit.edu!uhog.mit.edu!news.kei.com!newshost.marcam.com!usc!elroy.jpl.nasa.gov!swrinde!sgigate.sgi.com!fido.asd.sgi.com!sgi!dilow.asd.sgi.com!pho
  3. From: pho@dilow.asd.sgi.com (Paul Ho)
  4. Subject: OpenGL Frequently Asked Questions (FAQ) [3/3]
  5. Message-ID: <DFtAp9.Jp5@sgi.sgi.com>
  6. Followup-To: poster
  7. Last-Modified: 1995 September 8
  8. Summary: This contains a list of Frequently Asked Questions about OpenGL (R)
  9. Keywords: FAQ
  10. Sender: pho@dilow.asd.sgi.com
  11. Reply-To: pho@dilow.asd.sgi.com
  12. Organization: Silicon Graphics Inc.
  13. Posting-Frequency: twice a month
  14. Date: Mon, 2 Oct 1995 08:10:21 GMT
  15. Approved: mailnews@sgi.sgi.com
  16.  
  17. Archive-Name: graphics/opengl-faq/part3
  18. Lines: 412
  19. Xref: senator-bedfellow.mit.edu comp.answers:14597 comp.graphics.api.opengl:1184 news.answers:54157
  20.  
  21. The FAQ has been split into 3 parts.
  22. This is Part 3 of 3.
  23.  
  24. ------
  25. Subject:  Q22:  Where can I find OpenGL source code examples?  
  26. For instance, where is an example which combines
  27. OpenGL with Motif, using the Motif widget?
  28.  
  29. You can get the source code examples which are found in the
  30. OpenGL Programming Guide via anonymous, public ftp from
  31. ftp://sgigate.sgi.com/pub/opengl/opengl.tar.Z
  32.  
  33. Mark Kilgard has created an ftp site for source code, which is
  34. part of his articles in the X Journal magazine.  This includes
  35. the GLUT toolkit (version 2.0) and OpenGL with Motif examples.
  36. The directory is:
  37. ftp://sgigate.sgi.com/pub/opengl/xjournal
  38.  
  39. Some contributed source code of useful tools for developing
  40. OpenGL code can be found on
  41. ftp://sgigate.sgi.com/pub/opengl/contrib
  42. Source code found here includes:
  43.     isfast--compares the performance of OpenGL states 
  44.     samples--more OpenGL program examples
  45.     toogl--helps port IRIS GL code to OpenGL
  46.     xglinfo--display information on X visuals extended for OpenGL
  47.     xscope--examines OpenGL protocol sent to an extended X server 
  48.  
  49. ------
  50. Subject:  Q23:  How do I contribute OpenGL code examples to a publicly
  51. accessible archive?
  52.  
  53. A:  To contribute to the public OpenGL archive, send mail to
  54. opengl-contrib@sgi.com.  Your mail should contain:
  55.  
  56.     The material to be archived, or instructions for obtaining it.
  57.  
  58.     An announcement suitable for posting to comp.graphics.opengl.
  59.  
  60. SGI will place the material in the opengl/contrib directory on
  61. sgigate.sgi.com and post the announcement to this newsgroup.
  62.  
  63. To retrieve something from the archive, use anonymous ftp to
  64. sgigate.sgi.com.  Once connected, cd to the directory OpenGL.
  65. (Case is significant.)  Currently there are two subdirectories:
  66.  
  67.     doc
  68.     Manual pages for OpenGL and related libraries.
  69.  
  70.     contrib
  71.     Contributions from the public.  
  72.  
  73. Note that all contributions are distributed as-is; neither SGI nor the
  74. other companies on the OpenGL Architecture Review Board make any
  75. legally valid claims about the robustness or usefulness of this software.
  76.  
  77. If you do not have access to anonymous ftp, consider using an
  78. "ftp-by-mail" server.  For information on one such server, send mail
  79. to ftpmail@decwrl.dec.com with a message body containing only the word
  80. "help".
  81.  
  82. ------
  83. Subject:  Q24:  What is the GLUT toolkit?  Where do I get it?
  84.  
  85. GLUT is a portable toolkit which performs window and event 
  86. operations to support OpenGL rendering.
  87.  
  88. GLUT version 2.0 has:
  89.   o  window functions, including multiple windows for OpenGL rendering
  90.   o  callback driven event processing
  91.   o  sophisticated input devices, including dials and buttons box, 
  92.      tablet, Spaceball(TM)
  93.   o  idle routines and timers
  94.   o  a simple cascading pop-up menu facility
  95.   o  routines to generate wire and solid objects
  96.   o  bitmap and stroke fonts
  97.   o  request and queries for multisample and stereo windows
  98.   o  OpenGL extension query support
  99.  
  100. The version 2 functionality is fully backward compatible
  101. with the version 1 functionality.
  102.  
  103. The specification, source code (including FORTRAN bindings), 
  104. and articles for GLUT (Graphics Library Utility Toolkit) is in:
  105. URL ftp://sgigate.sgi.com/pub/opengl/xjournal/GLUT
  106.  
  107. This distribution of GLUT should compile on:
  108.   o  DEC Alpha workstation running OSF/1 with Open3D layered product
  109.   o  IBM RS/6000 workstations running AIX with OpenGL support
  110.   o  SGI workstation running IRIX 5.2 or higher supporting OpenGL
  111.   o  Template Graphics Software's OpenGL for Sun workstations
  112.   o  Mesa 1.1 for Unix workstations.
  113.  
  114. ------
  115. Subject:  Q25:  What is the relationship between IRIS GL and OpenGL?
  116. Is OpenGL source code or binary code compatible with IRIS GL?
  117.  
  118. A:  IRIS GL is the predecessor to OpenGL.  After other implementors
  119. had experience trying to port the IRIS GL to their own machines, it
  120. was learned that the IRIS GL was too tied to a specific window system
  121. or hardware.  Based upon consultations with several implementors,
  122. OpenGL is much more platform independent.
  123.  
  124. IRIS GL is being maintained and bugs will be fixed, but SGI will no
  125. longer add enhancements.  OpenGL is now the strategic interface for
  126. 3-D computer graphics.
  127.  
  128. OpenGL code is neither binary nor source code compatible with IRIS
  129. GL code.  It was decided to bite the bullet at this time to make
  130. OpenGL incompatible with IRIS GL and fix EVERYTHING that made IRIS GL
  131. difficult to port or use.  For example, the gl prefix has been added
  132. to every command:  glVertex(), glColor(), etc.
  133.  
  134. ------
  135. Subject:  Q26:  Why should I port my IRIS GL application to OpenGL?
  136.  
  137. SGI will be maintaining the old IRIS GL, but not enhancing it.  
  138. OpenGL is the API of choice on all new SGI machines.
  139.  
  140. OpenGL has no subsets.  You can use the same functionality
  141. on all machines from SGI or from other vendors.
  142.  
  143. OpenGL is better integrated with the X Window System than
  144. the old IRIS GL.  For example, you can mix OpenGL and X
  145. or Display PostScript drawing operations in the same window.
  146.  
  147. The OpenGL naming scheme, argument list conventions, and
  148. rendering semantics are cleaner than those of IRIS GL.  This
  149. should make OpenGL code easier to understand and maintain.
  150.  
  151. ------
  152. Subject:  Q27: How much work is it to convert an IRIS GL program to OpenGL?
  153. What are the major differences between them?
  154.  
  155. < from Mason Woo (woo@sgi.com) and Debbie Herrington (debbie@portable.com) >
  156.  
  157. There is a fair amount of work, most of which is in substituting
  158. for window management or input handling routines, for which the 
  159. equivalents are not OpenGL, but the local window system, such as
  160. the X Windows System or Windows NT.  
  161.  
  162. To help ease the way, port to "mixed model" right away, mixing the
  163. X Window System calls to open and manage windows, cursors, and color
  164. maps and read events of the window system, mouse and keyboard.  
  165. You can do that now with IRIS GL, if you are running IRIX 4.0.  
  166.  
  167. In the X Window System, display mode choices (such as single or 
  168. double buffering, color index or RGBA mode) must be declared before 
  169. the window is initially opened.  You may also substitute for other
  170. IRIS GL routines, such as using a OSF/Motif menu system, in place of
  171. the IRIS GL pop-up menus.  You should use glXUseXFont(), whenever 
  172. you were using the font manager with IRIS GL.
  173.  
  174. OpenGL uses standard, predictable naming conventions, which required
  175. that all names have been changed from IRIS GL.  The OpenGL
  176. naming scheme uses unique prefixes, suffixes, and capitalization to
  177. help prevent potential conflicts among application, system, and
  178. library routine names.
  179.  
  180. And all routine names have changed,
  181. at least, minimally; for example:  ortho() is now glOrtho(). 
  182.  
  183. Tables for states such as lighting or line and polygon stipples will 
  184. be gone.  Instead of using a def/set or def/bind sequence to load a
  185. table, you turn on the state with glEnable() and also declare the
  186. current values for that state.
  187.  
  188. Colors are best stored as floating point values, scaled from 0.0 to
  189. 1.0 (0% to 100%).  Alpha is fully integrated in the RGBA mode and
  190. at least source alpha will be available on all OpenGL implementations.
  191. OpenGL will not arbitrarily limit the number of bits per color to 8.
  192. Clearing the contents of buffers no longer uses the current color, but
  193. a special "clearing" color for each buffer (color, depth, stencil, and
  194. accumulation).
  195.  
  196. The transformation matrix has changed.  In OpenGL, there is no
  197. single matrix mode.  Matrices are now column-major and are post-multiplied,
  198. although that does NOT change the calling order of these routines from
  199. IRIS GL to OpenGL.  OpenGL's glRotate*() now allows for a rotation
  200. around an arbitrary axis, not just the x, y, and z axes.  lookat() 
  201. of IRIS GL is now gluLookAt(), which takes an up vector value, not
  202. merely a twist.  There is no polarview() in OpenGL, but a series
  203. of glRotate*()s and glTranslate*()s can do the same thing.
  204.  
  205. There are no separate depth cueing routines in OpenGL.  Use linear fog.
  206.  
  207. Feedback and selection (picking) return values, which are different
  208. from those found on any IRIS GL implementation.  For selection and
  209. picking, depth values will be returned for each hit.  In OpenGL, feedback 
  210. and selection will now be standardized on all hardware platforms.
  211.  
  212. ------
  213. Subject:  Q28:  When using Xlib, how do I create a borderless window?
  214.  
  215. A:  <from blythe@sgi.com (David Blythe)>
  216.  
  217. Essentially you can create the window with override-redirect 
  218. (see man xcreatewindow) which is the sledgehammer approach or 
  219. you can change the _MOTIF_WM_HINTS property to tell the window 
  220. manager to leave your windows undecorated.
  221.  
  222. <from alex@eagle.hd.hac.com (Alex Madarasz)>
  223.  
  224. Also of note is that the window manager decorations of any client can be
  225. turned off by putting something like the following in the .Xdefaults
  226. file in your home directory - assuming you aren't overriding them in
  227. your app:
  228.  
  229. 4Dwm*ClientAppOrClassName*clientDecoration: none
  230.  
  231. ( see the 4Dwm / mwm man pages for a full description of this resource )
  232.  
  233. ( you must restart the window manager or logout/login for 4Dwm resources
  234. to take effect )
  235.  
  236. "none" will remove all of the window manager decorations - border, title
  237. bar etc.
  238.  
  239. ------
  240. Subject:  Q29:  How do I switch between single buffer and double buffer mode?
  241.  
  242. A:  <from mjk@sgi.com (Mark Kilgard) 
  243.     and blythe@sgi.com (David Blythe)>
  244.  
  245. When using OpenGL with X, switching between a double buffered and 
  246. single buffered window can be accomplished by creating a "container" 
  247. X window and creating two subwindows, one with a double buffer visual, 
  248. the other with a single buffer visual.  Make sure the subwindows are each
  249. the full size of their parent window.
  250.  
  251. You can then use XRaiseWindow or XLowerWindow to change the stacking
  252. order of the two subwindows to switch between double buffering and
  253. single buffering.
  254.  
  255. You will need to create a separate context for each of the
  256. two windows since they have different visual types.  You will need
  257. to make the appropriate window/context pair current when you switch
  258. modes.
  259.  
  260. IRIS GL made it easy to switch between double buffering and single
  261. buffering.  But essentially, IRIS GL implemented the above process
  262. internally.
  263.  
  264. ------
  265. Subject:  Q30:  On my machine, it appears that glXChooseVisual
  266. is only able to match double-buffered visuals.  I want to have more
  267. bits of color resolution, so how do I render in single buffer mode?
  268.  
  269. A:  <from mjk@sgi.com (Mark Kilgard)>
  270.  
  271. On mid- to low-end machines with double buffer hardware, you'll
  272. probably find you get twice as much color resolution using a single
  273. buffer visual.  But if there is no hardware double buffering support,
  274. the double buffered and single buffered visuals are generally the
  275. same depth (the back buffer is "carved" out of software).
  276.  
  277. Search again for a double buffered visual.  If you find one,
  278. use it instead.  Call glDrawBuffer(GL_FRONT) though to make sure
  279. you are drawing to the front buffer (the default for a double
  280. buffered visual is to draw into the back buffer).
  281.  
  282. ------
  283. Subject:  Q31:  I've got a 24-bit machine, but my OpenGL windows
  284. are not using the full color resolution.  What's wrong?  My
  285. program looks fine on one machine, but the depth buffer doesn't work
  286. on another.  What's wrong?
  287.  
  288. A:  <from mjk@sgi.com (Mark Kilgard) and woo@sgi.com (Mason Woo)> 
  289.  
  290. An unfortunate (but documented) semantic of glXChooseVisual is
  291. that if you don't request GLX_RED_SIZE, GLX_GREEN_SIZE, or
  292. GLX_BLUE_SIZE, glXChooseVisual assumes zero for these parameters
  293. which means pick the visual with the _smallest_ amount of red,
  294. green, and blue that matches the other visual attributes.  Make
  295. sure you ask for at least 1 bit of GLX_RED_SIZE, GLX_GREEN_SIZE,
  296. and GLX_BLUE_SIZE.  If these configuration parameters are
  297. non-zero, it matches the visual with the _largest_ amount of red,
  298. green, and blue with at least 1 bit of each (probably what you
  299. want).
  300.  
  301. Similarly, if you don't request GLX_DEPTH_SIZE, you may get a
  302. visual with zero bits of depth buffer.  Some systems may have few
  303. visuals available, and those visuals all have at least 1 bit of
  304. depth buffer.  On other systems, there may be dozens of visuals
  305. available, some with zero bits for the depth buffer.  In short,
  306. if hidden surface removal appears to fail, check to see if you
  307. have explicitly specified any bits of depth buffer you have requested.
  308. Also check to see what visual you have received.
  309.  
  310. ------
  311. Subject:  Q32:  What information is available about OpenGL extensions?
  312.  
  313. A:  Examples of extensions include vertex arrays (calling several vertexes
  314. or related data, such as normals or colors, with a single function call),
  315. blending of constant colors, polygon offset (multiple coplanar polygons 
  316. can be rendered without interaction), 
  317.  
  318. Procedure names and tokens for OpenGL extensions are either suffixed
  319. with EXT or a vendor-specific acronym:  such as SGI for Silicon Graphics
  320. machines, or INGR for Intergraph.  Also note that Silicon Graphics 
  321. extensions to OpenGL are suffixed to indicate whether they will be 
  322. available on all machines (SGI), on just a subset of machines (SGIS), 
  323. or are very experimental and may become unavailable or completely
  324. changed (SGIX).  
  325.  
  326. Vendors are encouraged to add extension information to their 
  327. documentation.  For Silicon Graphics, extension information is 
  328. summarized on the glIntro man page.  
  329.  
  330. ------
  331. Subject:  Q33:  How do I make shadows in OpenGL?
  332.  
  333. A:  There are no individual routines to control shadows nor
  334. an OpenGL state for shadows.  However, code can be written
  335. to render shadows.
  336.  
  337. <from woo@sgi.com (Mason Woo)> 
  338.  
  339. To project a shadow onto a flat plane (such as in the insect
  340. demo), draw the stippled object, flattened using matrix transformations.
  341. The easiest way to flatten an object is to use the scale function.
  342. For example, use glScalef(1., 0., 1.) to create from an infinite light
  343. shining straight down the y axis.  A transformation matrix 
  344. can be used to cast a shadow from an infinite or local light source
  345. in an arbitrary direction.  See the article:
  346.  
  347.     Thant Tessman, "Casting Shadows on Flat Surfaces,"
  348.     IRIS Universe, Winter, 1989.
  349.  
  350. <from shreiner@sgi.com (Dave Shreiner)>
  351.  
  352. Check out the fast shadow and projective texture multi-pass
  353. algorithms for producing realistic shadows using texture mapping.
  354. See the SIGGRAPH paper:
  355.  
  356.     Mark Segal, Carl Korobkin, et al.
  357.     "Fast Shadows and Lighting Effects using Texture Mapping"
  358.     1992 SIGGRAPH Proceedings
  359.  
  360. ------
  361. Subject:  Q34:  How can I use 16 bit X fonts?
  362.  
  363. A:  <from James A. ("Jim") Miller>
  364.  
  365. Here is some code that will load any font into the server and use glXUseXFont
  366. to build the display lists for you (this does work with 16 bit fonts, it has
  367. been tested on IBM, DEC and SGI machines at an OpenGL interop testing).
  368. Once your display lists are created for each character, you can use the same
  369. basic logic to figure out which characters are valid (using first, last,
  370. firstrow and lastrow in the sample code to get :
  371. firstchar = 256 * firstrow + first
  372. lastchar = 256 * lastrow + last ) and use glCallList with those characters 
  373. to print them out.
  374.  
  375. static int LoadFont(char *fontName)
  376. {
  377.     Font id;
  378.     int first, last, firstbitmap, i;
  379.     GLuint base;
  380.     Display *display=0;
  381.     int firstrow, lastrow;
  382.     int maxchars;
  383.  
  384.     tkGetSystem(TK_X_DISPLAY, &display);
  385.  
  386.     fontInfo = XLoadQueryFont(display, fontName);
  387.     if (fontInfo == NULL) {
  388.         return 0;
  389.     }
  390.     id = fontInfo->fid;
  391.     /*
  392.      * First and Last char in a row of chars
  393.      */
  394.     first = (int)fontInfo->min_char_or_byte2;
  395.     last = (int)fontInfo->max_char_or_byte2;
  396.     /*
  397.      * First and Last row of chars, important for multibyte charset's
  398.      */
  399.     firstrow = (int)fontInfo->min_byte1;
  400.     lastrow = (int)fontInfo->max_byte1;
  401.     /*
  402.      * How many chars in the charset
  403.      */
  404.     maxchars = 256 * lastrow + last;
  405.     base = glGenLists(maxchars+1);
  406.     if (base == 0) {
  407.         return 0;
  408.     }
  409.     /*
  410.      * Get offset to first char in the charset
  411.      */
  412.     firstbitmap = 256 * firstrow + first;
  413.     /*
  414.      * for each row of chars, call glXUseXFont to build the bitmaps.
  415.      */
  416.     for(i=firstrow; i<=lastrow; i++)
  417.     {
  418.         glXUseXFont(id, firstbitmap, last-first+1, base+firstbitmap);
  419.         firstbitmap += 256;
  420.     }
  421.     return base;
  422. }
  423.  
  424. ------
  425. Subject:  Q35:  What's in the new GLU 1.2 tesselator?
  426.  
  427. A:  <from Mark Kilgard>
  428.  
  429. Our friends at Digital have the answers:
  430.     http://www.digital.com:80/pub/doc/opengl/opengl_new_glu.html
  431.  
  432.  
  433.