|
KGLLib
|
Easy to use GL widget, based on QGLWidget. More...
#include <glwidget.h>
Public Slots | |
| void | toggleShowFps () |
| void | toggleWireframeMode () |
Public Member Functions | |
| EIGEN_MAKE_ALIGNED_OPERATOR_NEW | GLWidget (QWidget *parent=0, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0) |
| GLWidget (QGLContext *context, QWidget *parent=0, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0) | |
| GLWidget (const QGLFormat &format, QWidget *parent=0, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0) | |
| KGLLib::Camera * | camera () const |
| KGLLib::FPSCounter * | fpsCounter () const |
| KGLLib::TextRenderer * | textRenderer () const |
| bool | glInitialized () const |
Protected Member Functions | |
| virtual void | initializeGL () |
| virtual void | initializeGL (Renderer *r) |
| virtual void | resizeGL (int width, int height) |
| virtual void | paintGL () |
| virtual void | render () |
| void | setClearColor (const Eigen::Vector4f &c) |
| void | setAutomaticClear (bool clear) |
| Eigen::Vector4f | clearColor () const |
| bool | automaticClear () const |
| void | setErrorText (const QString &text) |
| QString | errorText () const |
| bool | shortcutsEnabled () const |
| virtual void | setShortcutsEnabled (bool enabled) |
Easy to use GL widget, based on QGLWidget.
GLWidget is a QGLWidget subclass which is integrated with the rest of the KGLLib and implements some of the common functionality used by many GL applications.
If you are already using QGLWidget then switching to GLWidget is very easy. All you need to do is changing class name to GLWidget and doing your OpenGL rendering in render() method instead of paintGL().
| KGLLib::Camera* KGLLib::GLWidget::camera | ( | ) | const [inline] |
Referenced by initializeGL(), paintGL(), and resizeGL().
| QString KGLLib::GLWidget::errorText | ( | ) | const [inline, protected] |
| KGLLib::FPSCounter* KGLLib::GLWidget::fpsCounter | ( | ) | const [inline] |
Referenced by paintGL().
| bool KGLLib::GLWidget::glInitialized | ( | ) | const [inline] |
| void KGLLib::GLWidget::initializeGL | ( | Renderer * | r | ) | [protected, virtual] |
Same as above but passes the specified Renderer object to KGLLib::init().
Reimplemented in KGLLib::HdrGLWidget.
References camera(), KGLLib::init(), setClearColor(), KGLLib::Camera::setDepthRange(), KGLLib::Camera::setLookAt(), KGLLib::Camera::setPosition(), and KGLLib::Camera::setUp().
| void KGLLib::GLWidget::initializeGL | ( | ) | [protected, virtual] |
Initializes OpenGL. Base implementation:
Reimplemented in KGLLib::HdrGLWidget.
| void KGLLib::GLWidget::paintGL | ( | ) | [protected, virtual] |
Called when the widget needs to be painted. Base implementation:
Note that applications are preferred to use render() instead. If you do your OpenGL rendering in this method then some functionality provided by this class will not work (e.g. fps display).
References KGLLib::Camera::applyView(), KGLLib::TextRenderer::begin(), camera(), KGLLib::TextRenderer::draw(), KGLLib::TextRenderer::end(), fpsCounter(), KGLLib::FPSCounter::nextFrame(), render(), setClearColor(), and textRenderer().
| void KGLLib::GLWidget::render | ( | ) | [protected, virtual] |
Called from paintGL() when the widget needs to be painted. This is the method that you should reimplement to do your rendering. Base implementation does nothing, so you needn't call it from your implementation.
Reimplemented in KGLLib::HdrGLWidget.
Referenced by paintGL().
| void KGLLib::GLWidget::resizeGL | ( | int | width, |
| int | height | ||
| ) | [protected, virtual] |
Called when the widget is resized. Base implementation:
Reimplemented in KGLLib::HdrGLWidget.
References KGLLib::Camera::applyPerspective(), KGLLib::Camera::applyViewport(), camera(), KGLLib::Camera::setAspect(), and KGLLib::Camera::setViewport().
| void KGLLib::GLWidget::setAutomaticClear | ( | bool | clear | ) | [protected] |
Specifies whether OpenGL buffers should be automatically cleared in the beginning of paintGL.
| void KGLLib::GLWidget::setClearColor | ( | const Eigen::Vector4f & | c | ) | [protected] |
Set's OpenGL's clear color to c. Default is black. TODO: maybe rename to setBackgroundColor?
Referenced by initializeGL(), and paintGL().
| void KGLLib::GLWidget::setErrorText | ( | const QString & | text | ) | [protected] |
Sets error text for this widget.
If the error text is set, then it is displayed centered in the widget and render() method isn't called.
It is handy to use when something goes wrong in your application's initialization phase (e.g. data files cannot be found) and you want to abort but let the user know what happened.
| void KGLLib::GLWidget::setShortcutsEnabled | ( | bool | enabled | ) | [protected, virtual] |
GLWidget provides some keyboard shortcuts to ease application development. For example Meta+F toggles FPS (frames per second) display and Meta+W toggles wireframe rendering.
If you don't want those shortcuts to be available, you can disable them using this method.
Shortcuts are enabled by default.
| bool KGLLib::GLWidget::shortcutsEnabled | ( | ) | const [inline, protected] |
| KGLLib::TextRenderer * KGLLib::GLWidget::textRenderer | ( | ) | const |
Referenced by paintGL().
1.7.4