InfoVis 2013  1.0
Information Visualisation project - "Mapping Text with Phrase Nets"
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Renderer.h
Go to the documentation of this file.
1 #ifndef RENDERER_H
2 #define RENDERER_H
3 
4 #include <vector>
5 #include <stdint.h>
6 
7 #include <windows.h>
8 #include <GL/glew.h>
9 #include <GL/glfw.h>
10 
11 #include <glm.hpp>
12 
13 class Arrow;
14 class Shader;
15 class ShaderManager;
16 class Application;
17 
19 {
20  ArrowVertex(const glm::vec3& position, const glm::vec4& colour);
21  ArrowVertex(const glm::vec2& position, const glm::vec4& colour);
22  ArrowVertex(const ArrowVertex& original);
23 
24  float posX, posY, posZ;
26 };
27 
28 /* The Renderer class is responsioble for rendering the arrows to a multisampled FBO texture that is used to contain all the rendered arrows drawn in the application */
29 class Renderer
30 {
31 public:
32  Renderer(Application* application);
33  ~Renderer();
34 
35  void swapBuffers();
36  void render();
37 
38  void handleSizeUpdate(int width, int height);
39  void createArrowGeometry(const std::vector<Arrow>& arrows);
40 
41 
42 
43 private:
44 
45  void beginRendering();
46  void endRendering();
47 
48  void blitArrowMultiSamplingFbo();
49 
50  void createRenderBuffers();
51 
52  void createRenderBufferFboAA();
53 
54  void createRenderBufferFboFinal();
55 
56  void createArrowBuffers();
57 
58  void updateArrowBuffer(const std::vector<ArrowVertex>& arrowVertices);
59  void updateArrowFboSize();
60 
61  void renderArrowVertices();
62 
63  void createArrowGeometryArrowHeads(std::vector<ArrowVertex> &arrowVertices);
64 
65  float calculateArrowHeadScaleFactor(int connectionsCount);
66 
67  void createArrowGeometryArrowHead(std::vector<ArrowVertex> &arrowVertices, const glm::vec2& arrowPeakPosition, glm::vec2 arrowDirection, float arrowHeadAngle, float arrowHeadDimension, const Arrow& arrow);
68 
69  void createArrowGeometryLines(std::vector<ArrowVertex> &arrowVertices);
70 
71  float calculateArrowScaleValue(const Arrow& arrow);
72  float calculateArrowAlphaValue(float scaleValue);
73 
74  int m_arrowFboWidth;
75  int m_arrowFboHeight;
76 
77  std::vector<Arrow> m_arrows;
78 
79  ShaderManager* m_shaderManager;
80  Shader* m_arrowShader;
81 
82  GLuint m_arrowFboAA;
83  GLuint m_arrowRboAA;
84  GLuint m_arrowFboFinal;
85  GLuint m_arrowFboFinalTextureID;
86  GLint m_multiSamplingSamples;
87 
88  GLuint m_arrowVao;
89  GLuint m_arrowVbo;
90 
91  GLuint m_arrowShaderMatrixLoc;
92 
93  Application* m_application;
94 
95  int m_arrowVertexCount;
96 
97  glm::vec3 m_arrowLineColour;
98  glm::vec3 m_arrowHeadColour;
99  glm::vec3 m_arrowOutlineColour;
100 
101  glm::vec4 m_backgroundColour;
102 };
103 
104 #endif