#include <glworldviewer.h>
Inheritance diagram for GLWorldViewer:

Public Member Functions | |
| GLWorldViewer (const GLScene *s, GLScreenViewer *screenViewer, QWidget *parent) | |
| GLWorldViewer (const GLScene *s, GLScreenViewer *screenViewer, const QGLFormat &format, QWidget *parent) | |
| void | resetCamera () |
| bool | autoGLClearEnabled () const |
| bool | autoGLFlushEnabled () const |
| bool | frustumIsDrawn () const |
| void | setDrawFrustum (bool enable) |
| void | setAutoGLClearEnabled (bool enable) |
| void | setAutoGLFlushEnabled (bool enable) |
| qglviewer::Vec | backgroundColor () const |
| void | getBackgroundColor (float &r, float &g, float &b) const |
| void | getBackgroundColor (QColor &c) const |
| void | setBackgroundColor (const qglviewer::Vec &color) |
| void | setBackgroundColor (float r, float g, float b) |
| void | setBackgroundColor (const QColor &c) |
Protected Member Functions | |
| void | sharedInit () |
| void | drawFrustum (GLdouble *inverseProjectionMatrix) |
| virtual void | init () |
| virtual void | draw () |
| virtual void | preDraw () |
| virtual void | postDraw () |
| virtual void | keyPressEvent (QKeyEvent *e) |
| virtual void | keyReleaseEvent (QKeyEvent *e) |
| virtual void | mousePressEvent (QMouseEvent *e) |
| virtual void | mouseReleaseEvent (QMouseEvent *e) |
| virtual void | mouseDoubleClickEvent (QMouseEvent *e) |
| virtual void | mouseMoveEvent (QMouseEvent *e) |
| void | mouseEventTranslator (QMouseEvent *e, QEvent::Type mouseEventType) |
| GLboolean | invert (const GLdouble src[16], GLdouble inverse[16]) |
Protected Attributes | |
| const GLScene * | myScene |
| GLScreenViewer * | myScreenViewer |
| const GLdouble * | myScreenViewersProjection |
| bool | reinitRequired |
| qglviewer::Vec | myBackgroundColour |
| bool | autoGLClear |
| bool | autoGLFlush |
| bool | frustumEnabled |
| int | extModifierKey |
Note: This viewer relies upon / requires a pointer to a valid GLScreenViewer instance. This is because it requires its post-draw projection matrix values, so that it can draw the projection frustum. The reason that we don't know these values is because we deliberately prevent modifications to be made to the projection when we draw the scene, as we want to DRAW the projection (as the frustum), not EXECUTE it.
Note: The scene is reinitialized EVERY time GLWorldViewer::draw() is called, as the camera has an effect on the initizliation commands and the most common reason that GLWorldViewer::draw() will be called is because the camera has been repositioned / rotated, etc. This behavior is unlike GLScreenViewer::draw()'s.
Note: OpenGL viewports are NOT supported by this viewer, as they would not make sense in this context. Hence glViewport commands will be ignored when the scene is executed/drawn.
Note: Display lists are NOT used to cache the initialization and display commands, as they would enfore too many limitations. For example, many OpenGL commands cannot be placed in display lists, such as those that pass parameters by reference (as they may be out of scope). It would also prevent the user from working with display lists themselves.
Note: The GLWorldViewer::invert() method, used to get the inverse of a 4x4 matrix actually came from Nate Robins' OpenGL Tutors.
I contacted him via email (nate@pobox.com) on Sunday 25, January 2004 and got the OK from him to use it before I went ahead and used it.
Beginning of the source code file projection.c:
projection.c
Nate Robins, 1997
Tool for teaching about OpenGL projections.
|
||||||||||||||||
|
Constructor. See the class's detailed description for why we need a pointer to an instance of GLScreenViewer. |
|
||||||||||||||||||||
|
Constructor. This constructor takes a QGLFormat parameter, so that special format options such as double buffering can be enabled and disabled. See the class's detailed description for why we need a pointer to an instance of GLScreenViewer. |
|
|
|
|
|
|
|
|
Reimplemented, due to GLWorldViewer::setBackgroundColor() having to be reimplemented. Reimplemented from QGLViewer. |
|
|
Execute the OpenGL scene, though with some possible modifications, see below. Note: The scene is reinitialized EVERY time this is called, as the camera has an effect on the initizliation commands and the most common reason that this will be called is because the camera has been repositioned / rotated, etc. This behaviour is unlike GLScreenViewer::draw()'s. Note: We prevent modifications to projection from being executed by the scene, as we will be DRAWING the projection in the form of its frustum instead in GLWorldViewer::postDraw(). Note: OpenGL viewports are NOTE supported by this viewer, as they would not make sense in this context. Hence glViewport commands will be ignored. Note: This method will perfrom: glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) Reimplemented from QGLViewer. |
|
|
Draw the viewing frustum for a given projection matrix. Note: This method takes the INVERSE of the projection matrix as its parameter. |
|
|
|
|
|
Same as backgroundColor(), but result is returned as a QColor attribute. |
|
||||||||||||||||
|
Same as backgroundColor(), but result is returned as three floats. Reimplemented from QGLViewer. |
|
|
Initialize OpenGL for the context. This method is called by QGLViewer::initializeGL(). The main reason that this has been implemented, is to undo the non-standard modifications that QGLViewer::initializeGL() makes to the OpenGL initial state. Reimplemented from QGLViewer. |
|
||||||||||||
|
This method is used to get the inverse of a 4x4 matrix.
It actually came from from Nate Robins' OpenGL Tutors. Beginning of the source code file projection.c: projection.c
Nate Robins, 1997
Tool for teaching about OpenGL projections.
|
|
|
Used to extend Qt's mouse button modifier keys to include the "1", "2" and "3" number keys. This method will handle a key press event and filter it to check if one of these extended modifier keys has been pressed. If one has been, then the current extended modifier key variable will be set to the Qt key code. This reimplementation also disables QGLViewer's key bindings. Reimplemented from QGLViewer. |
|
|
Used to extend Qt's mouse button modifier keys to include "1", "2" and "3" number keys. This method will handle a key release event and filter it to check if one of these extended modifier keys has been released. If one has been, then the current extended modifier key variable will be set to = 0 (no key). This reimplementation also disables QGLViewer's key bindings. |
|
|
Re-implemented, as to use the mouse event translator. See GLWorldViewer::mouseEventTranslator() for details. Reimplemented from QGLViewer. |
|
||||||||||||
|
This is used to translate mouse events, as to support all of the control features of a 3-button mouse by adding the "1", "2" and "3" number keys as modifiers to the left mouse button. Translated events:
Note: The ordering of the modifiers, where key 1 was chosen for the middle button, followed by key 2 for the right mouse button, was implemented, as that is the same ordering of the buttons on a mouse (right-hand setup). |
|
|
Re-implemented, as to use the mouse event translator. See GLWorldViewer::mouseEventTranslator() for details. Reimplemented from QGLViewer. |
|
|
Re-implemented, as to use the mouse event translator. See GLWorldViewer::mouseEventTranslator() for details. Reimplemented from QGLViewer. |
|
|
Re-implemented, as to use the mouse event translator. See GLWorldViewer::mouseEventTranslator() for details. Reimplemented from QGLViewer. |
|
|
Draw post-scene objects and visual hints, such as the axis, Z=0 grid, projection frustum and possibly the contents of the Z-buffer. Reimplemented from QGLViewer. |
|
|
Prep the OpenGL context for drawing to.
This method will make a call for its GLScreenViewer instance counterpart to update itself (via an GLScreenViewer::updateGL() call). Note: This will delete any existing display lists. Reimplemented from QGLViewer. |
|
|
Stop the camera from spinning (if it is) and reposition it so that it is located at (0.0, 0.0, 4.0), looking at (0.0, 0.0, 0.0) (i.e. the origin) and has an up vector of (0.0, 1.0, 0.0). |
|
|
|
|
|
|
|
|
Same as setBackgroundColor, but with a QColor attribute. Reimplemented from QGLViewer. |
|
||||||||||||||||
|
Same as setBackgroundColor(), but with float parameters. Reimplemented from QGLViewer. |
|
|
Reimplemented, as to gain more control over when the glClearColor call is made (so that the user can override it if they call it) and also to overcome a bug in QGLViewer, where a makeCurrent() call is not made before glClearColor is called, hence any viewer could otherwise end-up being effected. Reimplemented from QGLViewer. |
|
|
|
|
|
This method is used by the constructors to perform tasks that are common to all of them. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.3.2