Gem Illuminator
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
gemrenderer.h
Go to the documentation of this file.
1 #ifndef GEMRENDERERNEW_H
2 #define GEMRENDERERNEW_H
3 
4 template<typename Key, typename T> class QHash;
5 template<typename T> class QList;
6 class QMatrix4x4;
7 class QOpenGLBuffer;
8 class QOpenGLFunctions;
9 class QOpenGLShaderProgram;
10 class QOpenGLTexture;
11 template<typename T> class QVector;
12 
13 class AbstractGem;
14 class GemData;
15 enum class GemType;
16 
22 {
27  class GemDataInfo
28  {
29  public:
30  GemDataInfo();
31  ~GemDataInfo();
32 
37  const GemData &data() const;
42  void setData(const GemData &data);
43 
48  int index() const;
53  void setIndex(int index);
54 
59  int numberOfVertices();
60 
65  void appendVerticesWithIndexTo(QVector<float> &vector) const;
66 
67  protected:
68  GemData *m_data;
69  int m_index;
70  };
71 
77  class GemRenderData
78  {
79  public:
80  GemRenderData();
81  ~GemRenderData();
82 
87  void cleanup(QOpenGLFunctions &gl);
92  void initialize(QOpenGLFunctions &gl);
93 
99  void paint(QOpenGLFunctions &gl, QOpenGLShaderProgram &program);
100 
107  void addOrUpdateGem(GemDataInfo *gem, QOpenGLFunctions &gl);
112  void setVerticesPerGem(int numberOfVertices);
117  void setSceneExtent(float extent);
122  void setFloatTexturesEnabled(bool enable);
128  void appendAttributesToVector(GemDataInfo *gem, QVector<float> &vector);
135  void appendAttributesToVector(GemDataInfo *gem, QVector<unsigned char> &vector);
136 
137  protected:
144  void addGem(GemDataInfo *gem, QOpenGLFunctions &gl);
150  void updateGem(GemDataInfo *gem, QOpenGLFunctions &gl);
151 
152  protected:
153  int m_allocatedGems;
154  int m_allocatedAndUsedGems;
156  unsigned int m_dataBuffer;
157  QList<GemDataInfo *> *m_gems;
158  bool m_hasErrorOccured;
159  bool m_isInitialized;
160  unsigned int m_lowestUnusedIndex;
161  int m_maxTextureSize;
162  float m_sceneExtent;
163  int m_texelPerGem;
164  QOpenGLBuffer *m_vertexBuffer;
165  int m_verticesPerGem;
166  };
167 
168 
169 public:
170  GemRenderer();
171  ~GemRenderer();
172 
177  void cleanup(QOpenGLFunctions &gl);
182  void initialize(QOpenGLFunctions &gl);
188  void paint(QOpenGLFunctions &gl, QOpenGLShaderProgram &program);
193  void setSceneExtent(float extent);
199  void updateGem(AbstractGem *gem);
200 
201 protected:
206  void updateData(QOpenGLFunctions &gl);
207 
208 protected:
217 };
218 
219 #endif // GEMRENDERERNEW_H
bool m_isGemBufferUpdateRequired
Definition: gemrenderer.h:212
Definition: gemdata.h:6
GemType
An enum describing current gem type. This enum is used for faster comparision of gems, because all gems of one type have same (objectspace) vertices.
Definition: abstractgem.h:22
bool m_isInitialized
Definition: gemrenderer.h:214
void cleanup(QOpenGLFunctions &gl)
Cleans up all gpu resources.
Definition: gemrenderer.cpp:44
QHash< GemType, GemRenderData * > * m_gemBuffersTex
Definition: gemrenderer.h:210
The GemData class stores all required information to describe an AbstractGem. The advantage of GemDa...
Definition: gemdata.h:20
QList< GemDataInfo * > * m_newGems
Definition: gemrenderer.h:215
GemRenderer()
Definition: gemrenderer.cpp:24
void initialize(QOpenGLFunctions &gl)
Initializes all gpu resources.
Definition: gemrenderer.cpp:87
~GemRenderer()
Definition: gemrenderer.cpp:36
void paint(QOpenGLFunctions &gl, QOpenGLShaderProgram &program)
paint Paints all gems using faked instanced drawing.
Definition: gemrenderer.cpp:51
void setSceneExtent(float extent)
Sets the scene extent, which is required to encode gem positions into byte textures.
Definition: gemrenderer.cpp:65
QHash< AbstractGem *, GemDataInfo * > * m_gemMap
Definition: gemrenderer.h:211
bool m_areFloatTexturesAvailable
Definition: gemrenderer.h:209
void updateGem(AbstractGem *gem)
Save given gem in order to update it later.
Definition: gemrenderer.cpp:71
The GemRenderer class renders all of our gems. For performance reasons the GemRenderer packs all gem...
Definition: gemrenderer.h:21
Definition: gemrenderer.h:11
float m_sceneExtent
Definition: gemrenderer.h:216
Definition: gemrenderer.h:4
The AbstractGem class is the base class of all gems. As base class all required information of a gem...
Definition: abstractgem.h:39
bool m_isGemDataBufferInvalid
Definition: gemrenderer.h:213
void updateData(QOpenGLFunctions &gl)
Updates previous added gem using updateGem()
Definition: gemrenderer.cpp:117