QGLViewer - Technical FAQ

See also the General FAQ

The black screen is back !

"I copy-pasted my code in your draw() function, and the screen remains black. I hate openGL !"
The classical openGL black screen is not supported by libQGLViewer. There are two possible reasons for your problem, as detailed in the introduction: Press 'A' to display the world axis and double click the mouse middle button to make the camera fit the scene. You should at least see the axis.

It still looks strange

If your are still unable to get the results you had before switching to libQGLViewer, check that your init function sets the default openGL state with glEnable(GL_LIGHTING, GL_FOG, ...) as you did before. Also note that libQGLViewer slightly changes the default openGL state : see the QGLViewer::initializeGL() documentation.

How are mouse events interpreted ?

The mouse events are sent to three possible receivers : the camera, the manipulatedFrame or a MouseGrabber, depending on the context. By default, the mouse is used to move the camera, as in classical 3D viewers. With a specific state key (default is Control), it is the manipulatedFrame that receives the mouse events. The state keys can of course be customized. The MouseGrabber is described below.

What is a ManipulatedFrame ?

A ManipulatedFrame is a Frame (position and orientation in 3D) that can directly be moved with the mouse. It is used to move objects in your scene, see the ManipulatedFrame example.

What are frame hierarchies ?

The Frame class represents a position and orientation in 3D. These frames can be organized in a hierarchy and convenient conversion functions are provided. The openGL code should reflect this organization, as is detailed in the Frame detailed description.

How can I use several ManipulatedFrame ?

You need to create a structure (typically a vector) that holds the pointers to the different ManipulatedFrame you have created. Use setManipulatedFrame() to decide which of them is active at a given time. See the Luxo example for an illustration.

What are MouseGrabbers ?

MouseGrabber is an empty interface for any object that may grab the mouse focus. Many usages are possible, opening the way to innovant reactive user interfaces. Note that ManipulatedFrame are MouseGrabbers, see the MouseGrabber example for an illustration.

How can I redefine the mouse/keyboard behavior ?

The keyboardAndMouse example illustrates this in details. See also the mouse and keyboard pages.

How can I use several viewers ?

Simply create them, as in the multiView example. You may have to connect additionnal signals to synchonize viewers' displays. A ManipulatedFrame displayed by several viewers will typically have its manipulated signal connected to the other viewers updateGL() slots.

How can I measure my application frame rate ?

Press the F key to toggle the frame rate display. In is computed as an average over 30 frames. Since the display is updated only when needed, the frame rate is valid only when you display in a loop (such as when you move the camera with the mouse). If you want to know the maximum possible frame rate of your machine on a given scene, you should setAnimationPeriod(0) and turn on the animation (by pressing Enter). The display will then be updated as quickly as possible, and the frame rate will be meaningful.

Other questions can be sent by e-mail and will be added to this page. See also the General FAQ.

Valid XHTML 1.0! Valid CSS! Last modified on Friday, June 11, 2004.