-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QT-OpenGL example now builds with Qt6 #59
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
QT += qml quick | ||
QT += qml quick quickcontrols2 | ||
|
||
HEADERS += main.h | ||
SOURCES += main.cpp | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This entire file is unncessary. The .pro file should be updated instead. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
Comment on lines
-9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
MainWindow w; | ||
w.show(); | ||
return a.exec(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,7 @@ void MpvWidget::initializeGL() | |
|
||
void MpvWidget::paintGL() | ||
{ | ||
mpv_opengl_fbo mpfbo{static_cast<int>(defaultFramebufferObject()), width(), height(), 0}; | ||
mpv_opengl_fbo mpfbo{static_cast<int>(defaultFramebufferObject()), (int) (width() * devicePixelRatio()), (int) (height() * devicePixelRatio()), 0}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Use new-style casts such as |
||
int flip_y{1}; | ||
|
||
mpv_render_param params[] = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave this as a generic
test.mkv
instead of a file on your own computer.