Commit c7c7a04a authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Implemented functionality to rebuild all GLSL shaders from file while CAMPVis is running.

parent 13b43621
......@@ -36,11 +36,13 @@
#include "application/campvispainter.h"
#include "application/gui/mainwindow.h"
#include "core/tools/job.h"
#include "core/tools/opengljobprocessor.h"
#include "core/tools/simplejobprocessor.h"
#include "core/tools/stringutils.h"
#include "core/tools/quadrenderer.h"
#include "core/pipeline/abstractpipeline.h"
#include "core/pipeline/visualizationprocessor.h"
#include "modules/pipelinefactory.h"
namespace campvis {
......@@ -153,6 +155,7 @@ namespace campvis {
}
GLJobProc.start();
GLJobProc.registerContext(_localContext);
_initialized = true;
}
......@@ -277,5 +280,26 @@ namespace campvis {
return dc;
}
void CampVisApplication::rebuildAllShadersFromFiles() {
// rebuilding all shaders has to be done from OpenGL context, use the local one.
GLJobProc.enqueueJob(_localContext, makeJobOnHeap(this, &CampVisApplication::triggerShaderRebuild), OpenGLJobProcessor::SerialJob);
}
void CampVisApplication::triggerShaderRebuild() {
if (! ShdrMgr.rebuildAllShadersFromFile()) {
LERROR("Could not rebuild all shaders from file.");
return;
}
for (std::vector<AbstractPipeline*>::iterator it = _pipelines.begin(); it != _pipelines.end(); ++it) {
for (std::vector<AbstractProcessor*>::const_iterator pit = (*it)->getProcessors().begin(); pit != (*it)->getProcessors().end(); ++pit) {
if (VisualizationProcessor* tester = dynamic_cast<VisualizationProcessor*>(*pit)) {
tester->invalidate(AbstractProcessor::INVALID_RESULT);
}
}
}
}
}
......@@ -118,6 +118,11 @@ namespace campvis {
*/
DataContainer* createAndAddDataContainer(const std::string& name);
/**
* Reloads all GLSL shaders from file and rebuilds them.
*/
void rebuildAllShadersFromFiles();
/// Signal emitted when the collection of pipelines has changed.
sigslot::signal0<> s_PipelinesChanged;
......@@ -135,6 +140,12 @@ namespace campvis {
/// All DataContainers
std::vector<DataContainer*> _dataContainers;
/**
* Triggers the ShaderManager to rebuild all shaders from file and then
* invalidates all VisualizationProcessors.
*/
void triggerShaderRebuild();
/// A local OpenGL context used for initialization
tgt::GLCanvas* _localContext;
/// Main window hosting GUI stuff
......
......@@ -160,6 +160,7 @@ namespace campvis {
// Populate the file menu
QMenuBar* menuBar = this->menuBar();
QMenu* fileMenu = menuBar->addMenu(tr("&File"));
fileMenu->addAction(tr("&Rebuild all Shaders from File"), this, SLOT(onRebuildShadersClicked()), QKeySequence(Qt::CTRL + Qt::Key_F5));
fileMenu->addAction(tr("&Quit"), qApp, SLOT(closeAllWindows()), QKeySequence(Qt::CTRL + Qt::Key_Q));
// Populate the visualizations menu
......@@ -306,4 +307,8 @@ namespace campvis {
_application->addPipeline(name, p);
}
void MainWindow::onRebuildShadersClicked() {
_application->rebuildAllShadersFromFiles();
}
}
......@@ -125,6 +125,9 @@ namespace campvis {
/// Slot to be called when _btnPipelineFactory was clicked;
void onBtnPipelineFactoryClicked();
/// Slot to be called when all shaders shall be rebuilt.
void onRebuildShadersClicked();
private:
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment