-
-
Notifications
You must be signed in to change notification settings - Fork 557
/
Copy pathshaderdrawable.h
66 lines (49 loc) · 1.32 KB
/
shaderdrawable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef SHADERDRAWABLE_H
#define SHADERDRAWABLE_H
#include <QObject>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
#include <QOpenGLVertexArrayObject>
#include "util.h"
struct VertexData
{
QVector3D position;
QVector3D color;
QVector3D start;
};
class ShaderDrawable : protected QOpenGLFunctions
{
public:
explicit ShaderDrawable();
~ShaderDrawable();
void update();
void draw(QOpenGLShaderProgram *shaderProgram);
bool needsUpdateGeometry() const;
void updateGeometry(QOpenGLShaderProgram *shaderProgram = 0);
virtual QVector3D getSizes();
virtual QVector3D getMinimumExtremes();
virtual QVector3D getMaximumExtremes();
virtual int getVertexCount();
double lineWidth() const;
void setLineWidth(double lineWidth);
bool visible() const;
void setVisible(bool visible);
double pointSize() const;
void setPointSize(double pointSize);
signals:
public slots:
protected:
double m_lineWidth;
double m_pointSize;
bool m_visible;
QVector<VertexData> m_lines;
QVector<VertexData> m_points;
QOpenGLBuffer m_vbo; // Protected for direct vbo access
virtual bool updateData();
private:
QOpenGLVertexArrayObject m_vao;
bool m_needsUpdateGeometry;
void init();
};
#endif // SHADERDRAWABLE_H