diff --git a/libmpv/qml/main.cpp b/libmpv/qml/main.cpp index 6aac9b9..60305eb 100644 --- a/libmpv/qml/main.cpp +++ b/libmpv/qml/main.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -75,7 +75,7 @@ class MpvRenderer : public QQuickFramebufferObject::Renderer void render() { - obj->window()->resetOpenGLState(); + obj->window()->beginExternalCommands(); QOpenGLFramebufferObject *fbo = framebufferObject(); mpv_opengl_fbo mpfbo{.fbo = static_cast(fbo->handle()), .w = fbo->width(), .h = fbo->height(), .internal_format = 0}; @@ -95,7 +95,7 @@ class MpvRenderer : public QQuickFramebufferObject::Renderer // other API details. mpv_render_context_render(obj->mpv_gl, params); - obj->window()->resetOpenGLState(); + obj->window()->endExternalCommands(); } }; @@ -152,7 +152,7 @@ void MpvObject::setProperty(const QString& name, const QVariant& value) QQuickFramebufferObject::Renderer *MpvObject::createRenderer() const { - window()->setPersistentOpenGLContext(true); + window()->setPersistentGraphics(true); window()->setPersistentSceneGraph(true); return new MpvRenderer(const_cast(this)); } diff --git a/libmpv/qml/main.qml b/libmpv/qml/main.qml index 2ec75fd..979825a 100644 --- a/libmpv/qml/main.qml +++ b/libmpv/qml/main.qml @@ -1,5 +1,5 @@ import QtQuick 2.0 -import QtQuick.Controls 1.0 +import QtQuick.Controls 2.0 import mpvtest 1.0 @@ -13,7 +13,7 @@ Item { MouseArea { anchors.fill: parent - onClicked: renderer.command(["loadfile", "test.mkv"]) + onClicked: renderer.command(["loadfile", "C:/Users/Siddhant/Downloads/orig cut.mp4"]) } } @@ -61,8 +61,8 @@ Item { anchors.margins: 10 anchors.left: checkbox.left anchors.right: checkbox.right - minimumValue: -100 - maximumValue: 100 + from: -100 + to: 100 value: 0 onValueChanged: renderer.setProperty("gamma", slider.value | 0) } diff --git a/libmpv/qml/mpvtest.pro b/libmpv/qml/mpvtest.pro index 0b2e96f..e7e13dd 100644 --- a/libmpv/qml/mpvtest.pro +++ b/libmpv/qml/mpvtest.pro @@ -1,4 +1,4 @@ -QT += qml quick +QT += qml quick quickcontrols2 HEADERS += main.h SOURCES += main.cpp diff --git a/libmpv/qt_opengl/CMakeLists.txt b/libmpv/qt_opengl/CMakeLists.txt new file mode 100644 index 0000000..d1af72e --- /dev/null +++ b/libmpv/qt_opengl/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.16) +project(qt_opengl VERSION 1.0 LANGUAGES C CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Gui OpenGLWidgets) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(MPV REQUIRED IMPORTED_TARGET mpv) + +qt_standard_project_setup() + +qt_add_executable(qt_opengl WIN32 MACOSX_BUNDLE + main.cpp + mainwindow.cpp mainwindow.h + mpvwidget.cpp mpvwidget.h +) + + +target_include_directories(qt_opengl PUBLIC ${MPV_INCLUDE_DIRS}) +target_compile_options(qt_opengl PUBLIC ${MPV_CFLAGS_OTHER}) +#target_link_libraries(qt_opengl ${MPV_LIBRARIES}) + +target_link_libraries(qt_opengl + #PUBLIC {MPV_LIBRARIES} + PUBLIC PkgConfig::MPV + PRIVATE + Qt::Core + Qt::Gui + Qt::OpenGLWidgets +) + + +install(TARGETS qt_opengl + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) + +qt_generate_deploy_app_script( + TARGET qt_opengl + FILENAME_VARIABLE deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR +) +install(SCRIPT ${deploy_script}) diff --git a/libmpv/qt_opengl/main.cpp b/libmpv/qt_opengl/main.cpp index 086a4b4..a7d0d77 100644 --- a/libmpv/qt_opengl/main.cpp +++ b/libmpv/qt_opengl/main.cpp @@ -6,7 +6,8 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); // Qt sets the locale in the QApplication constructor, but libmpv requires // the LC_NUMERIC category to be set to "C", so change it back. - setlocale(LC_NUMERIC, "C"); + //setlocale(LC_NUMERIC, "C"); + // Commented because it's not compiling on macOS MainWindow w; w.show(); return a.exec(); diff --git a/libmpv/qt_opengl/mpvwidget.cpp b/libmpv/qt_opengl/mpvwidget.cpp index 07169bc..44ec7fc 100644 --- a/libmpv/qt_opengl/mpvwidget.cpp +++ b/libmpv/qt_opengl/mpvwidget.cpp @@ -75,7 +75,7 @@ void MpvWidget::initializeGL() void MpvWidget::paintGL() { - mpv_opengl_fbo mpfbo{static_cast(defaultFramebufferObject()), width(), height(), 0}; + mpv_opengl_fbo mpfbo{static_cast(defaultFramebufferObject()), (int) (width() * devicePixelRatio()), (int) (height() * devicePixelRatio()), 0}; int flip_y{1}; mpv_render_param params[] = { diff --git a/libmpv/qt_opengl/mpvwidget.h b/libmpv/qt_opengl/mpvwidget.h index ec134ac..b4ad734 100644 --- a/libmpv/qt_opengl/mpvwidget.h +++ b/libmpv/qt_opengl/mpvwidget.h @@ -1,7 +1,7 @@ #ifndef PLAYERWINDOW_H #define PLAYERWINDOW_H -#include +#include #include #include #include "../common/qthelper.hpp" @@ -10,7 +10,7 @@ class MpvWidget Q_DECL_FINAL: public QOpenGLWidget { Q_OBJECT public: - MpvWidget(QWidget *parent = 0, Qt::WindowFlags f = 0); + MpvWidget(QWidget *parent = 0, Qt::WindowFlags f = Qt::WindowFlags()); ~MpvWidget(); void command(const QVariant& params); void setProperty(const QString& name, const QVariant& value); diff --git a/libmpv/qt_opengl/qt_opengl.pro b/libmpv/qt_opengl/qt_opengl.pro index 8a2bcc6..304288a 100644 --- a/libmpv/qt_opengl/qt_opengl.pro +++ b/libmpv/qt_opengl/qt_opengl.pro @@ -1,5 +1,5 @@ CONFIG -= app_bundle -QT += widgets +QT += openglwidgets QT_CONFIG -= no-pkg-config CONFIG += link_pkgconfig debug