Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/doc/src/examples/hellogl.qdoc

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the documentation of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    6666
    6767    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).
    6970
    7071    \snippet examples/opengl/hellogl/glwidget.h 1
     
    8586    The rest of the class contains utility functions and variables that are
    8687    used to construct and hold orientation information for the scene. The
    87     \c object variable will be used to hold an identifier for an OpenGL
    88     display list.
     88    \c logo variable will be used to hold a pointer to the QtLogo object which
     89    contains all the geometry.
    8990
    9091    \section1 GLWidget Class Implementation
     
    9697    \section2 Widget Construction and Sizing
    9798
    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.
    100102
    101103    \snippet examples/opengl/hellogl/glwidget.cpp 0
     
    106108    \snippet examples/opengl/hellogl/glwidget.cpp 1
    107109
    108     The destructor ensures that the display list is deleted properly.
     110    In this case nothing requires cleaning up.
    109111
    110112    We provide size hint functions to ensure that the widget is shown at a
     
    140142
    141143    In this example, we reimplement the function to set the background color,
    142     create a display list containing information about the object we want to
     144    create a QtLogo object instance which will contain all the geometry to
    143145    display, and set up the rendering process to use a particular shading model
    144     and rendering flags:
     146    and rendering flags.
    145147
    146148    \section2 Resizing the Viewport
     
    173175    In this example, we clear the widget using the background color that
    174176    we defined in the \l{QGLWidget::initializeGL()}{initializeGL()} function,
    175     set up the frame of reference for the object we want to display, and call
    176     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.
    177179
    178180    \section2 Mouse Handling
     
    197199    a move event is received.
    198200
    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.
    205252
    206253    \section1 Window Class Definition
Note: See TracChangeset for help on using the changeset viewer.