-
Notifications
You must be signed in to change notification settings - Fork 0
/
glwidget.h
97 lines (80 loc) · 2.25 KB
/
glwidget.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Don't forget to promote the widget in the designer to be of
// this class!
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QOpenGLWidget>
#include <QOpenGLBuffer>
#include <QOpenGLFunctions>
#include <QOpenGLVertexArrayObject>
#include <QMatrix4x4>
#include <QColor>
#include "sprite.h"
QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
public:
GLWidget(QWidget *parent = 0);
~GLWidget();
public slots:
void setEnableBlending(bool);
void setEnableDepthTest(bool);
void setSrcFactor(const QString&);
void setDstFactor(const QString&);
void setEnabledSeparateBlending(bool);
void setSeparateSrcFactor(const QString&);
void setSeparateDstFactor(const QString&);
void setClearColor(QColor);
void setClearAlpha(float);
void setTopColor(QColor);
void setTopAlpha(float);
void setMiddleColor(QColor);
void setMiddleAlpha(float);
void setBottomColor(QColor);
void setBottomAlpha(float);
void setBlendColor(QColor);
void setBlendAlpha(float);
void setBlendEquation(const QString&);
void setSeparateBlendEquation(const QString&);
void setEnableColorLogicOp(bool);
void setLogicOp(const QString&);
void setEnablePreMultiplyAlpha(bool);
void cleanup();
signals:
// signals are for mouse events etc inside the widget.
protected:
void initializeGL() Q_DECL_OVERRIDE;
void paintGL() Q_DECL_OVERRIDE;
private:
// Qt centric
bool core;
// OpenGL centric
void setupVertexAttribs();
// These are state which can be set in paintGL()
bool blending;
bool depthtesting;
GLenum srcfactor;
GLenum dstfactor;
bool separateblending;
GLenum separatesrcfactor;
GLenum separatedstfactor;
GLenum blendeq;
GLenum sepeq;
bool logicoping;
GLenum logicop;
bool premultalpha;
float clearColor[4];
float blendColor[4];
// for setting uniforms
float topColor[4];
float middleColor[4];
float bottomColor[4];
// for converting combobox QStrings to GLenums
GLenum str2enum(const QString&);
Sprite *topSprite;
Sprite *middleSprite;
Sprite *bottomSprite;
QMatrix4x4 persp;
QMatrix4x4 cam;
};
#endif // GLWIDGET_H