-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenglwidget.h
82 lines (62 loc) · 1.71 KB
/
openglwidget.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
#ifndef OPENGLWIDGET_H
#define OPENGLWIDGET_H
#include <QWidget>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QPushButton>
#include "usplatform.h"
#include "usnetwork.h"
#include "uslogger.h"
using namespace qtng;
class OpenGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
public:
explicit OpenGLWidget(QWidget *parent = 0) : screenW(640), screenH(480)
{
QPushButton *btn = new QPushButton();
btn->setGeometry(200, 200, 200, 100);
btn->setText(QStringLiteral("骚猫!"));
btn->setFlat(true);
btn->setAutoFillBackground(true);
QPalette palette = btn->palette();
palette.setColor(QPalette::Button,QColor(166,166,166,166));
btn->setPalette(palette);
btn->setParent(this);
#ifdef US_NETWORK_NG
connect(btn, &QPushButton::clicked,
[btn]()
{
QString remoteHost = QStringLiteral("127.0.0.1");
Socket s(Socket::IPv4Protocol, Socket::TcpSocket);
bool ok = s.connect(remoteHost, US_PORT);
QString msg;\
msg.append("connecting to ").append(remoteHost).append(US_PORT).append("\n");
USLOG_QS(msg);
});
#endif
}
void setScreenW(qint32 w)
{
screenW = w;
}
void setScreenH(qint32 h)
{
screenW = h;
}
qint32 getScreenW(void)
{
return screenW;
}
qint32 getScreenH(void)
{
return screenH;
}
protected:
void initializeGL();
void paintGL();
void resizeGL(int w, int h);
private:
qint32 screenW;
qint32 screenH;
};
#endif // OPENGLWIDGET_H