Skip to content

Commit

Permalink
gl: bind to old fbo when glsl is applied
Browse files Browse the repository at this point in the history
we can revert qml QuickFBORenderer commit about fbo rebinding
  • Loading branch information
wang-bin committed May 21, 2016
1 parent c300c7a commit c193a46
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/QtAV/GLSLFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ class Q_AV_EXPORT GLSLFilter : public VideoFilter
void outputSizeChanged(const QSize& size);
protected:
GLSLFilter(GLSLFilterPrivate& d, QObject *parent = 0);
/*!
* \brief process
* Draw video frame into fbo and apply the user shader from opengl()->userShader();
* \param frame input frame can be a frame holding host memory data, or any other GPU frame can interop with OpenGL texture (including frames from HW decoders in QtAV).
* Output frame holds an RGB texture, which can be processed in the next GPU filter, or rendered by OpenGL renderers.
* When process() is done, FBO before before process() is bounded.
*/
void process(Statistics* statistics, VideoFrame* frame = 0) Q_DECL_OVERRIDE;
};
} //namespace QtAV
Expand Down
5 changes: 3 additions & 2 deletions src/filter/GLSLFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ void GLSLFilter::process(Statistics *statistics, VideoFrame *frame)
DPTR_D(GLSLFilter);
if (!frame || !*frame)
return;
GLint currentFbo = 0;
DYGL(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &currentFbo));
// now use the frame size
if (d.fbo) {
if (d.size.isEmpty()) {
Expand Down Expand Up @@ -118,8 +120,7 @@ void GLSLFilter::process(Statistics *statistics, VideoFrame *frame)
QMatrix4x4 mat; // flip vertical
mat.scale(1, -1);
d.glv.render(QRectF(), QRectF(), mat);
QOpenGLFramebufferObject::bindDefault();

DYGL(glBindFramebuffer(GL_FRAMEBUFFER, (GLuint)currentFbo));
VideoFormat fmt(VideoFormat::Format_RGB32);
VideoFrame f(d.fbo->width(), d.fbo->height(), fmt); //
f.setBytesPerLine(d.fbo->width()*fmt.bytesPerPixel(), 0);
Expand Down

0 comments on commit c193a46

Please sign in to comment.