update opengl exporter to pass encoderptr along to exporter base class

This commit is contained in:
itsmattkc
2019-12-21 20:40:09 +11:00
parent 04d39e27a8
commit a8a5e50d3a
2 changed files with 27 additions and 3 deletions
+21 -2
View File
@@ -1,9 +1,10 @@
#include "openglexporter.h"
#include "render/backend/opengl/functions.h"
#include "render/pixelservice.h"
OpenGLExporter::OpenGLExporter(ViewerOutput* viewer, const VideoRenderingParams& params, const QMatrix4x4& transform, ColorProcessorPtr color_processor, QObject* parent) :
Exporter(viewer, params, transform, color_processor, parent)
OpenGLExporter::OpenGLExporter(ViewerOutput* viewer, const VideoRenderingParams& params, const QMatrix4x4 &transform, ColorProcessorPtr color_processor, EncoderPtr encoder, QObject* parent) :
Exporter(viewer, params, transform, color_processor, encoder, parent)
{
}
@@ -44,6 +45,9 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture)
frame->set_format(params_.format());
frame->allocate();
QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions();
f->glViewport(0, 0, texture_->width(), texture_->height());
// Blit for transform if the width/height are different
OpenGLTexturePtr input_tex = texture.value<OpenGLTexturePtr>();
if (input_tex) {
@@ -59,6 +63,21 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture)
}
// Perform OpenGL read
buffer_.Attach(texture_);
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, buffer_.buffer());
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(params_.format());
f->glReadPixels(0,
0,
texture_->width(),
texture_->height(),
format_info.pixel_format,
format_info.gl_pixel_type,
frame->data());
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
buffer_.Detach();
return frame;
}
+6 -1
View File
@@ -10,7 +10,12 @@
class OpenGLExporter : public Exporter
{
public:
OpenGLExporter(ViewerOutput *viewer, const VideoRenderingParams &params, const QMatrix4x4 &transform, ColorProcessorPtr color_processor, QObject* parent = nullptr);
OpenGLExporter(ViewerOutput* viewer,
const VideoRenderingParams& params,
const QMatrix4x4& transform,
ColorProcessorPtr color_processor,
EncoderPtr encoder,
QObject* parent = nullptr);
virtual ~OpenGLExporter() override;