fixed effects when opengl context changes
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "project/clip.h"
|
||||
|
||||
BoxBlurEffect::BoxBlurEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_BOXBLUR_EFFECT), vert(QOpenGLShader::Vertex), frag(QOpenGLShader::Fragment) {
|
||||
BoxBlurEffect::BoxBlurEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_BOXBLUR_EFFECT) {
|
||||
enable_opengl = true;
|
||||
|
||||
radius_val = add_row("Radius:")->add_field(EFFECT_FIELD_DOUBLE);
|
||||
@@ -19,11 +19,13 @@ BoxBlurEffect::BoxBlurEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_BOXBL
|
||||
horiz_val->set_bool_value(true);
|
||||
vert_val->set_bool_value(true);
|
||||
|
||||
vert.compileSourceFile(":/shaders/common.vert");
|
||||
vertPath = ":/shaders/common.vert";
|
||||
fragPath = ":/shaders/boxblureffect.frag";
|
||||
/*vert.compileSourceFile(":/shaders/common.vert");
|
||||
frag.compileSourceFile(":/shaders/boxblureffect.frag");
|
||||
program.addShader(&vert);
|
||||
program.addShader(&frag);
|
||||
program.link();
|
||||
program.link();*/
|
||||
|
||||
connect(radius_val, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
// connect(iteration_val, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
@@ -31,15 +33,9 @@ BoxBlurEffect::BoxBlurEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_BOXBL
|
||||
connect(vert_val, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
}
|
||||
|
||||
void BoxBlurEffect::process_gl(double timecode, GLTextureCoords &coords) {
|
||||
program.bind();
|
||||
|
||||
program.setUniformValue("resolution", parent_clip->getWidth(), parent_clip->getHeight());
|
||||
program.setUniformValue("radius", (GLfloat) radius_val->get_double_value(timecode));
|
||||
program.setUniformValue("horiz_blur", horiz_val->get_bool_value(timecode));
|
||||
program.setUniformValue("vert_blur", vert_val->get_bool_value(timecode));
|
||||
}
|
||||
|
||||
void BoxBlurEffect::clean_gl() {
|
||||
program.release();
|
||||
void BoxBlurEffect::process_gl(double timecode, GLTextureCoords&) {
|
||||
glslProgram->setUniformValue("resolution", parent_clip->getWidth(), parent_clip->getHeight());
|
||||
glslProgram->setUniformValue("radius", (GLfloat) radius_val->get_double_value(timecode));
|
||||
glslProgram->setUniformValue("horiz_blur", horiz_val->get_bool_value(timecode));
|
||||
glslProgram->setUniformValue("vert_blur", vert_val->get_bool_value(timecode));
|
||||
}
|
||||
|
||||
@@ -8,13 +8,8 @@ class BoxBlurEffect : public Effect
|
||||
public:
|
||||
BoxBlurEffect(Clip* c);
|
||||
|
||||
void process_gl(double timecode, GLTextureCoords &coords);
|
||||
void clean_gl();
|
||||
void process_gl(double timecode, GLTextureCoords &coords);
|
||||
private:
|
||||
QOpenGLShaderProgram program;
|
||||
QOpenGLShader vert;
|
||||
QOpenGLShader frag;
|
||||
|
||||
EffectField* radius_val;
|
||||
EffectField* iteration_val;
|
||||
EffectField* horiz_val;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "chromakeyeffect.h"
|
||||
|
||||
ChromaKeyEffect::ChromaKeyEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_CHROMAKEY_EFFECT), vert(QOpenGLShader::Vertex), frag(QOpenGLShader::Fragment) {
|
||||
ChromaKeyEffect::ChromaKeyEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_CHROMAKEY_EFFECT) {
|
||||
enable_opengl = true;
|
||||
|
||||
color_field = add_row("Color:")->add_field(EFFECT_FIELD_COLOR);
|
||||
@@ -12,22 +12,14 @@ ChromaKeyEffect::ChromaKeyEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_C
|
||||
tolerance_field->set_double_minimum_value(0);
|
||||
tolerance_field->set_double_maximum_value(100);
|
||||
|
||||
vert.compileSourceFile(":/shaders/common.vert");
|
||||
frag.compileSourceFile(":/shaders/chromakeyeffect.frag");
|
||||
program.addShader(&vert);
|
||||
program.addShader(&frag);
|
||||
program.link();
|
||||
vertPath = ":/shaders/common.vert";
|
||||
fragPath = ":/shaders/chromakeyeffect.frag";
|
||||
|
||||
connect(color_field, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(tolerance_field, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
}
|
||||
|
||||
void ChromaKeyEffect::process_gl(double timecode, GLTextureCoords&) {
|
||||
program.bind();
|
||||
program.setUniformValue("keyColor", color_field->get_color_value(timecode));
|
||||
program.setUniformValue("threshold", (GLfloat) (tolerance_field->get_double_value(timecode)*0.01));
|
||||
}
|
||||
|
||||
void ChromaKeyEffect::clean_gl() {
|
||||
program.release();
|
||||
glslProgram->setUniformValue("keyColor", color_field->get_color_value(timecode));
|
||||
glslProgram->setUniformValue("threshold", (GLfloat) (tolerance_field->get_double_value(timecode)*0.01));
|
||||
}
|
||||
|
||||
@@ -7,13 +7,9 @@ class ChromaKeyEffect : public Effect {
|
||||
public:
|
||||
ChromaKeyEffect(Clip* c);
|
||||
void process_gl(double timecode, GLTextureCoords &coords);
|
||||
void clean_gl();
|
||||
private:
|
||||
EffectField* color_field;
|
||||
EffectField* tolerance_field;
|
||||
QOpenGLShaderProgram program;
|
||||
QOpenGLShader vert;
|
||||
QOpenGLShader frag;
|
||||
};
|
||||
|
||||
#endif // CHROMAKEYEFFECT_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <QImage>
|
||||
|
||||
GaussianBlurEffect::GaussianBlurEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_GAUSSIANBLUR_EFFECT), frag(QOpenGLShader::Fragment), vert(QOpenGLShader::Vertex) {
|
||||
GaussianBlurEffect::GaussianBlurEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_GAUSSIANBLUR_EFFECT) {
|
||||
enable_opengl = true;
|
||||
|
||||
radius_val = add_row("Radius:")->add_field(EFFECT_FIELD_DOUBLE);
|
||||
@@ -21,11 +21,8 @@ GaussianBlurEffect::GaussianBlurEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, V
|
||||
horiz_val->set_bool_value(true);
|
||||
vert_val->set_bool_value(true);
|
||||
|
||||
vert.compileSourceFile(":/shaders/common.vert");
|
||||
frag.compileSourceFile(":/shaders/gaussianblureffect.frag");
|
||||
program.addShader(&vert);
|
||||
program.addShader(&frag);
|
||||
program.link();
|
||||
vertPath = ":/shaders/common.vert";
|
||||
fragPath = ":/shaders/gaussianblureffect.frag";
|
||||
|
||||
connect(radius_val, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(sigma_val, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
@@ -34,15 +31,9 @@ GaussianBlurEffect::GaussianBlurEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, V
|
||||
}
|
||||
|
||||
void GaussianBlurEffect::process_gl(double timecode, GLTextureCoords &coords) {
|
||||
program.bind();
|
||||
|
||||
program.setUniformValue("resolution", parent_clip->getWidth(), parent_clip->getHeight());
|
||||
program.setUniformValue("radius", (GLfloat) radius_val->get_double_value(timecode));
|
||||
program.setUniformValue("sigma", (GLfloat) sigma_val->get_double_value(timecode));
|
||||
program.setUniformValue("horiz_blur", horiz_val->get_bool_value(timecode));
|
||||
program.setUniformValue("vert_blur", vert_val->get_bool_value(timecode));
|
||||
}
|
||||
|
||||
void GaussianBlurEffect::clean_gl() {
|
||||
program.release();
|
||||
glslProgram->setUniformValue("resolution", parent_clip->getWidth(), parent_clip->getHeight());
|
||||
glslProgram->setUniformValue("radius", (GLfloat) radius_val->get_double_value(timecode));
|
||||
glslProgram->setUniformValue("sigma", (GLfloat) sigma_val->get_double_value(timecode));
|
||||
glslProgram->setUniformValue("horiz_blur", horiz_val->get_bool_value(timecode));
|
||||
glslProgram->setUniformValue("vert_blur", vert_val->get_bool_value(timecode));
|
||||
}
|
||||
|
||||
@@ -8,12 +8,7 @@ class GaussianBlurEffect : public Effect
|
||||
public:
|
||||
GaussianBlurEffect(Clip* c);
|
||||
void process_gl(double timecode, GLTextureCoords &coords);
|
||||
void clean_gl();
|
||||
private:
|
||||
QOpenGLShaderProgram program;
|
||||
QOpenGLShader vert;
|
||||
QOpenGLShader frag;
|
||||
|
||||
EffectField* radius_val;
|
||||
EffectField* sigma_val;
|
||||
EffectField* horiz_val;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QXmlStreamAttributes>
|
||||
|
||||
InvertEffect::InvertEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_INVERT_EFFECT), vert(QOpenGLShader::Vertex), frag(QOpenGLShader::Fragment) {
|
||||
InvertEffect::InvertEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_INVERT_EFFECT) {
|
||||
enable_opengl = true;
|
||||
|
||||
EffectRow* amount_row = add_row("Amount:");
|
||||
@@ -22,18 +22,10 @@ InvertEffect::InvertEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_INVERT_
|
||||
|
||||
connect(amount_val, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
|
||||
vert.compileSourceFile(":/shaders/common.vert");
|
||||
frag.compileSourceFile(":/shaders/inverteffect.frag");
|
||||
program.addShader(&vert);
|
||||
program.addShader(&frag);
|
||||
program.link();
|
||||
vertPath = ":/shaders/common.vert";
|
||||
fragPath = ":/shaders/inverteffect.frag";
|
||||
}
|
||||
|
||||
void InvertEffect::process_gl(double timecode, GLTextureCoords&) {
|
||||
program.bind();
|
||||
program.setUniformValue("amount_val", (GLfloat) (amount_val->get_double_value(timecode)*0.01));
|
||||
}
|
||||
|
||||
void InvertEffect::clean_gl() {
|
||||
program.release();
|
||||
glslProgram->setUniformValue("amount_val", (GLfloat) (amount_val->get_double_value(timecode)*0.01));
|
||||
}
|
||||
|
||||
@@ -8,12 +8,8 @@ class InvertEffect : public Effect {
|
||||
public:
|
||||
InvertEffect(Clip* c);
|
||||
void process_gl(double timecode, GLTextureCoords& coords);
|
||||
void clean_gl();
|
||||
private:
|
||||
EffectField* amount_val;
|
||||
QOpenGLShader frag;
|
||||
QOpenGLShader vert;
|
||||
QOpenGLShaderProgram program;
|
||||
};
|
||||
|
||||
#endif // INVERTEFFECT_H
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#define SMPTE_STRIP_COUNT 3
|
||||
#define SMPTE_LOWER_BARS 4
|
||||
|
||||
SolidEffect::SolidEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_SOLID_EFFECT), vert(QOpenGLShader::Vertex), frag(QOpenGLShader::Fragment) {
|
||||
SolidEffect::SolidEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_SOLID_EFFECT) {
|
||||
enable_opengl = true;
|
||||
|
||||
solid_type = add_row("Type:")->add_field(EFFECT_FIELD_COMBO);
|
||||
@@ -34,22 +34,15 @@ SolidEffect::SolidEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_SOLID_EFF
|
||||
connect(solid_color_field, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(opacity_field, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
|
||||
vert.compileSourceFile(":/shaders/common.vert");
|
||||
frag.compileSourceFile(":/shaders/solideffect.frag");
|
||||
program.addShader(&vert);
|
||||
program.addShader(&frag);
|
||||
vertPath = ":/shaders/common.vert";
|
||||
fragPath = ":/shaders/solideffect.frag";
|
||||
}
|
||||
|
||||
void SolidEffect::process_gl(double timecode, GLTextureCoords&) {
|
||||
solid_color_field->set_enabled(solid_type->get_combo_data(timecode) == SOLID_TYPE_COLOR);
|
||||
|
||||
program.bind();
|
||||
program.setUniformValue("solidColor", solid_color_field->get_color_value(timecode));
|
||||
program.setUniformValue("amount_val", (GLfloat) (opacity_field->get_double_value(timecode)*0.01));
|
||||
}
|
||||
|
||||
void SolidEffect::clean_gl() {
|
||||
program.release();
|
||||
glslProgram->setUniformValue("solidColor", solid_color_field->get_color_value(timecode));
|
||||
glslProgram->setUniformValue("amount_val", (GLfloat) (opacity_field->get_double_value(timecode)*0.01));
|
||||
}
|
||||
|
||||
void SolidEffect::process_image(long frame, uint8_t* data, int w, int h) {
|
||||
|
||||
@@ -11,12 +11,7 @@ public:
|
||||
EffectField* solid_color_field;
|
||||
EffectField* opacity_field;
|
||||
void process_gl(double timecode, GLTextureCoords& coords);
|
||||
void clean_gl();
|
||||
void process_image(long p, uint8_t* data, int width, int height);
|
||||
private:
|
||||
QOpenGLShaderProgram program;
|
||||
QOpenGLShader vert;
|
||||
QOpenGLShader frag;
|
||||
void process_image(long p, uint8_t* data, int width, int height);
|
||||
};
|
||||
|
||||
#endif // SOLIDEFFECT_H
|
||||
|
||||
Reference in New Issue
Block a user