Commit c33134bd authored by dogmaphobic's avatar dogmaphobic

Fixing Android build.

parent 8983c746
......@@ -132,6 +132,7 @@ VideoEnabled {
$$PWD/gstqtvideosink/painters/videonode.h \
$$PWD/gstqtvideosink/utils/bufferformat.h \
$$PWD/gstqtvideosink/utils/utils.h \
$$PWD/gstqtvideosink/utils/glutils.h \
SOURCES += \
$$PWD/gstqtvideosink/delegates/basedelegate.cpp \
......
......@@ -27,7 +27,8 @@
#include <QStack>
#include <QPainter>
#include <QOpenGLFunctions_2_0>
#include "glutils.h"
QtVideoSinkDelegate::QtVideoSinkDelegate(GstElement *sink, QObject *parent)
: BaseDelegate(sink, parent)
......@@ -138,7 +139,7 @@ void QtVideoSinkDelegate::setGLContext(QGLContext *context)
if (m_glContext) {
m_glContext->makeCurrent();
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (funcs) {
const QByteArray extensions(reinterpret_cast<const char *>(funcs->glGetString(GL_EXTENSIONS)));
GST_LOG_OBJECT(m_sink, "Available GL extensions: %s", extensions.constData());
......@@ -230,7 +231,6 @@ void QtVideoSinkDelegate::changePainter(const BufferFormat & format)
void QtVideoSinkDelegate::destroyPainter()
{
GST_LOG_OBJECT(m_sink, "Destroying painter");
delete m_painter;
m_painter = 0;
}
......@@ -243,6 +243,5 @@ bool QtVideoSinkDelegate::event(QEvent *event)
destroyPainter();
}
}
return BaseDelegate::event(event);
}
......@@ -23,7 +23,8 @@
#include "openglsurfacepainter.h"
#include <QtCore/qmath.h>
#include <QOpenGLFunctions_2_0>
#include "glutils.h"
#ifndef GL_TEXTURE0
# define GL_TEXTURE0 0x84C0
......@@ -178,7 +179,7 @@ void OpenGLSurfacePainter::paint(quint8 *data,
QPainter *painter,
const PaintAreas & areas)
{
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (!funcs)
return;
......@@ -396,22 +397,17 @@ ArbFpSurfacePainter::ArbFpSurfacePainter()
, m_programId(0)
{
const QGLContext *context = QGLContext::currentContext();
glProgramStringARB = (_glProgramStringARB) context->getProcAddress(
QLatin1String("glProgramStringARB"));
glBindProgramARB = (_glBindProgramARB) context->getProcAddress(
QLatin1String("glBindProgramARB"));
glDeleteProgramsARB = (_glDeleteProgramsARB) context->getProcAddress(
QLatin1String("glDeleteProgramsARB"));
glGenProgramsARB = (_glGenProgramsARB) context->getProcAddress(
QLatin1String("glGenProgramsARB"));
glProgramLocalParameter4fARB = (_glProgramLocalParameter4fARB) context->getProcAddress(
QLatin1String("glProgramLocalParameter4fARB"));
glProgramStringARB = (_glProgramStringARB) context->getProcAddress(QLatin1String("glProgramStringARB"));
glBindProgramARB = (_glBindProgramARB) context->getProcAddress(QLatin1String("glBindProgramARB"));
glDeleteProgramsARB = (_glDeleteProgramsARB) context->getProcAddress(QLatin1String("glDeleteProgramsARB"));
glGenProgramsARB = (_glGenProgramsARB) context->getProcAddress(QLatin1String("glGenProgramsARB"));
glProgramLocalParameter4fARB = (_glProgramLocalParameter4fARB) context->getProcAddress(QLatin1String("glProgramLocalParameter4fARB"));
}
void ArbFpSurfacePainter::init(const BufferFormat &format)
{
Q_ASSERT(m_textureCount == 0);
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (!funcs)
return;
......@@ -501,7 +497,7 @@ void ArbFpSurfacePainter::init(const BufferFormat &format)
void ArbFpSurfacePainter::cleanup()
{
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (funcs)
{
funcs->glDeleteTextures(m_textureCount, m_textureIds);
......@@ -516,7 +512,7 @@ void ArbFpSurfacePainter::paintImpl(const QPainter *painter,
const GLfloat *textureCoordArray)
{
Q_UNUSED(painter);
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (!funcs)
return;
......@@ -734,14 +730,14 @@ void GlslSurfacePainter::init(const BufferFormat &format)
throw QString("Shader link error ") + m_program.log();
}
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (funcs)
funcs->glGenTextures(m_textureCount, m_textureIds);
}
void GlslSurfacePainter::cleanup()
{
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (funcs)
{
funcs->glDeleteTextures(m_textureCount, m_textureIds);
......@@ -795,8 +791,8 @@ void GlslSurfacePainter::paintImpl(const QPainter *painter,
m_program.setAttributeArray("textureCoordArray", textureCoordArray, 2);
m_program.setUniformValue("positionMatrix", positionMatrix);
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
if (funcs)
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (!funcs)
return;
if (m_textureCount == 3) {
......
......@@ -26,9 +26,10 @@
#include <qmath.h>
#include <QOpenGLContext>
#include <QOpenGLFunctions_2_0>
#include <QtQuick/QSGMaterialShader>
#include "glutils.h"
static const char * const qtvideosink_glsl_vertexShader =
"uniform highp mat4 qt_Matrix; \n"
"attribute highp vec4 qt_VertexPosition; \n"
......@@ -257,7 +258,7 @@ VideoMaterial::~VideoMaterial()
{
if (!m_textureSize.isEmpty())
{
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (funcs)
{
funcs->glDeleteTextures(m_textureCount, m_textureIds);
......@@ -329,7 +330,7 @@ void VideoMaterial::initYuv420PTextureInfo(bool uvSwapped, const QSize &size)
void VideoMaterial::init(GstVideoColorMatrix colorMatrixType)
{
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (funcs)
{
funcs->glGenTextures(m_textureCount, m_textureIds);
......@@ -421,7 +422,7 @@ void VideoMaterial::updateColors(int brightness, int contrast, int hue, int satu
void VideoMaterial::bind()
{
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (!funcs)
return;
......@@ -455,7 +456,7 @@ void VideoMaterial::bind()
void VideoMaterial::bindTexture(int i, const quint8 *data)
{
QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>();
QOpenGLFunctionsDef *funcs = getQOpenGLFunctions();
if (!funcs)
return;
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief QGC Video Item
* @author Gus Grubba <mavlink@grubba.com>
*/
#ifndef GLUTILS_H
#define GLUTILS_H
#ifdef __android__
#include <QOpenGLFunctions>
#define getQOpenGLFunctions() QOpenGLContext::currentContext()->functions()
#define QOpenGLFunctionsDef QOpenGLFunctions
#else
#include <QOpenGLFunctions_2_0>
#define getQOpenGLFunctions() QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_0>()
#define QOpenGLFunctionsDef QOpenGLFunctions_2_0
#endif
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment