AmbientOcclusion
Canvas.h
Go to the documentation of this file.
1 #ifndef CANVAS_H
2 #define CANVAS_H
3 
4 #include <iostream>
5 #include <vector>
6 #include <stdio.h>
7 #include <math.h>
8 
9 #include <QOpenGLWidget>
10 #include <QOpenGLFunctions_3_1>
11 #include <QtOpenGL>
12 #include <QOpenGLFunctions>
13 #include <QOpenGLBuffer>
14 #include <QOpenGLShaderProgram>
15 #include <QMatrix4x4>
16 
17 
18 #include "Params.h"
19 #include "Molecule.h"
20 #include "Camera.h"
21 #include "Direction.h"
22 
27 class Canvas: public QOpenGLWidget, protected QOpenGLFunctions
28 {
29  Q_OBJECT
30 public:
31 
32  Canvas(QWidget *parent = 0);
33  ~Canvas();
34 
38  virtual void initializeGL();
39 
45  virtual void resizeGL(int width, int height);
50  virtual void paintGL();
51 
55  void loadModel();
56 
60  void drawScene();
61 
65  void drawEdges();
66 
70  void drawHalos();
71 
76 
80  void drawPostProcess();
81 
86  virtual void mouseMoveEvent(QMouseEvent * event);
87 
92  virtual void mousePressEvent(QMouseEvent * event);
93 
98  virtual void mouseReleaseEvent(QMouseEvent * event);
99 
104  virtual void wheelEvent(QWheelEvent * event);
105 
106 protected:
107 
108 private:
109 
113  QOpenGLShaderProgram mainShader;
114 
118  QOpenGLFramebufferObject* sceneFBO;
119 
123  GLuint sceneDepthTexture;
124 
128  QOpenGLShaderProgram haloShader;
129 
133  QOpenGLFramebufferObject* haloFBO;
134 
138  QOpenGLShaderProgram edgeShader;
139 
143  QOpenGLFramebufferObject* edgeFBO;
144 
148  QOpenGLShaderProgram shadowMapShader;
149 
153  QOpenGLShaderProgram occlusionMapShader;
154 
158  QOpenGLFramebufferObject* occlusionMapFBO;
159 
163  GLuint shadowMapTexture;
164 
168  QOpenGLShaderProgram postprocessShader;
169 
170 
174  QOpenGLBuffer quadVertexBuffer;
175 
179  QOpenGLBuffer quadUVBuffer;
180 
184  QOpenGLVertexArrayObject postProcessVAO;
185 
189  void initializeShaders();
190 
194  void initializeQuad();
195 
199  void initializeFrameBufferObjects();
200 
204  void destroyFrameBufferObjects();
205 
209  Molecule* molecule;
210 
214  Camera* camera;
215 
219  QPoint lastPos;
220 
224  bool mouseRightDown;
225 };
226 
227 #endif // CANVAS_H
virtual void mouseMoveEvent(QMouseEvent *event)
mouseMoveEvent - Callback Function for when the Mouse is being moved
Definition: Canvas.cpp:245
void drawPostProcess()
drawPostProcess - calculates the post process edge cueing effects, contours and halos ...
Definition: Canvas.cpp:193
The Molecule class - This class represents a molecule. It consists of atoms and bonds.
Definition: Molecule.h:70
The Canvas class - represents the main class of our application, since the whole logic and the calls ...
Definition: Canvas.h:27
void drawHalos()
drawHalos - Draws the previously rendered scene from the framebuffer onto the screen with postprocess...
Definition: Canvas.cpp:157
The Camera class - simulates the view point of the user. When the user interacts with the visualized ...
Definition: Camera.h:10
~Canvas()
Definition: Canvas.cpp:17
virtual void mouseReleaseEvent(QMouseEvent *event)
mouseReleaseEvent - Callback Function for when a Mouse button is released
Definition: Canvas.cpp:273
void calculateAmbientOcclusionMap()
calculateAmbientOcclusion - calculates the ambient occlusion effect for the current scene ...
Definition: Canvas.cpp:371
Canvas(QWidget *parent=0)
Definition: Canvas.cpp:9
void drawEdges()
drawEdges - Draws the edge effect
Definition: Canvas.cpp:138
virtual void mousePressEvent(QMouseEvent *event)
mousePressEvent - Callback Function for when a Mouse button is pressed
Definition: Canvas.cpp:263
void drawScene()
drawScene - Draws the sccene onto the bound framebuffer
Definition: Canvas.cpp:105
virtual void resizeGL(int width, int height)
resizeGL - callback method, which handels situations where the width or heigt of the window changes ...
Definition: Canvas.cpp:232
virtual void paintGL()
paintGL - takes care of everything that will be drawn on the canvas. Calls methods which regulate div...
Definition: Canvas.cpp:62
void loadModel()
loadModel - Load model from currently specified file path
Definition: Canvas.cpp:44
virtual void wheelEvent(QWheelEvent *event)
wheelEvent - Callback Function for when the Mouse scroll wheel is being activated ...
Definition: Canvas.cpp:282
virtual void initializeGL()
initializeGL - takes care of the initialization of al important OpenGL aspects
Definition: Canvas.cpp:26