-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscreensaver.h
52 lines (34 loc) · 1.03 KB
/
screensaver.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
#ifndef SCREENSAVER_H
#define SCREENSAVER_H
#include <QQuickWindow>
#include <random>
#include <QRandomGenerator>
#include <QElapsedTimer>
#include <QQuickFramebufferObject>
#include <QOpenGLFramebufferObject>
#include "stick.h"
class Screensaver : public QQuickFramebufferObject
{
Q_OBJECT
public:
Renderer *createRenderer() const override;
};
class StickRenderer : public QQuickFramebufferObject::Renderer, protected QOpenGLFunctions
{
public:
StickRenderer();
qint64 elapsed() const { return _timer.elapsed(); }
void initializeGLCanvas();
void resizeGLCanvas(int width, int height);
void paintGLCanvas();
protected:
void render() override;
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size) override;
void synchronize(QQuickFramebufferObject *item) override;
private:
QVector<Stick*> _barSticks;
std::uniform_real_distribution<qreal> randomX, randomY, randomRadius;
std::uniform_real_distribution<qreal> randomFrequency, randomRatioRotation;
QElapsedTimer _timer;
};
#endif // SCREENSAVER_H