1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/opengl-x11-overlays.doc:36 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>How to use X11 overlays with the Qt OpenGL extension</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>How to use X11 overlays with the Qt OpenGL extension</h1>
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | <p> X11 overlays are a powerful mechanism for drawing
|
---|
37 | annotations etc., on top of an image without destroying it, thus saving
|
---|
38 | a great deal of image rendering time. For more information, consult the highly
|
---|
39 | recommended book <em>OpenGL Programming for the X Window System</em> (Mark
|
---|
40 | Kilgard, Addison Wesley Developers Press 1996).
|
---|
41 | <p> <b>Warning:</b> From version 5.0 onwards, the Qt OpenGL Extension includes
|
---|
42 | direct support for the use of OpenGL overlays. For many uses of
|
---|
43 | overlays, this makes the technique described below redundant. See the
|
---|
44 | <a href="opengl-overlay-example.html">overlay</a> example program. The
|
---|
45 | following is a discussion on how to use non-QGL widgets in overlay
|
---|
46 | planes.
|
---|
47 | <p> In the typical case, X11 overlays can easily be used together with the
|
---|
48 | current version of Qt and the Qt OpenGL Extension. The following
|
---|
49 | requirements apply:
|
---|
50 | <p> <ol type=1>
|
---|
51 | <li> Your X server and graphics card/hardware must support overlays.
|
---|
52 | For many X servers, overlay support can be turned on with
|
---|
53 | a configuration option; consult your X server installation
|
---|
54 | documentation.
|
---|
55 | <p> <li> Your X server must (be configured to) use an overlay visual as the
|
---|
56 | default visual. Most modern X servers do this, since this has the
|
---|
57 | added advantage that pop-up menus, overlapping windows etc., will
|
---|
58 | <em>not</em> destroy underlying images in the main plane, thereby
|
---|
59 | avoiding expensive redraws.
|
---|
60 | <p> <li> The best (deepest) visual for OpenGL rendering is in the main
|
---|
61 | plane. This is the normal case. Typically, X servers that support
|
---|
62 | overlays provide a 24 bit deep TrueColor visual in the main plane,
|
---|
63 | and an 8 bit PseudoColor (default) visual in the overlay plane.
|
---|
64 | </ol>
|
---|
65 | <p> The provided example program <a href="opengl-overlay-example.html">X11
|
---|
66 | overlay</a> will check for these and report if anything is wrong.
|
---|
67 | See <a href="#x11visuals">About X11 Visuals</a>, below for more
|
---|
68 | information.
|
---|
69 | <p> <h2> How it works
|
---|
70 | </h2>
|
---|
71 | <a name="1"></a><p> Given the above, a <a href="qglwidget.html">QGLWidget</a> will by default use the main plane
|
---|
72 | visual, while all other widgets will use the overlay visual. Thus, we
|
---|
73 | can place a normal widget on top of the QGLWidget, and do drawing on
|
---|
74 | it, without destroying the image in the OpenGL window. In other words,
|
---|
75 | we can use all the drawing capabilities of <a href="qpainter.html">QPainter</a> to draw the
|
---|
76 | annotations, rubberbands, etc. For the typical use of overlays,
|
---|
77 | this is much easier than using OpenGL for rendering the annotations.
|
---|
78 | <p> An overlay plane has a specific color called the transparent
|
---|
79 | color. Pixels drawn in this color will not be visible; instead the
|
---|
80 | underlying OpenGL image will show through. In the example program
|
---|
81 | <a href="opengl-overlay-example.html">X11 overlay</a>, the file
|
---|
82 | <tt>main.cpp</tt> contains a routine that returns a <a href="qcolor.html">QColor</a> containing the
|
---|
83 | transparent color. For the overlay widget, you will typically want to
|
---|
84 | set the background color to the transparent color, so that the OpenGL
|
---|
85 | image shows through except where explicitly overpainted.
|
---|
86 | <p> Note: to use this technique, you must not use the "ManyColor" or
|
---|
87 | "TrueColor" ColorSpec for <a href="qapplication.html">QApplication</a>, because this will force
|
---|
88 | the normal Qt widgets to use a TrueColor visual, which will typically
|
---|
89 | be in the main plane, not in the overlay plane as desired.
|
---|
90 | <p> <a name="x11visuals"></a>
|
---|
91 | <h2> About X11 visuals
|
---|
92 | </h2>
|
---|
93 | <a name="2"></a><p> The utilities directory contains two small programs that can help you
|
---|
94 | determine the capabilities of your X server. These programs are from
|
---|
95 | the OpenGL book mentioned above, see utilities/NOTICE for copyright
|
---|
96 | information. The full set of example programs from this book is
|
---|
97 | available at <a href="ftp://ftp.sgi.com/pub/opengl/opengl_for_x/">ftp://ftp.sgi.com/pub/opengl/opengl_for_x/</a>.
|
---|
98 | <p> <tt>glxvisuals</tt> will list all the GL-capable visuals the X server
|
---|
99 | provides, together with the depth and other GL-specific information
|
---|
100 | for each. Note especially the column "lvl"; a number in this column
|
---|
101 | means the visual is in an overlay plane.
|
---|
102 | <p> <tt>sovinfo</tt> will list all available visuals, and provides special
|
---|
103 | transparency information for overlay visuals.
|
---|
104 | <p> The <a href="opengl-overlay-example.html">X11 overlay</a> example
|
---|
105 | program will output what visual is used for the normal Qt widgets, and
|
---|
106 | what visual is used by the <a href="qglwidget.html">QGLWidget</a>.
|
---|
107 | <p>
|
---|
108 | <!-- eof -->
|
---|
109 | <p><address><hr><div align=center>
|
---|
110 | <table width=100% cellspacing=0 border=0><tr>
|
---|
111 | <td>Copyright © 2007
|
---|
112 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
113 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
114 | </table></div></address></body>
|
---|
115 | </html>
|
---|