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

KGLLib

glwidget.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008 Rivo Laks <rivolaks@hot.ee>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either 
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public 
00015  * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef KGLLIB_GLWIDGET_H
00019 #define KGLLIB_GLWIDGET_H
00020 
00021 
00022 #include "kgllib.h"
00023 #include <QtOpenGL/QGLWidget>
00024 #include <QtCore/QList>
00025 
00026 #include <Eigen/Core>
00027 
00028 class QAction;
00029 
00030 
00031 namespace KGLLib
00032 {
00033 class Camera;
00034 class FPSCounter;
00035 class TextRenderer;
00036 
00048 class KGLLIB_EXPORT GLWidget : public QGLWidget
00049 {
00050 Q_OBJECT
00051 public:
00052     explicit GLWidget(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
00053     explicit GLWidget(QGLContext* context, QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
00054     explicit GLWidget(const QGLFormat& format, QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
00055 
00056     virtual ~GLWidget();
00057 
00062     KGLLib::Camera* camera() const  { return mCamera; }
00067     KGLLib::FPSCounter* fpsCounter() const  { return mFpsCounter; }
00068 
00072     KGLLib::TextRenderer* textRenderer() const;
00073 
00077     bool glInitialized() const  { return mGLInitialized; }
00078 
00079 public Q_SLOTS:
00080     void toggleShowFps();
00081     void toggleWireframeMode();
00082 
00083 protected:
00095     virtual void initializeGL();
00099     virtual void initializeGL(Renderer* r);
00105     virtual void resizeGL(int width, int height);
00116     virtual void paintGL();
00123     virtual void render();
00124 
00130     void setClearColor(const Eigen::Vector4f& c);
00135     void setAutomaticClear(bool clear);
00136 
00137     Eigen::Vector4f clearColor() const  { return mClearColor; }
00138     bool automaticClear() const  { return mAutomaticClear; }
00139 
00150     void setErrorText(const QString& text);
00155     QString errorText() const  { return mErrorText; }
00156 
00161     bool shortcutsEnabled() const  { return mShortcutsEnabled; }
00172     virtual void setShortcutsEnabled( bool enabled);
00173 
00174 private:
00175     void init();
00176 
00177 private:
00178     KGLLib::Camera* mCamera;
00179     KGLLib::FPSCounter* mFpsCounter;
00180     mutable KGLLib::TextRenderer* mTextRenderer;
00181 
00182     bool mAutomaticClear;
00183     Eigen::Vector4f mClearColor;
00184     bool mGLInitialized;
00185 
00186     bool mShowFps;
00187     bool mWireframeMode;
00188     QString mErrorText;
00189     // We use our own list of actions here because we want to be able to
00190     //  enable/disable only those actions
00191     QList<QAction*> mShortcuts;
00192     bool mShortcutsEnabled;
00193 };
00194 
00195 }
00196 
00197 #endif

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