don't bind shaders if they didn't compile

This commit is contained in:
itsmattkc
2019-01-09 12:22:50 +11:00
parent 6b1bb620c1
commit 72df21e57c
3 changed files with 20 additions and 6 deletions
+17 -4
View File
@@ -800,9 +800,18 @@ void Effect::open() {
} else {
glslProgram = new QOpenGLShaderProgram();
validate_meta_path();
if (!vertPath.isEmpty()) glslProgram->addShaderFromSourceFile(QOpenGLShader::Vertex, meta->path + "/" + vertPath);
if (!fragPath.isEmpty()) glslProgram->addShaderFromSourceFile(QOpenGLShader::Fragment, meta->path + "/" + fragPath);
glslProgram->link();
bool glsl_compiled = true;
if (!vertPath.isEmpty()) {
if (!glslProgram->addShaderFromSourceFile(QOpenGLShader::Vertex, meta->path + "/" + vertPath)) {
glsl_compiled = false;
}
}
if (!fragPath.isEmpty()) {
if (!glslProgram->addShaderFromSourceFile(QOpenGLShader::Fragment, meta->path + "/" + fragPath)) {
glsl_compiled = false;
}
}
if (glsl_compiled) glslProgram->link();
isOpen = true;
}
} else {
@@ -826,12 +835,16 @@ void Effect::close() {
isOpen = false;
}
bool Effect::is_glsl_linked() {
return glslProgram != NULL && glslProgram->isLinked();
}
void Effect::startEffect() {
if (!isOpen) {
open();
dout << "[WARNING] Tried to start a closed effect - opening";
}
if (enable_shader) bound = glslProgram->bind();
if (enable_shader && glslProgram->isLinked()) bound = glslProgram->bind();
}
void Effect::endEffect() {
+1
View File
@@ -142,6 +142,7 @@ public:
bool is_open();
void open();
void close();
bool is_glsl_linked();
virtual void startEffect();
virtual void endEffect();
+2 -2
View File
@@ -189,7 +189,7 @@ void ViewerWidget::initializeGL() {
//}
void ViewerWidget::paintEvent(QPaintEvent *e) {
if (!rendering && context()->thread() == this->thread()) {
if (!rendering && context()->thread() == this->thread()) {
makeCurrent();
QOpenGLWidget::paintEvent(e);
}
@@ -429,7 +429,7 @@ void ViewerWidget::process_effect(Clip* c, Effect* e, double timecode, GLTexture
}
if (e->enable_shader || e->enable_superimpose) {
e->startEffect();
if (e->enable_shader) {
if (e->enable_shader && e->is_glsl_linked()) {
e->process_shader(timecode, coords);
composite_texture = draw_clip(c->fbo[fbo_switcher], composite_texture, true);
fbo_switcher = !fbo_switcher;