Changeset 561 for trunk/doc/src/examples/hellogl.qdoc
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/doc/src/examples/hellogl.qdoc
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the documentation of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 66 66 67 67 We use a destructor to ensure that any OpenGL-specific data structures 68 are deleted when the widget is no longer needed. 68 are deleted when the widget is no longer needed (although in this case nothing 69 needs cleaning up). 69 70 70 71 \snippet examples/opengl/hellogl/glwidget.h 1 … … 85 86 The rest of the class contains utility functions and variables that are 86 87 used to construct and hold orientation information for the scene. The 87 \c object variable will be used to hold an identifier for an OpenGL88 display list.88 \c logo variable will be used to hold a pointer to the QtLogo object which 89 contains all the geometry. 89 90 90 91 \section1 GLWidget Class Implementation … … 96 97 \section2 Widget Construction and Sizing 97 98 98 The constructor provides default rotation angles for the scene, initializes 99 the variable used for the display list, and sets up some colors for later use. 99 The constructor provides default rotation angles for the scene, sets 100 the pointer to the QtLogo object to null, and sets up some colors for 101 later use. 100 102 101 103 \snippet examples/opengl/hellogl/glwidget.cpp 0 … … 106 108 \snippet examples/opengl/hellogl/glwidget.cpp 1 107 109 108 The destructor ensures that the display list is deleted properly.110 In this case nothing requires cleaning up. 109 111 110 112 We provide size hint functions to ensure that the widget is shown at a … … 140 142 141 143 In this example, we reimplement the function to set the background color, 142 create a display list containing information about the object we wantto144 create a QtLogo object instance which will contain all the geometry to 143 145 display, and set up the rendering process to use a particular shading model 144 and rendering flags :146 and rendering flags. 145 147 146 148 \section2 Resizing the Viewport … … 173 175 In this example, we clear the widget using the background color that 174 176 we defined in the \l{QGLWidget::initializeGL()}{initializeGL()} function, 175 set up the frame of reference for the object we want to display, and call176 the display list containing the rendering commands for the object.177 set up the frame of reference for the geometry we want to display, and 178 call the draw method of the QtLogo object to render the scene. 177 179 178 180 \section2 Mouse Handling … … 197 199 a move event is received. 198 200 199 \section2 Utility Functions 200 201 We have omitted the utility functions, \c makeObject(), \c quad(), 202 \c extrude(), and \c normalizeAngle() from our discussion. These can be 203 viewed in the quoted source for \c glwidget.cpp via the link at the 204 start of this document. 201 \section1 QtLogo Class 202 203 This class encapsulates the OpenGL geometry data which will be rendered 204 in the basic 3D scene. 205 206 \snippet examples/opengl/shared/qtlogo.h 0 207 208 The geometry is divided into a list of parts which may be rendered in 209 different ways. The data itself is contained in a Geometry structure that 210 includes the vertices, their lighting normals and index values which 211 point into the vertices, grouping them into faces. 212 213 \snippet examples/opengl/shared/qtlogo.cpp 0 214 215 The data in the Geometry class is stored in QVector<QVector3D> members 216 which are convenient for use with OpenGL because they expose raw 217 contiguous floating point values via the constData() method. Methods 218 are included for adding new vertex data, either with smooth normals, or 219 facetted normals; and for enabling the geometry ready for rendering. 220 221 \snippet examples/opengl/shared/qtlogo.cpp 1 222 223 The higher level Patch class has methods for accumulating the geometry 224 one face at a time, and treating collections of faces or "patches" with 225 transformations, applying different colors or smoothing. Although faces 226 may be added as triangles or quads, at the OpenGL level all data is 227 treated as triangles for compatibility with OpenGL/ES. 228 229 \snippet examples/opengl/shared/qtlogo.cpp 2 230 231 Drawing a Patch is simply acheived by applying any transformation, 232 and material effect, then drawing the data using the index range for 233 the patch. The model-view matrix is saved and then restored so that 234 any transformation does not affect other parts of the scene. 235 236 \snippet examples/opengl/shared/qtlogo.cpp 3 237 238 The geometry is built once on construction of the QtLogo, and it is 239 paramaterized on a number of divisions - which controls how "chunky" the 240 curved section of the logo looks - and on a scale, so larger and smaller 241 QtLogo objects can be created without having to use OpenGL scaling 242 (which would force normal recalculation). 243 244 The building process is done by helper classes (read the source for full 245 details) which only exist during the build phase, to assemble the parts 246 of the scene. 247 248 \snippet examples/opengl/shared/qtlogo.cpp 4 249 250 Finally the complete QtLogo scene is simply drawn by enabling the data arrays 251 and then iterating over the parts, calling draw() on each one. 205 252 206 253 \section1 Window Class Definition
Note:
See TracChangeset
for help on using the changeset viewer.