-
Notifications
You must be signed in to change notification settings - Fork 0
/
qgldisplaywidget.h
83 lines (70 loc) · 1.89 KB
/
qgldisplaywidget.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
#ifndef QGLDISPLAYWIDGET_H
#define QGLDISPLAYWIDGET_H
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLShader>
#include <QOpenGLTexture>
#include <QOpenGLBuffer>
struct _texture_obj_{
void init(){
texture = new QOpenGLTexture(QOpenGLTexture::Target2D);
texture->create();
id = texture->textureId();
glBindTexture(GL_TEXTURE_2D, id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
QOpenGLTexture* texture;
uint id;
};
class QGLDisplayWidget : public QOpenGLWidget, public QOpenGLFunctions
{
Q_OBJECT
enum enum_pragram_attr_index
{
ATTR_VERTEX_IN = 0,
ATTR_TEXTURE_IN,
};
// enum enum_texture_index
// {
// TEXTURE_IMG = 0,
// TEXTURE_MAX
// };
enum enum_local
{
// Local_Img,
Local_Mouse,
Local_Time,
Local_Resolution,
Local_Max
};
public:
QGLDisplayWidget(QWidget *parent = nullptr);
virtual ~QGLDisplayWidget();
void setDisplaySize(int w, int h);
// QOpenGLWidget interface
signals:
void modifyFile(const QString&);
void flushPoint(const QPoint&);
void playOver();
public slots:
void setSpeed(int);
protected:
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
void initProgram(const QString&);
private:
QOpenGLShader* m_vShader,* m_fShader;
QOpenGLShaderProgram* m_program;
int m_location[Local_Max];
GLfloat m_vertexVertices[8], m_textureVertices[8];
// _texture_obj_ m_texture[TEXTURE_MAX];
QPoint m_center;
QImage m_img;
long long m_nStart;
int m_nDelay;
};
#endif // QGLDISPLAYWIDGET_H