Skip to content

Commit

Permalink
Add GLSLFilter.fbo() to access filter result
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Apr 16, 2016
1 parent be209a5 commit 15e4afe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/QtAV/GLSLFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
#include <QtAV/QtAV_Global.h>
#include <QtAV/Filter.h>

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#undef QOpenGLFramebufferObject
#define QOpenGLFramebufferObject QGLFramebufferObject
#endif
QT_BEGIN_NAMESPACE
class QOpenGLFramebufferObject;
QT_END_NAMESPACE

namespace QtAV {
class OpenGLVideo;
class GLSLFilterPrivate;
Expand All @@ -44,7 +52,7 @@ class Q_AV_EXPORT GLSLFilter : public VideoFilter
* Currently you can only use it to set custom shader OpenGLVideo.setUserShader()
*/
OpenGLVideo* opengl() const;
// TODO: set FBO format
QOpenGLFramebufferObject* fbo() const;
/*!
* \brief outputSize
* Output frame size. FBO uses the same size to render. An empty size means using the input frame size
Expand Down
8 changes: 6 additions & 2 deletions src/filter/GLSLFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <QtGui/QOpenGLFramebufferObject>
#else
#include <QtOpenGL/QGLFramebufferObject>
#define QOpenGLFramebufferObject QGLFramebufferObject
#endif
#include "QtAV/SurfaceInterop.h"
#include "QtAV/OpenGLVideo.h"
Expand Down Expand Up @@ -58,6 +57,11 @@ OpenGLVideo* GLSLFilter::opengl() const
return const_cast<OpenGLVideo*>(&d_func().glv);
}

QOpenGLFramebufferObject* GLSLFilter::fbo() const
{
return d_func().fbo;
}

QSize GLSLFilter::outputSize() const
{
return d_func().size;
Expand Down Expand Up @@ -114,7 +118,7 @@ void GLSLFilter::process(Statistics *statistics, VideoFrame *frame)
QMatrix4x4 mat; // flip vertical
mat.scale(1, -1);
d.glv.render(QRectF(), QRectF(), mat);
d.fbo->bindDefault();
QOpenGLFramebufferObject::bindDefault();

VideoFormat fmt(VideoFormat::Format_RGB32);
VideoFrame f(d.fbo->width(), d.fbo->height(), fmt); //
Expand Down

0 comments on commit 15e4afe

Please sign in to comment.