From 37298b2232d6a0515fe957a4d4b99f514859c3d2 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Tue, 18 Mar 2014 12:33:11 +0800 Subject: [PATCH] gl: Qt<4.8 build error. No QGLFunctions, so need GLES2. works for meego --- src/GLWidgetRenderer.cpp | 11 +++++++++-- src/QtAV/GLWidgetRenderer.h | 8 +++++++- src/QtAV/QtAV_Global.h | 2 ++ src/QtAV/private/GLWidgetRenderer_p.h | 7 +++++-- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/GLWidgetRenderer.cpp b/src/GLWidgetRenderer.cpp index ac767d213..af69f71f8 100644 --- a/src/GLWidgetRenderer.cpp +++ b/src/GLWidgetRenderer.cpp @@ -20,7 +20,7 @@ ******************************************************************************/ #include "QtAV/GLWidgetRenderer.h" -#include "private/GLWidgetRenderer_p.h" +#include "QtAV/private/GLWidgetRenderer_p.h" #include #include #include @@ -88,7 +88,12 @@ namespace QtAV { // APIENTRY may be not defined(why? linux es2). or use QOPENGLF_APIENTRY // use QGLF_APIENTRY for Qt4 crash, why? APIENTRY is defined in windows header #ifndef APIENTRY +// QGLF_APIENTRY is in Qt4,8+ +#if defined(QGLF_APIENTRY) #define APIENTRY QGLF_APIENTRY +#elif defined(GL_APIENTRY) +#define APIENTRY GL_APIENTRY +#endif #endif typedef void (APIENTRY *type_glActiveTexture) (GLenum); static type_glActiveTexture qtav_glActiveTexture = 0; @@ -505,7 +510,7 @@ void GLWidgetRendererPrivate::upload(const QRect &roi) // we have to consider size of opengl format. set bytesPerLine here and change to width later texture_size[i] = QSize(video_frame.bytesPerLine(i), video_frame.planeHeight(i)); effective_tex_width[i] = video_frame.effectiveBytesPerLine(i); //store bytes here, modify as width later - effective_tex_width_ratio = qMin(1.0, (qreal)video_frame.effectiveBytesPerLine(i)/(qreal)video_frame.bytesPerLine(i)); + effective_tex_width_ratio = qMin((qreal)1.0, (qreal)video_frame.effectiveBytesPerLine(i)/(qreal)video_frame.bytesPerLine(i)); } qDebug("effective_tex_width_ratio=%f", effective_tex_width_ratio); plane0Size = video_frame.size(); @@ -809,8 +814,10 @@ void GLWidgetRenderer::initializeGL() //const QByteArray extensions(reinterpret_cast(glGetString(GL_EXTENSIONS))); d.hasGLSL = QGLShaderProgram::hasOpenGLShaderPrograms(); qDebug("OpenGL version: %d.%d hasGLSL: %d", format().majorVersion(), format().minorVersion(), d.hasGLSL); +#if QTAV_HAVE(QGLFUNCTIONS) initializeGLFunctions(); d.initializeGLFunctions(); +#endif //QTAV_HAVE(QGLFUNCTIONS) qtavResolveActiveTexture(); glEnable(GL_TEXTURE_2D); if (!d.hasGLSL) { diff --git a/src/QtAV/GLWidgetRenderer.h b/src/QtAV/GLWidgetRenderer.h index 1d7aed0f5..6dc6ae0bc 100644 --- a/src/QtAV/GLWidgetRenderer.h +++ b/src/QtAV/GLWidgetRenderer.h @@ -24,12 +24,18 @@ #include #include +// TODO: QGLFunctions is in Qt4.8+. meego is 4.7 +#if QTAV_HAVE(QGLFUNCTIONS) #include +#endif //QT_VERSION namespace QtAV { class GLWidgetRendererPrivate; -class Q_AV_EXPORT GLWidgetRenderer : public QGLWidget, public VideoRenderer, public QGLFunctions +class Q_AV_EXPORT GLWidgetRenderer : public QGLWidget, public VideoRenderer +#if QTAV_HAVE(QGLFUNCTIONS) //TODO: why use QT_VERSION will result in moc error? + , public QGLFunctions +#endif //QTAV_HAVE(QGLFUNCTIONS) { Q_OBJECT DPTR_DECLARE_PRIVATE(GLWidgetRenderer) diff --git a/src/QtAV/QtAV_Global.h b/src/QtAV/QtAV_Global.h index f4c47f789..d2b8d6734 100644 --- a/src/QtAV/QtAV_Global.h +++ b/src/QtAV/QtAV_Global.h @@ -56,6 +56,8 @@ Q_AV_EXPORT void setFFmpegLogHandler(void(*)(void *, int, const char *, va_list) */ #define QTAV_HAVE(FEATURE) (defined QTAV_HAVE_##FEATURE && QTAV_HAVE_##FEATURE) +#define QTAV_HAVE_QGLFUNCTIONS QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) + //TODO: always inline /* --gnu option of the RVCT compiler also defines __GNUC__ */ #if defined(Q_CC_GNU) && !defined(Q_CC_RVCT) diff --git a/src/QtAV/private/GLWidgetRenderer_p.h b/src/QtAV/private/GLWidgetRenderer_p.h index 56c77be18..38f070321 100644 --- a/src/QtAV/private/GLWidgetRenderer_p.h +++ b/src/QtAV/private/GLWidgetRenderer_p.h @@ -25,7 +25,7 @@ #include #include -#include "private/VideoRenderer_p.h" +#include "QtAV/private/VideoRenderer_p.h" #include #include @@ -33,7 +33,10 @@ namespace QtAV { -class Q_AV_EXPORT GLWidgetRendererPrivate : public VideoRendererPrivate, public QGLFunctions +class Q_AV_EXPORT GLWidgetRendererPrivate : public VideoRendererPrivate +#if QTAV_HAVE(QGLFUNCTIONS) + , public QGLFunctions +#endif //QTAV_HAVE(QGLFUNCTIONS) { public: GLWidgetRendererPrivate():