summaryrefslogtreecommitdiffstats
path: root/libmpv/wxwidgets_opengl/main.h
diff options
context:
space:
mode:
Diffstat (limited to 'libmpv/wxwidgets_opengl/main.h')
-rw-r--r--libmpv/wxwidgets_opengl/main.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/libmpv/wxwidgets_opengl/main.h b/libmpv/wxwidgets_opengl/main.h
new file mode 100644
index 0000000..14628ed
--- /dev/null
+++ b/libmpv/wxwidgets_opengl/main.h
@@ -0,0 +1,75 @@
+#pragma once
+
+#include <functional>
+
+#include <wx/wxprec.h>
+#ifndef WX_PRECOMP
+ #include <wx/wx.h>
+#endif
+
+#include <wx/glcanvas.h>
+
+#include <mpv/client.h>
+#include <mpv/opengl_cb.h>
+
+class MpvApp : public wxApp
+{
+public:
+ bool OnInit() override;
+};
+
+class MpvGLCanvas : public wxGLCanvas
+{
+public:
+ MpvGLCanvas(wxWindow *parent);
+ ~MpvGLCanvas();
+
+ void Render();
+ bool SetCurrent() const;
+ bool SwapBuffers() override;
+ void *GetProcAddress(const char *name);
+
+ std::function<void (wxGLCanvas *, int w, int h)> OnRender = nullptr;
+ std::function<void (wxGLCanvas *)> OnSwapBuffers = nullptr;
+
+private:
+ void OnSize(wxSizeEvent &event);
+ void OnPaint(wxPaintEvent &event);
+ void OnErase(wxEraseEvent &event);
+
+ void DoRender();
+
+ wxGLContext *glContext = nullptr;
+
+ wxDECLARE_EVENT_TABLE();
+};
+
+class MpvFrame : public wxFrame
+{
+public:
+ MpvFrame();
+
+ bool Destroy() override;
+ bool Autofit(int percent, bool larger = true, bool smaller = true);
+
+private:
+ void MpvCreate();
+ void MpvDestroy();
+
+ void OnSize(wxSizeEvent &event);
+ void OnKeyDown(wxKeyEvent &event);
+ void OnDropFiles(wxDropFilesEvent &event);
+
+ void OnMpvEvent(mpv_event &event);
+ void OnMpvWakeupEvent(wxThreadEvent &event);
+ void OnMpvRedrawEvent(wxThreadEvent &event);
+
+ void DoMpvDraw(int w, int h);
+ void DoMpvFlip();
+
+ mpv_handle *mpv = nullptr;
+ mpv_opengl_cb_context *mpv_gl = nullptr;
+ MpvGLCanvas *glCanvas = nullptr;
+
+ wxDECLARE_EVENT_TABLE();
+};