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
simpleViewer

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

A ManipulatedFrame can be moved with the mouse in the scene.
select
select

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

Shows how to customize your keyboard and mouse bindings.

Pedagogical examples

animation
animation

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

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

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

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

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

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

Coordinate transformation between different Frames.
interface
interface

Adding a graphical user interface around a QGLViewer.
keyFrames
keyFrames

The KeyFrameInterpolator test example.
luxo
luxo

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

MouseGrabbers enable complex mouse interaction.
multiSelect
multiSelect

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

A multi-view application, with constrained camera displacements.
screenCoordSystem
screenCoordSystem

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

SpinningFrames are handy to create rotations.
stereoViewer
stereoViewer

Simply press S to toggle stereo display (if supported).
   

More complex examples

3dsViewer
3dsViewer

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

Implementation of the game of Agora.
anaglyph
anaglyph

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

Displays a background image in the viewer.
draw3DText
draw3DText

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

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

A simulation of the game of Quarto.
textureViewer
textureViewer

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

Displays an alternative 3D view in a corner thumbnail.
x3dViewer
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.

linux 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.


mac 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 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:

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:
.NETVisual Studio 6
Open Qt ProjectGenerate Qt Project
Project-Properties-C/C++-General-Additional Include DirectoriesTools-Options-Directories-Include files
Project-Properties-Linker-General-Additional Library DirectoriesTools-Options-Directories-Library files

Valid XHTML 1.0! Valid CSS! Last modified on Wednesday, December 1, 2004.