libQGLViewer examples
Introduction
Many pedagogical examples illustrate some functionalities of the viewer and are provided for
understanding and cut and paste. New users should read the introduction
page and the commented example to understand the philosophy of
the library. One should then test the following basic examples:
Basic examples

simpleViewer The simplest application example: 20 lines of code and yet all the power !
|

manipulatedFrame A ManipulatedFrame can be moved with the mouse in the scene.
|

select Selection of scene objects using select() and an GL_SELECT render mode.
|

keyboardAndMouse Shows how to customize your keyboard and mouse bindings.
|
|
Pedagogical examples

animation The animate() function illustrated by a water particle simulation.
|

callback Using the Qt signal-slot mechanism to connect a QGLViewer to your scene.
|

constrainedCamera Constraints applied on the Camera Frame to limit its translation and/or rotation.
|

constrainedFrame Constraints can limit the translation and/or rotation of a (Manipulated)Frame.
|

drawLight The drawLight() function is a light debugging tool.
|

fastDraw The fastDraw() function keeps interactivity even with large scenes.
|

frameTransform Coordinate transformation between different Frames.
|

interface Adding a graphical user interface around a QGLViewer .
|

keyFrames The KeyFrameInterpolator test example.
|

luxo A more complex example that combines ManipulatedFrames , selection and constraints.
|

mouseGrabber MouseGrabber s enable complex mouse interaction.
|

multiSelect Customization of the select() function that enables the selection of several
objects.
|

multiView A multi-view application, with constrained camera displacements.
|

screenCoordSystem A saucers control viewer that illustrates the screen coordinate system feature.
|

spinningFrame SpinningFrame s are handy to create rotations.
|

stereoViewer Simply press S to toggle stereo display (if supported).
|
|
|
|
More complex examples

3dsViewer The LGPL lib3ds library is used to load and display a 3ds scene.
|

agora Implementation of the game of Agora.
|

anaglyph Displays a scene in pseudo-stereo using anaglyph.
|

backgroundImage Displays a background image in the viewer.
|

draw3DText An icosahedron is used to illustrate the draw3DText() function.
|

eventRecorder Records a scenario that can be replayed and converted into a movie.
|

quarto A simulation of the game of Quarto.
|

textureViewer Loads an image file and texture maps a polygon with it.
|

thumbnail Displays an alternative 3D view in a corner thumbnail.
|

x3dViewer The X3DToolkit library is used to load and display an x3d scene.
|
|
|
|
Compilation
Some pre-compiled examples are available for an easy evaluation of the library's functionnalities on
the download page. It is however better to recompile from the
sources to ensure a full compatibility with dependencies.
If you installed the RPM, the examples' source files are in
/usr/share/doc/QGLViewer/examples
and you have to copy the desired example(s)
directories to a place where you have write permission.
If you have downloaded the tarball instead, simply go to the examples
directory. Then,
> cd exampleDirectory
> qmake [PREFIX=...] [INCLUDE_DIR=...] [LIB_DIR=...]
> make
The optional PREFIX, INCLUDE_DIR
and LIB_DIR
parameters are those you used
if you customized your make install
. This can
also be done in the examples
's main directory to compile all the examples.
You may be prompted with an "error while loading shared libraries"
message when trying
to execute an example. You probably forgot to add the libQGLViewer.so
directory to your
default library path. Simply do this (use LD_LIBRARYN32_PATH
instead on some Unix
flavors):
[bash] > export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/Path/To/libQGLViewer
[tcsh] > setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/Path/To/libQGLViewer
Some configurations may require you to add LIBS *= -lXi
in the .pro
file.
Debian users may have to replace -lQGLViewer-1
by -lQGLViewer
(change the
Makefile
or create a link on libQGLViewer.so
in your lib directory).
See also the Qt-Unix and libQGLViewer on Unix installation pages.
The examples' compilation is essentially identical to the one described above in the linux section.
Simply replace the above lines by:
[bash] > export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/Path/To/libQGLViewer
[tcsh] > setenv DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH}:/Path/To/libQGLViewer
You can safely ignore the prebound warning. Building a prebound library creates overlapping address
ranges. This requires further investigations, any help more than welcome.
See also the Qt-Mac and libQGLViewer on Mac installation pages.
Windows users have to compile each example separately, using the Open Qt project * icon. With Visual Studio 6.0, use File-Open workspace to open the
.dsp
generated file.
Qt 2.3 users have to first edit the examples' .pro
files (uncomment and remove end of
file as explained) and have to add /GX /GR
in Project-Settings-C-C++, Project
options before compilation. One should also tune the include and lib paths:
- Add the path to
libQGLViewer-1.3.9
(note there is no trailing QGLViewer
) to your
Project-Properties-C/C++-General-Additional Include Directories *
- Add the path
libQGLViewer-1.3.9\QGLViewer
to your
Linker-General-Additional Library Directories *. Visual 6
users may add Release
(or Debug
) to this path: it must be the directoy
where QGLViewer.lib
is located.
All this should be done automatically if you use a Qt 3.x version.
See also the installation advices for Qt-Windows and libQGLViewer on Windows.
* Names are given in .NET standards, and differ from those of Visual 6.
Here is a correspondance table:
.NET | Visual Studio 6 |
Open Qt Project | Generate Qt Project |
Project-Properties-C/C++-General-Additional Include Directories | Tools-Options-Directories-Include files |
Project-Properties-Linker-General-Additional Library Directories | Tools-Options-Directories-Library files |
Last modified on Wednesday, December 1, 2004.