-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwidget.h
101 lines (75 loc) · 2.18 KB
/
widget.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
98
99
100
101
#ifndef PLAYERWINDOW_H
#define PLAYERWINDOW_H
#include <QOpenGLWindow>
#include <mpv/client.h>
#include <mpv/render_gl.h>
#include "mpv-qthelper.hpp"
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
#include <QOpenGLFramebufferObject>
#include <QTimer>
class OhmdHandler;
#define DEFAULT_FOV 80
class MpvWidget Q_DECL_FINAL: public QOpenGLWindow //, protected QOpenGLFunctions
{
Q_OBJECT
public:
enum VideoProjectionMode
{
Monoscopic,
OverUnder,
SideBySide
} video_projection_mode = SideBySide;
MpvWidget();
~MpvWidget();
QSize sizeHint() const { return QSize(480, 270);}
void play(const char *path);
float videoAngle = 180;
public slots:
void on_mpv_events();
Q_SIGNALS:
void durationChanged(int value);
void positionChanged(int value);
protected:
void initializeGL() Q_DECL_OVERRIDE;
void paintGL() Q_DECL_OVERRIDE;
void showEvent(QShowEvent *e) override;
private Q_SLOTS:
void maybeUpdate();
void onScreenAdded();
void resizeFbo();
private:
void renderEye(int eye, const QMatrix4x4 &modelview, QMatrix4x4 projection);
void handle_mpv_event(mpv_event *event);
static void on_update(void *ctx);
mpv_handle *m_mpv = nullptr;
mpv_render_context *m_mpvGl = nullptr;
OhmdHandler *m_ohmd;
bool invert_stereo = true;
float m_fieldOfView = DEFAULT_FOV;
float m_distance = 100.f;
double m_duration = 0;
double m_position = 0;
float m_rotHor = 0, m_rotVert = 0;
QOpenGLShaderProgram *m_sphereShader = nullptr;
QOpenGLShaderProgram *m_distortionShader = nullptr;
QOpenGLBuffer m_cubeVbo;
QOpenGLBuffer m_indexBo;
QOpenGLVertexArrayObject m_cubeVao;
QOpenGLFramebufferObject *m_videoFbo = nullptr;
const char *m_path = nullptr;
QImage m_posImage;
QTimer m_updateFboTimer;
int m_videoWidth = 0;
int m_videoHeight = 0;
GLint m_maxTextureSize = 512;
//QPainterPath m_posString;
//QPainterPath m_posStringStroke;
protected:
void keyPressEvent(QKeyEvent *event) override;
quint32 sphereVbo[3];
quint32 nIndices;
};
#endif // PLAYERWINDOW_H