began transition to gles
This commit is contained in:
@@ -5,5 +5,7 @@
|
||||
<file>cornerpin.vert</file>
|
||||
<file>premultiply.frag</file>
|
||||
<file>dropshadow.frag</file>
|
||||
<file>pipeline.frag</file>
|
||||
<file>pipeline.vert</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump int;
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform sampler2D texture;
|
||||
varying vec2 v_texcoord;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D(texture, v_texcoord);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump int;
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform mat4 mvp_matrix;
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord;
|
||||
|
||||
varying vec2 v_texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = mvp_matrix * a_position;
|
||||
v_texcoord = a_texcoord;
|
||||
};
|
||||
@@ -109,7 +109,9 @@ int main(int argc, char *argv[]) {
|
||||
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||
|
||||
QSurfaceFormat format;
|
||||
format.setVersion(3, 2);
|
||||
format.setDepthBufferSize(24);
|
||||
format.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
|
||||
@@ -316,6 +316,7 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
} 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 ¶ms) {
|
||||
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 ¶ms) {
|
||||
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 ¶ms) {
|
||||
|
||||
// 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 ¶ms) {
|
||||
|
||||
|
||||
|
||||
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 ¶ms) {
|
||||
// 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 ¶ms) {
|
||||
|
||||
} 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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
+71
-2
@@ -27,6 +27,7 @@ extern "C" {
|
||||
#include <QPainter>
|
||||
#include <QAudioOutput>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLExtraFunctions>
|
||||
#include <QtMath>
|
||||
#include <QMouseEvent>
|
||||
#include <QMimeData>
|
||||
@@ -39,6 +40,8 @@ extern "C" {
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QMessageBox>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
|
||||
#include "panels/panels.h"
|
||||
#include "project/projectelements.h"
|
||||
@@ -68,7 +71,8 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
gizmos(nullptr),
|
||||
selected_gizmo(nullptr),
|
||||
x_scroll(0),
|
||||
y_scroll(0)
|
||||
y_scroll(0),
|
||||
pipeline_(nullptr)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
@@ -82,6 +86,8 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
connect(renderer, SIGNAL(finished()), renderer, SLOT(deleteLater()));
|
||||
|
||||
window = new ViewerWindow(this);
|
||||
|
||||
projection_.setToIdentity();
|
||||
}
|
||||
|
||||
ViewerWidget::~ViewerWidget() {
|
||||
@@ -216,9 +222,14 @@ void ViewerWidget::retry() {
|
||||
}
|
||||
|
||||
void ViewerWidget::initializeGL() {
|
||||
initializeOpenGLFunctions();
|
||||
context()->functions()->initializeOpenGLFunctions();
|
||||
|
||||
connect(context(), SIGNAL(aboutToBeDestroyed()), this, SLOT(context_destroy()), Qt::DirectConnection);
|
||||
|
||||
pipeline_ = new QOpenGLShaderProgram();
|
||||
pipeline_->addShaderFromSourceFile(QOpenGLShader::Vertex, ":/internalshaders/pipeline.vert");
|
||||
pipeline_->addShaderFromSourceFile(QOpenGLShader::Fragment, ":/internalshaders/pipeline.frag");
|
||||
pipeline_->link();
|
||||
}
|
||||
|
||||
void ViewerWidget::frame_update() {
|
||||
@@ -252,10 +263,16 @@ void ViewerWidget::seek_from_click(int x) {
|
||||
|
||||
void ViewerWidget::context_destroy() {
|
||||
makeCurrent();
|
||||
|
||||
if (viewer->seq != nullptr) {
|
||||
close_active_clips(viewer->seq.get());
|
||||
}
|
||||
|
||||
renderer->delete_ctx();
|
||||
|
||||
delete pipeline_;
|
||||
pipeline_ = nullptr;
|
||||
|
||||
doneCurrent();
|
||||
}
|
||||
|
||||
@@ -539,6 +556,57 @@ void ViewerWidget::draw_gizmos() {
|
||||
}
|
||||
|
||||
void ViewerWidget::paintGL() {
|
||||
QOpenGLFunctions* f = context()->functions();
|
||||
QOpenGLExtraFunctions* xf = context()->extraFunctions();
|
||||
|
||||
f->glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
GLfloat vertices[] = {
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
1.0f, 1.0f, -1.0f,
|
||||
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
1.0f, 1.0f, -1.0f,
|
||||
};
|
||||
|
||||
GLfloat tex_coords[] = {
|
||||
0.0, 0.0,
|
||||
1.0, 0.0,
|
||||
1.0, 1.0,
|
||||
|
||||
0.0, 0.0,
|
||||
0.0, 1.0,
|
||||
1.0, 1.0
|
||||
};
|
||||
|
||||
f->glViewport(0, 0, width(), height());
|
||||
|
||||
f->glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
QOpenGLTexture texture(QImage("C:/Users/Matt/Desktop/bliss.png"));
|
||||
|
||||
pipeline_->bind();
|
||||
texture.bind();
|
||||
|
||||
pipeline_->setUniformValue("mvp_matrix", projection_);
|
||||
pipeline_->setUniformValue("texture", 0);
|
||||
|
||||
GLuint vertex_location = pipeline_->attributeLocation("a_position");
|
||||
f->glEnableVertexAttribArray(vertex_location);
|
||||
f->glVertexAttribPointer(vertex_location, 3, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
|
||||
GLuint tex_location = pipeline_->attributeLocation("a_texcoord");
|
||||
f->glEnableVertexAttribArray(tex_location);
|
||||
f->glVertexAttribPointer(tex_location, 2, GL_FLOAT, GL_FALSE, 0, tex_coords);
|
||||
|
||||
f->glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
texture.release();
|
||||
pipeline_->release();
|
||||
|
||||
/*
|
||||
if (waveform) {
|
||||
draw_waveform_func();
|
||||
} else {
|
||||
@@ -615,4 +683,5 @@ void ViewerWidget::paintGL() {
|
||||
renderer->start_render(context(), viewer->seq.get());
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
+5
-1
@@ -41,7 +41,7 @@ class Viewer;
|
||||
class QOpenGLFramebufferObject;
|
||||
struct GLTextureCoords;
|
||||
|
||||
class ViewerWidget : public QOpenGLWidget, QOpenGLFunctions
|
||||
class ViewerWidget : public QOpenGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -91,6 +91,10 @@ private:
|
||||
ViewerWindow* window;
|
||||
double x_scroll;
|
||||
double y_scroll;
|
||||
|
||||
QMatrix4x4 projection_;
|
||||
QOpenGLShaderProgram* pipeline_;
|
||||
|
||||
private slots:
|
||||
void context_destroy();
|
||||
void retry();
|
||||
|
||||
Reference in New Issue
Block a user