Depth of Field  0.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
appglwidget.h
Go to the documentation of this file.
1 /******************************************************************************
2 **
3 ** Author Matthias Werner
4 ** EMail <wmatthias at users.sourceforge.net>
5 ** Qt with CUDA and OpenGL Demonstration.
6 ** Feel free to use and modify it for your own purposes.
7 ** Have fun!
8 **
9 ** Created and tested on
10 ** - Windows 7 Geforce 9800GT
11 ** - CUDA Toolkit 4.0
12 ** - OpenGL 2.1
13 ** - Qt 4.7.4
14 ** - Visual Studio 2010 C/C++ Compiler
15  (with Parallel Nsight 2.0 and Qt Visual Studio AddIn 1.1.9)
16 *******************************************************************************/
17 
18 #ifndef __APPGLWIDGET_H
19 #define __APPGLWIDGET_H
20 
21 // first
22 #include "simplePBO.h"
23 #include "FileLoader.h"
24 
25 #include <QtGui>
26 #include <QtOpenGL>
27 #include <QGLWidget>
28 #include <QTimer>
29 #include <QWheelEvent>
30 
31 #include <time.h>
32 
33 // for AppGLWidget::getGLError()
34 #ifndef GLERROR
35 #define GLERROR(e) case e: exception=#e; break;
36 #endif
37 
42 class AppGLWidget : public QGLWidget
43 {
44  Q_OBJECT
45 
46  public:
51  AppGLWidget(QWidget *parent);
52 
56  ~AppGLWidget();
57 
63  void startUpdateTimer();
64 
66  void stopUpdateTimer();
67 
68 //-----------------------------------------------------------------------------
69  public slots:
75  void update();
77  void setAlpha(int val);
79  void setRenderDoF();
80 
81 
82  protected:
83  // input event handling
84  void mousePressEvent(QMouseEvent *event);
85  void mouseMoveEvent(QMouseEvent *event);
86  void wheelEvent(QWheelEvent *event);
87 
88  private slots:
92  void framesCount();
93 
94 //-----------------------------------------------------------------------------
95  private:
99  void initializeGL();
100 
106  void resizeGL(int w, int h);
107 
111  void paintGL();
112 
116  QString getGLError();
117 
118  private:
120  unsigned int frames;
122  GLenum glError;
124  QTime timeElapse;
126  QTimer* tiupdate;
128  QTimer* tifps;
130  QString strFrames;
132  SimplePBO spbo;
134  FileLoader fileLoader;
135 
136  // time difference in ms between last frame and current frame
137  int timediff;
138  int lasttime;
139 
140 
141  // last mouse position
142  QPoint lastPos;
143 };
144 
145 #endif