Skip to content

Commit

Permalink
gl: Qt<4.8 build error. No QGLFunctions, so need GLES2. works for meego
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Mar 18, 2014
1 parent 7a13caa commit 37298b2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/GLWidgetRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 20,7 @@
******************************************************************************/

#include "QtAV/GLWidgetRenderer.h"
#include "private/GLWidgetRenderer_p.h"
#include "QtAV/private/GLWidgetRenderer_p.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QFile>
#include <QtCore/qmath.h>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -809,8 814,10 @@ void GLWidgetRenderer::initializeGL()
//const QByteArray extensions(reinterpret_cast<const char *>(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) {
Expand Down
8 changes: 7 additions & 1 deletion src/QtAV/GLWidgetRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 24,18 @@

#include <QtAV/VideoRenderer.h>
#include <QtOpenGL/QGLWidget>
// TODO: QGLFunctions is in Qt4.8 . meego is 4.7
#if QTAV_HAVE(QGLFUNCTIONS)
#include <QtOpenGL/QGLFunctions>
#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)
Expand Down
2 changes: 2 additions & 0 deletions src/QtAV/QtAV_Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions src/QtAV/private/GLWidgetRenderer_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 25,18 @@
#include <QtOpenGL/QGLShaderProgram>

#include <QtCore/QVector>
#include "private/VideoRenderer_p.h"
#include "QtAV/private/VideoRenderer_p.h"
#include <QtAV/VideoFormat.h>
#include <QtAV/ColorTransform.h>

#define NO_QGL_SHADER (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))

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():
Expand Down

0 comments on commit 37298b2

Please sign in to comment.