home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / examples / opengl / overlay_x11 / README < prev    next >
Encoding:
Text File  |  2001-05-07  |  3.3 KB  |  75 lines

  1.  
  2. -----------------------------------------------------------------------
  3. UPDATE: From version 5.0 onwards, the Qt OpenGL Extension includes
  4. direct support for use of OpenGL overlays. For many uses of overlays,
  5. this makes the technique described below redundant. See the 'overlay'
  6. example program. The following is a discussion on how to use non-QGL
  7. widgets in overlay planes.
  8. -----------------------------------------------------------------------
  9.  
  10. Overlayrubber: An example program showing how to use Qt and Qt OpenGL
  11. Extension with X11 overlay visuals.
  12.  
  13. (Background information for this example can be found in the file
  14.  README.X11-OVERLAYS)
  15.  
  16. The example program has three main parts:
  17.  
  18. GearWidget - a normal, simple QGLWidget; renders the usual
  19. gears. Modified so that it will print a debug message everytime it
  20. redraws (renders) itself. Thus, you can eaily confirm that drawing in
  21. the overlay plane does not cause redrawings in the main plane where
  22. the QGLWidget resides.
  23.  
  24. RubberbandWidget: Very simple standard (non-GL) Qt widget that
  25. implements rubberband drawing. Designed for use in an overlay
  26. plane. It takes the planes' transparent color as a constructor
  27. argument and uses that for its background color. Thus, the widget
  28. itself will be invisible, only the rubberbands it draws will be
  29. visible.
  30.  
  31. main.cpp: Creates a GearWidget and a Rubberbandwidget and puts the
  32. latter on top of the former. Contains a routine that checks that the
  33. default visual is in an overlay plane, and returns the transparent
  34. color of that plane.
  35.  
  36.  
  37. Running it:
  38. -----------
  39.  
  40. Start the overlayrubber executable. Click and drag with the left mouse
  41. button to see rubberband drawing. Observere that the QGLWidget does
  42. not redraw itself (no redraw debug messages are output), still the
  43. image is not destroyed. Marvel at the coolness of X11 overlays!
  44.  
  45.  
  46. Using this technique in a real application
  47. ------------------------------------------
  48.  
  49. For clarity, this example program has been kept very simple. Here are
  50. some hints for real application usage:
  51.  
  52. All normal widgets is in the overlay plane: This means that you can
  53. put all kinds of Qt widgets (your own or provided with Qt) on top of
  54. the OpenGL image (widget), e.g. pushbuttons etc., and they can be
  55. moved, resized, or removed without destroying the OpenGL image.
  56.  
  57. Using together with geometry management: The QLayout classes will not
  58. allow you to put one widget (the overlay) on top of another (the
  59. OpenGL widget); that would defy the whole purpose of the automatic
  60. layout. The solution is to add just one of them to the QLayout object.
  61. Have it keep a pointer to the other (i.e. the QGLWidget knows about
  62. its overlay widget or vice versa). Implement the resizeEvent() method
  63. of the widget you put in the layout, and make it call setGeometry() on
  64. the other widget with its own geometry as parameters, thus keeping the
  65. two widgets' geometries synchronized.
  66.  
  67. Using together with QPalette and QColorGroup: In stead of the somewhat
  68. simplistic setBackgroundColor( transparentColor ), you can use Qt's
  69. QPalette system for having your overlay widgets use transparent color
  70. for what you want. This way, the normal Qt widgets can be used as
  71. overlays for fancy effects, just create a palette for them with the
  72. transparent color for the wanted color roles, e.g. Background and
  73. Base, in the Normal and/or Active modes. This way, you can create
  74. see-through QPushButtons etc.
  75.