• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KGLLib

KGLLib::GLWidget

KGLLib::GLWidget Class Reference

#include <glwidget.h>

Inheritance diagram for KGLLib::GLWidget:

Inheritance graph
[legend]

List of all members.


Detailed Description

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().

Definition at line 48 of file glwidget.h.


Public Slots

void toggleShowFps ()
void toggleWireframeMode ()

Public Member Functions

KGLLib::Camera * camera () const
KGLLib::FPSCounter * fpsCounter () const
bool glInitialized () const
 GLWidget (const QGLFormat &format, 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 (QWidget *parent=0, const QGLWidget *shareWidget=0, Qt::WindowFlags f=0)
KGLLib::TextRenderer * textRenderer () const
virtual ~GLWidget ()

Protected Member Functions

bool automaticClear () const
Eigen::Vector4f clearColor () const
QString errorText () const
virtual void initializeGL (Renderer *r)
virtual void initializeGL ()
virtual void paintGL ()
virtual void render ()
virtual void resizeGL (int width, int height)
void setAutomaticClear (bool clear)
void setClearColor (const Eigen::Vector4f &c)
void setErrorText (const QString &text)
virtual void setShortcutsEnabled (bool enabled)
bool shortcutsEnabled () const

Constructor & Destructor Documentation

KGLLib::GLWidget::GLWidget ( QWidget *  parent = 0,
const QGLWidget *  shareWidget = 0,
Qt::WindowFlags  f = 0 
) [explicit]

Definition at line 36 of file glwidget.cpp.

KGLLib::GLWidget::GLWidget ( QGLContext *  context,
QWidget *  parent = 0,
const QGLWidget *  shareWidget = 0,
Qt::WindowFlags  f = 0 
) [explicit]

Definition at line 42 of file glwidget.cpp.

KGLLib::GLWidget::GLWidget ( const QGLFormat &  format,
QWidget *  parent = 0,
const QGLWidget *  shareWidget = 0,
Qt::WindowFlags  f = 0 
) [explicit]

Definition at line 48 of file glwidget.cpp.

KGLLib::GLWidget::~GLWidget (  )  [virtual]

Definition at line 54 of file glwidget.cpp.


Member Function Documentation

bool KGLLib::GLWidget::automaticClear (  )  const [inline, protected]

Definition at line 138 of file glwidget.h.

KGLLib::Camera* KGLLib::GLWidget::camera (  )  const [inline]

Returns:
pointer to the Camera object.

This is available after initializeGL() has been called.

Definition at line 62 of file glwidget.h.

Eigen::Vector4f KGLLib::GLWidget::clearColor (  )  const [inline, protected]

Definition at line 137 of file glwidget.h.

QString KGLLib::GLWidget::errorText (  )  const [inline, protected]

Returns:
current error text

See also:
setErrorText()

Definition at line 155 of file glwidget.h.

KGLLib::FPSCounter* KGLLib::GLWidget::fpsCounter (  )  const [inline]

Returns:
pointer to the FPSCounter object.

This is available after initializeGL() has been called.

Definition at line 67 of file glwidget.h.

bool KGLLib::GLWidget::glInitialized (  )  const [inline]

Returns:
whether initializeGL() has been called

Definition at line 77 of file glwidget.h.

void KGLLib::GLWidget::initializeGL ( Renderer *  r  )  [protected, virtual]

Same as above but passes the specified Renderer object to KGLLib::init().

Reimplemented in KGLLib::HdrGLWidget.

Definition at line 142 of file glwidget.cpp.

void KGLLib::GLWidget::initializeGL (  )  [protected, virtual]

Initializes OpenGL.

Base implementation:

  • calls KGLLib::init() to initialize KGLLib
  • creates camera and fpsCounter objects
  • sets OpenGL clear color to clearColor
  • initializes camera to look from (0, 0, 5) at (0, 0, 0) with depth range [1, 100]
  • enables depth testing (if depth buffer is used)
  • sets OpenGL shade model to GL_SMOOTH
  • sets primary color to white

Reimplemented from QGLWidget.

Reimplemented in KGLLib::HdrGLWidget.

Definition at line 137 of file glwidget.cpp.

void KGLLib::GLWidget::paintGL (  )  [protected, virtual]

Called when the widget needs to be painted.

Base implementation:

  • updates fpsCounter
  • clears color and possibly depth buffer is automaticClear is true
  • applies camera
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).

Reimplemented from QGLWidget.

Definition at line 180 of file glwidget.cpp.

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.

Definition at line 225 of file glwidget.cpp.

void KGLLib::GLWidget::resizeGL ( int  width,
int  height 
) [protected, virtual]

Called when the widget is resized.

Base implementation:

  • sets up a new viewport, covering the entire widget
  • updates camera's aspect and applies the camera

Reimplemented from QGLWidget.

Reimplemented in KGLLib::HdrGLWidget.

Definition at line 171 of file glwidget.cpp.

void KGLLib::GLWidget::setAutomaticClear ( bool  clear  )  [protected]

Specifies whether OpenGL buffers should be automatically cleared in the beginning of paintGL.

Definition at line 118 of file glwidget.cpp.

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?

Definition at line 109 of file glwidget.cpp.

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.

Definition at line 123 of file glwidget.cpp.

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.

Definition at line 86 of file glwidget.cpp.

bool KGLLib::GLWidget::shortcutsEnabled (  )  const [inline, protected]

Returns:
whether KGLLib keyboard shortcuts are enabled.

See also:
setShortcutsEnabled()

Definition at line 161 of file glwidget.h.

KGLLib::TextRenderer * KGLLib::GLWidget::textRenderer (  )  const

Returns:
TextRenderer object

Definition at line 129 of file glwidget.cpp.

void KGLLib::GLWidget::toggleShowFps (  )  [slot]

Definition at line 97 of file glwidget.cpp.

void KGLLib::GLWidget::toggleWireframeMode (  )  [slot]

Definition at line 103 of file glwidget.cpp.


The documentation for this class was generated from the following files:
  • glwidget.h
  • glwidget.cpp

KGLLib

Skip menu "KGLLib"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KGLLib
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal