[vlc-commits] [Git][videolan/vlc][master] 10 commits: contrib: qt: install libqtmain.a for docs/

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Thu Jul 1 19:59:27 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
1c1739de by Alexandre Janniaux at 2021-07-01T16:24:23+00:00
contrib: qt: install libqtmain.a for docs/

It allows the QtGL example to be built with the following commandline:

unidan at DESKTOP-A5FN7E8:~/vlc/doc/libvlc/QtGL$ env \
PKG_CONFIG_SYSROOT_DIR=/ \
PKG_CONFIG_LIBDIR=$(realpath ${CONTRIB_PREFIX}/lib/pkgconfig/) \
PKG_CONFIG_PATH=$(realpath ${INSTALL_PREFIX}/lib/pkgconfig/) \
../../../build-win64/contrib/x86_64-w64-mingw32/lib/qt5/bin/qmake

where the path for ${INSTALL_PREFIX} is made of the --prefix value forwarded
to the configure script, where files are copied after `$MAKE install`.

- - - - -
930b5ef4 by Steve Lhomme at 2021-07-01T16:24:23+00:00
doc: QtPlayer: add QWindowsIntegrationPlugin plugin

Similar to the one in the QtGl sample.

- - - - -
1e09fce3 by Steve Lhomme at 2021-07-01T16:24:23+00:00
doc: QtGl: don't condition plugin import based on QT_STATICPLUGIN

QT_STATICPLUGIN is only used to export plugins, it has no impact on importing
plugins (see qplugin.h).

- - - - -
1d80e395 by Steve Lhomme at 2021-07-01T16:24:23+00:00
doc: QtGl: set the shader precision

On Windows if I don't set this I get the following error:

QOpenGLShader::compile(Fragment): ERROR: 0:3: '' : No precision specified for (float)
ERROR: 0:8: ';' : syntax error

- - - - -
fd58e148 by Steve Lhomme at 2021-07-01T16:24:23+00:00
doc: QtGl: replace std::mutex with QMutex

std::mutex is not available on some platforms (mingw64 with gcc for example).

- - - - -
ff816e40 by Steve Lhomme at 2021-07-01T16:24:23+00:00
doc: QtGl: remove unused private variables

- - - - -
4b60c03d by Steve Lhomme at 2021-07-01T16:24:23+00:00
doc: QtGl: fix usage of OpenGL functions when running in Qt

glActiveTexture doesn't exist in opengl32.dll on Windows.

Co-Authored-By: Alexandre Janniaux <ajanni at videolabs.io>

- - - - -
ce4e4085 by Alexandre Janniaux at 2021-07-01T16:24:23+00:00
doc: QtPlayer: check _WIN32 for windows plugins

QWindowsIntegrationPlugin is supposed to be linked against only when the
example is being compiled for Windows platform.

- - - - -
f3f32481 by Alexandre Janniaux at 2021-07-01T16:24:23+00:00
doc: QtGL: check _WIN32 for windows plugins

QWindowsIntegrationPlugin is supposed to be linked against only when the
example is being compiled for Windows platform.

- - - - -
febdeca0 by Alexandre Janniaux at 2021-07-01T16:24:23+00:00
doc: QtGL: conditionnally set precision qualifier

Precision is available but no-op on GLSL 130 (see [3], section 4.5.2)
and mandatory for OpenGL ES. It was first reserved on GLSL 120 and
didn't exist in GLSL <= 110 (= OpenGL 2.0). Since it's a no-op, the
easiest solution is to never use it for OpenGL code.

This description is also copied into the sample to explain to the users
that they might have difference in behaviour depending on whether they
are using OpenGL or OpenGL ES2, and depending on the version of OpenGL
used.

The precision qualifier was added because Qt was linked from the
contribs, which was linked with -opengl angle and thus was actually
using OpenGL ES2, which needs the precision qualifier.

Resources used:
[1]: https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.10.pdf
[2]: https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.20.pdf
[3]: https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.30.pdf

- - - - -


4 changed files:

- contrib/src/qt/rules.mak
- doc/libvlc/QtGL/main.cpp
- doc/libvlc/QtGL/qtvlcwidget.cpp
- doc/libvlc/QtPlayer/main.cpp


Changes:

=====================================
contrib/src/qt/rules.mak
=====================================
@@ -129,4 +129,9 @@ endif
 	sed -i -e "s#\$\$QT_MODULE_INCLUDE_BASE#$(PREFIX)/lib/qt5/include#g" $(PREFIX)/lib/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri
 	# Install a qmake with correct paths set
 	cd $< && $(MAKE) sub-qmake-qmake-aux-pro-install_subtargets install_mkspecs
+ifdef HAVE_WIN32
+	# Install libqtmain for potentially other targets, eg. docs/ samples
+	$(MAKE) -C "$</src/winmain" all
+	$(MAKE) -C "$</src/winmain" install
+endif
 	touch $@


=====================================
doc/libvlc/QtGL/main.cpp
=====================================
@@ -5,9 +5,9 @@
 
 #ifdef QT_STATIC
 # include <QtPlugin>
-#ifdef QT_STATICPLUGIN
+# ifdef _WIN32
 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
-#endif
+# endif
 #endif
 
 


=====================================
doc/libvlc/QtGL/qtvlcwidget.cpp
=====================================
@@ -7,10 +7,9 @@
 #include <QOffscreenSurface>
 #include <QThread>
 #include <QSemaphore>
+#include <QMutex>
 #include <cmath>
 
-#include <mutex>
-
 #include <vlc/vlc.h>
 
 class VLCVideo
@@ -58,7 +57,7 @@ public:
     /// return the texture to be displayed
     QOpenGLFramebufferObject *getVideoFrame()
     {
-        std::lock_guard<std::mutex> lock(m_text_lock);
+        QMutexLocker locker(&m_text_lock);
         if (m_updated) {
             std::swap(m_idx_swap, m_idx_display);
             m_updated = false;
@@ -134,7 +133,7 @@ public:
     static void swap(void* data)
     {
         VLCVideo* that = static_cast<VLCVideo*>(data);
-        std::lock_guard<std::mutex> lock(that->m_text_lock);
+        QMutexLocker locker(&that->m_text_lock);
         that->m_updated = true;
         that->mWidget->update();
         std::swap(that->m_idx_swap, that->m_idx_render);
@@ -176,10 +175,8 @@ private:
     //FBO data
     unsigned m_width = 0;
     unsigned m_height = 0;
-    std::mutex m_text_lock;
+    QMutex m_text_lock;
     QOpenGLFramebufferObject *mBuffers[3];
-    GLuint m_tex[3];
-    GLuint m_fbo[3];
     size_t m_idx_render = 0;
     size_t m_idx_swap = 1;
     size_t m_idx_display = 2;
@@ -287,6 +284,20 @@ static const char *vertexShaderSource =
     "}\n";
 
 static const char *fragmentShaderSource =
+    /* Precision is available but no-op on GLSL 130 (see [3], section 4.5.2)
+     * and mandatory for OpenGL ES. It was first reserved on GLSL 120 and
+     * didn't exist in GLSL <= 110 (= OpenGL 2.0). Since it's a no-op, the
+     * easiest solution is to never use it for OpenGL code.
+     *
+     * [1]: https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.10.pdf
+     * [2]: https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.20.pdf
+     * [3]: https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.30.pdf
+     */
+    "#ifdef GL_ES\n"
+    "precision highp float;\n"
+    "#endif\n"
+
+    "\n"
     "uniform sampler2D texture;\n"
     "\n"
     "varying vec2 texcoord;\n"
@@ -340,15 +351,16 @@ void QtVLCWidget::initializeGL()
 
 void QtVLCWidget::paintGL()
 {
+    QOpenGLFunctions *GL = context()->functions();
     QOpenGLFramebufferObject *fbo = mVLC->getVideoFrame();
-    if (fbo != NULL)
+    if (fbo != NULL && GL != NULL)
     {
         m_program->bind();
 
-        glClearColor(1.0, 0.5, 0.0, 1.0);
+        GL->glClearColor(1.0, 0.5, 0.0, 1.0);
 
-        glActiveTexture(GL_TEXTURE0);
-        glBindTexture(GL_TEXTURE_2D, fbo->takeTexture());
+        GL->glActiveTexture(GL_TEXTURE0);
+        GL->glBindTexture(GL_TEXTURE_2D, fbo->takeTexture());
 
         vertexBuffer.bind();
         m_program->setAttributeArray("position", (const QVector2D *)nullptr, sizeof(GLfloat)*2);
@@ -357,7 +369,7 @@ void QtVLCWidget::paintGL()
         m_program->enableAttributeArray("position");
 
         vertexIndexBuffer.bind();
-        glDrawElements(
+        GL->glDrawElements(
             GL_TRIANGLE_STRIP,  /* mode */
             4,                  /* count */
             GL_UNSIGNED_SHORT,  /* type */


=====================================
doc/libvlc/QtPlayer/main.cpp
=====================================
@@ -12,6 +12,13 @@
     #include <X11/Xlib.h>
 #endif
 
+#ifdef QT_STATIC
+# include <QtPlugin>
+# ifdef _WIN32
+Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
+# endif
+#endif
+
 int main(int argc, char *argv[]) {
 #ifdef Q_WS_X11
     XInitThreads();



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1fb307f7dcddd3dd2887aaa6eeb1deda904ddba3...febdeca0b46551500563cf3f2b058f81c1814079

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1fb307f7dcddd3dd2887aaa6eeb1deda904ddba3...febdeca0b46551500563cf3f2b058f81c1814079
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list