void QGLFrame::getCodeChanged(QString newCode) { this->code = newCode; stopRenderThread(); initRenderThread(); RenderThread.doRendering=true; }
void QGLFrame::handleCodeChange(QObject *glslwptr) { this->code=((GLSLEditor*)glslwptr)->editor->toPlainText(); stopRenderThread(); initRenderThread(); RenderThread.doRendering=true; }
void OpenGLComponent::stopBackgroundThread() { if (threadStarted) { stopRenderThread(); threadStarted = false; } }
void QGLFrame::openFileDialog() { QString filePath = QFileDialog::getOpenFileName(this,tr("Fragment Shader File"),"./../Shadertoy",tr("Files (*.fsh)")); qDebug()<<filePath; QFile fShaderFile(filePath); if(fShaderFile.open(QFile::ReadOnly | QFile::Text)) { this->code = fShaderFile.readAll(); stopRenderThread(); initRenderThread(); RenderThread.doRendering=true; emit sendCode(this->code); } else qDebug() <<"Error unable to open file:" << filePath; }
OpenGLComponent::~OpenGLComponent() { if (isUsingDedicatedThread()) { /* If you're using a background thread, then your sub-class MUST call stopRenderThread() in its destructor! Otherwise, the thread could still be running while your sub-class isbeing destroyed, and so may make a call to your subclass's renderOpenGL() method when it no longer exists! */ jassert (renderThread == nullptr); stopRenderThread(); } else { deleteContext(); } componentWatcher = nullptr; }
void QGLFrame::closeEvent(QCloseEvent *evt) { stopRenderThread(); QGLWidget::closeEvent(evt); }