began transition to gles

This commit is contained in:
itsmattkc
2019-03-17 15:53:54 +11:00
parent eef306ff1e
commit c8496ac2a8
10 changed files with 134 additions and 15 deletions
+7 -5
View File
@@ -1,6 +1,8 @@
#include "framebufferobject.h"
#include <QOpenGLFunctions>
#include <QOpenGLExtraFunctions>
#include <QDebug>
FramebufferObject::FramebufferObject() :
buffer_(0),
@@ -39,16 +41,16 @@ void FramebufferObject::Create(QOpenGLContext *ctx, int width, int height)
ctx->functions()->glBindTexture(GL_TEXTURE_2D, texture_);
// allocate storage for texture
ctx->functions()->glTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr
glTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA8, GL_UNSIGNED_BYTE, nullptr
);
// set texture filtering to bilinear
ctx->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
ctx->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// attach texture to framebuffer
ctx->functions()->glFramebufferTexture2D(
ctx->extraFunctions()->glFramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_, 0
);
+17 -1
View File
@@ -316,6 +316,7 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
} else {
// retrieve ID from c->texture
textureID = c->texture->textureId();
qDebug() << "tex 1" << textureID;
}
if (textureID == 0) {
@@ -359,18 +360,22 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
params.nests.removeLast();
// compose_sequence() would have written to this clip's fbo[0], so we switch to fbo[1]
fbo_switcher = true;
fbo_switcher = !fbo_switcher;
} else if (c->media()->get_type() == MEDIA_TYPE_FOOTAGE) {
if (!c->media()->to_footage()->alpha_is_premultiplied) {
// alpha is not premultiplied, we'll need to multiply it for the rest of the pipeline
params.ctx->functions()->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ZERO, GL_ONE, GL_ZERO);
qDebug() << "about to draw on" << fbo_switcher;
textureID = draw_clip(c->fbo[fbo_switcher], textureID, true);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
fbo_switcher = !fbo_switcher;
qDebug() << "tex 3" << textureID << fbo_switcher;
}
#ifndef NO_OCIO
@@ -382,11 +387,14 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
params.ocio_shader->setUniformValue("tex1", 0);
params.ocio_shader->setUniformValue("tex2", 2);
qDebug() << "about to draw on" << fbo_switcher;
textureID = draw_clip(c->fbo[fbo_switcher], textureID, true);
params.ocio_shader->release();
fbo_switcher = !fbo_switcher;
qDebug() << "tex 4" << textureID << fbo_switcher;
}
#endif
@@ -414,8 +422,11 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
// run through all of the clip's effects
for (int j=0;j<c->effects.size();j++) {
Effect* e = c->effects.at(j).get();
qDebug() << "about to draw on" << fbo_switcher;
process_effect(c, e, timecode, coords, textureID, fbo_switcher, params.texture_failed, kTransitionNone);
qDebug() << "tex 5" << textureID << fbo_switcher;
}
@@ -457,6 +468,7 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
qDebug() << "final texture ID" << textureID;
if (textureID > 0) {
// set viewport to sequence size
params.ctx->functions()->glViewport(0, 0, s->width, s->height);
@@ -549,6 +561,8 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
// Check if we're using a blend mode (< 0 means no blend mode)
if (coords.blendmode < 0) {
qDebug() << "normal blending";
params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, backend_tex_1);
glColor4f(coords.opacity, coords.opacity, coords.opacity, coords.opacity);
@@ -559,6 +573,8 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
} else {
qDebug() << "blending mode?";
// load background texture into texture unit 0
params.ctx->functions()->glActiveTexture(GL_TEXTURE0 + 0); // Texture unit 0
params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, backend_tex_2);
+3 -3
View File
@@ -24,6 +24,7 @@
#include <QImage>
#include <QDateTime>
#include <QFileInfo>
#include <QOpenGLExtraFunctions>
#include <QDebug>
#ifndef NO_OCIO
@@ -160,7 +161,6 @@ const char * g_fragShaderText = ""
#ifndef NO_OCIO
void RenderThread::set_up_ocio()
{
functions.initializeOpenGLFunctions();
//
// SETUP LUT TEXTURE
@@ -181,7 +181,7 @@ void RenderThread::set_up_ocio()
ctx->functions()->glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
// Allocate storage for texture
functions.glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB16F_ARB,
ctx->extraFunctions()->glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB16F_ARB,
OCIO_LUT3D_EDGE_SIZE, OCIO_LUT3D_EDGE_SIZE, OCIO_LUT3D_EDGE_SIZE,
0, GL_RGB,GL_FLOAT, ocio_lut_data);
@@ -241,7 +241,7 @@ void RenderThread::set_up_ocio()
processor->getGpuLut3D(ocio_lut_data, shaderDesc);
glBindTexture(GL_TEXTURE_3D, ocio_lut_texture);
functions.glTexSubImage3D(GL_TEXTURE_3D, 0,
ctx->extraFunctions()->glTexSubImage3D(GL_TEXTURE_3D, 0,
0, 0, 0,
OCIO_LUT3D_EDGE_SIZE, OCIO_LUT3D_EDGE_SIZE, OCIO_LUT3D_EDGE_SIZE,
GL_RGB,GL_FLOAT, ocio_lut_data);
-3
View File
@@ -28,7 +28,6 @@
#include <QOpenGLContext>
#include <QOpenGLFramebufferObject>
#include <QOpenGLShaderProgram>
#include <QOpenGLFunctions_2_0>
#include "timeline/sequence.h"
#include "effects/effect.h"
@@ -119,8 +118,6 @@ private:
QString save_fn;
GLvoid *pixel_buffer;
int pixel_buffer_linesize;
QOpenGLFunctions_2_0 functions;
};
#endif // RENDERTHREAD_H