diff options
author | wm4 <wm4@nowhere> | 2015-01-08 02:40:30 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-08 02:40:30 +0100 |
commit | f551fbaa25ac9930c6e5a3df372a4bd7acdd2811 (patch) | |
tree | 2bad3f3c5ced87b3e446f11c18f474414aef3af7 /DOCS/client_api_examples/qml_direct/main.h | |
parent | f52ec079b22a4dae732f759ac29746d1d7ca3076 (diff) | |
download | mpv-f551fbaa25ac9930c6e5a3df372a4bd7acdd2811.tar.bz2 mpv-f551fbaa25ac9930c6e5a3df372a4bd7acdd2811.tar.xz |
DOCS/client_api_examples: add an alternative qml example
This one avoids use of a FBO. It's less flexible, because it uses works
around the whole QML rendering API. It seems to be the only way to get
OpenGL rendering without any indirections, though.
Parts of this example were insipired by Qt's "Squircle" example.
Also add a README file with a short description of each example, to
reduce the initial confusing.
Diffstat (limited to 'DOCS/client_api_examples/qml_direct/main.h')
-rw-r--r-- | DOCS/client_api_examples/qml_direct/main.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/DOCS/client_api_examples/qml_direct/main.h b/DOCS/client_api_examples/qml_direct/main.h new file mode 100644 index 0000000000..90acdeedd2 --- /dev/null +++ b/DOCS/client_api_examples/qml_direct/main.h @@ -0,0 +1,49 @@ +#ifndef MPVRENDERER_H_ +#define MPVRENDERER_H_ + +#include <QtQuick/QQuickItem> + +#include <mpv/client.h> +#include <mpv/opengl_cb.h> +#include <mpv/qthelper.hpp> + +class MpvRenderer : public QObject +{ + Q_OBJECT + mpv::qt::Handle mpv; + mpv_opengl_cb_context *mpv_gl; + QQuickWindow *window; + + friend class MpvObject; +public: + MpvRenderer(mpv::qt::Handle a_mpv, mpv_opengl_cb_context *a_mpv_gl); + virtual ~MpvRenderer(); +public slots: + void paint(); +}; + +class MpvObject : public QQuickItem +{ + Q_OBJECT + + mpv::qt::Handle mpv; + mpv_opengl_cb_context *mpv_gl; + MpvRenderer *renderer; + +public: + MpvObject(QQuickItem * parent = 0); + virtual ~MpvObject(); +public slots: + void command(const QVariant& params); + void sync(); + void cleanup(); +signals: + void onUpdate(); +private slots: + void doUpdate(); + void handleWindowChanged(QQuickWindow *win); +private: + static void on_update(void *ctx); +}; + +#endif |