cleaned up texture and texture reading classes

This commit is contained in:
itsmattkc
2019-12-21 21:30:42 +11:00
parent a8a5e50d3a
commit 4cb6659dbb
4 changed files with 4 additions and 42 deletions
+2 -2
View File
@@ -64,7 +64,7 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture)
// Perform OpenGL read
buffer_.Attach(texture_);
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, buffer_.buffer());
buffer_.Bind();
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(params_.format());
@@ -76,7 +76,7 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture)
format_info.gl_pixel_type,
frame->data());
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
buffer_.Release();
buffer_.Detach();
return frame;
@@ -156,39 +156,6 @@ void OpenGLTexture::Upload(const void *data)
Release();
}
uchar *OpenGLTexture::Download() const
{
if (!IsCreated()) {
qWarning() << "OpenGLTexture::Download() called while it wasn't created";
return nullptr;
}
QOpenGLContext* context = QOpenGLContext::currentContext();
QOpenGLFunctions* f = context->functions();
GLuint read_fbo;
f->glGenFramebuffers(1, &read_fbo);
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, read_fbo);
context->extraFunctions()->glFramebufferTexture2D(
GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_, 0
);
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(format_);
uchar* data = new uchar[PixelService::GetBufferSize(format_, width_, height_)];
f->glReadPixels(0, 0, width_, height_, format_info.pixel_format, format_info.gl_pixel_type, data);
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
f->glDeleteFramebuffers(1, &read_fbo);
return data;
}
void OpenGLTexture::CreateInternal(QOpenGLContext* create_ctx, GLuint* tex, const void *data)
{
QOpenGLFunctions* f = create_ctx->functions();
@@ -59,8 +59,6 @@ public:
void Upload(const void *data);
uchar *Download() const;
public slots:
void Destroy();
+2 -5
View File
@@ -121,8 +121,6 @@ void OpenGLWorker::FrameToValue(StreamPtr stream, FramePtr frame, NodeValueTable
buffer_.Detach();
footage_tex_ref = associated_tex_ref;
functions_->glFinish();
}
table->Push(NodeParam::kTexture, QVariant::fromValue(footage_tex_ref));
@@ -337,7 +335,6 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const TimeRange &range,
// Make sure all OpenGL functions are complete by this point before unlocking the shader (or another thread may
// change its parameters before our drawing in this thread is done)
functions_->glFinish();
shader->Unlock();
// Release any textures we bound before
@@ -362,7 +359,7 @@ void OpenGLWorker::TextureToBuffer(const QVariant &tex_in, QByteArray &buffer)
QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions();
buffer_.Attach(texture->texture());
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, buffer_.buffer());
buffer_.Bind();
f->glReadPixels(0,
0,
@@ -372,7 +369,7 @@ void OpenGLWorker::TextureToBuffer(const QVariant &tex_in, QByteArray &buffer)
format_info.gl_pixel_type,
buffer.data());
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
buffer_.Release();
buffer_.Detach();
}