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

Cleaned up CampVisPainter to fully match the new API.

parent afa7bd28
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "tgt/assert.h" #include "tgt/assert.h"
#include "tgt/camera.h" #include "tgt/camera.h"
#include "tgt/glcontextmanager.h"
#include "tgt/quadric.h" #include "tgt/quadric.h"
#include "tgt/shadermanager.h" #include "tgt/shadermanager.h"
#include "tgt/texture.h" #include "tgt/texture.h"
...@@ -48,8 +49,7 @@ namespace campvis { ...@@ -48,8 +49,7 @@ namespace campvis {
, _copyShader(nullptr) , _copyShader(nullptr)
, _errorTexture(nullptr) , _errorTexture(nullptr)
{ {
tgtAssert(getCanvas() != 0, "The given canvas must not be 0!"); tgtAssert(getCanvas() != nullptr, "The given canvas must not be 0!");
_dirty = true;
setPipeline(pipeline); setPipeline(pipeline);
} }
...@@ -58,7 +58,7 @@ namespace campvis { ...@@ -58,7 +58,7 @@ namespace campvis {
} }
void CampVisPainter::paint() { void CampVisPainter::paint() {
if (getCanvas() == 0) if (getCanvas() == nullptr)
return; return;
if (_copyShader == nullptr) { if (_copyShader == nullptr) {
...@@ -79,7 +79,7 @@ namespace campvis { ...@@ -79,7 +79,7 @@ namespace campvis {
tgt::Shader::IgnoreUniformLocationErrorGuard guard(_copyShader); tgt::Shader::IgnoreUniformLocationErrorGuard guard(_copyShader);
// render whatever there is to render // render whatever there is to render
if (rd != 0 || (repGL != 0 && repGL->getDimensionality() == 2)) { if (rd != nullptr || (repGL != nullptr && repGL->getDimensionality() == 2)) {
_copyShader->setUniform("_viewMatrix", tgt::mat4::identity); _copyShader->setUniform("_viewMatrix", tgt::mat4::identity);
// bind input textures // bind input textures
...@@ -135,39 +135,33 @@ namespace campvis { ...@@ -135,39 +135,33 @@ namespace campvis {
void CampVisPainter::deinit() { void CampVisPainter::deinit() {
ShdrMgr.dispose(_copyShader); ShdrMgr.dispose(_copyShader);
if (_pipeline != 0) { if (_pipeline != nullptr) {
_pipeline->s_renderTargetChanged.disconnect(this); if (getCanvas()->getEventHandler() != nullptr)
if (getCanvas()->getEventHandler() != 0)
getCanvas()->getEventHandler()->removeEventListener(_pipeline); getCanvas()->getEventHandler()->removeEventListener(_pipeline);
_pipeline = 0; _pipeline = nullptr;
} }
} }
void CampVisPainter::setPipeline(AbstractPipeline* pipeline) { void CampVisPainter::setPipeline(AbstractPipeline* pipeline) {
tgtAssert(pipeline != 0, "The given pipeline must not be 0."); tgtAssert(pipeline != nullptr, "The given pipeline must not be 0.");
if (_pipeline != 0) {
_pipeline->s_renderTargetChanged.disconnect(this); if (_pipeline != nullptr) {
if (getCanvas()->getEventHandler() != 0) if (getCanvas()->getEventHandler() != nullptr)
getCanvas()->getEventHandler()->removeEventListener(_pipeline); getCanvas()->getEventHandler()->removeEventListener(_pipeline);
} }
_pipeline = pipeline; _pipeline = pipeline;
_pipeline->s_renderTargetChanged.connect(this, &CampVisPainter::onRenderTargetChanged);
_pipeline->setRenderTargetSize(getCanvas()->getSize()); _pipeline->setRenderTargetSize(getCanvas()->getSize());
if (getCanvas()->getEventHandler() != 0) if (getCanvas()->getEventHandler() != nullptr)
getCanvas()->getEventHandler()->addEventListenerToFront(_pipeline); getCanvas()->getEventHandler()->addEventListenerToFront(_pipeline);
} }
void CampVisPainter::repaint() { void CampVisPainter::repaint() {
//GLJobProc.enqueueJob(getCanvas(), makeJobOnHeap(this, &CampVisPainter::paint), OpenGLJobProcessor::PaintJob); // do nothing, as the painting is entirely managed by the pipeline.
}
void CampVisPainter::onRenderTargetChanged() {
repaint();
} }
void CampVisPainter::setCanvas(tgt::GLCanvas* canvas) { void CampVisPainter::setCanvas(tgt::GLCanvas* canvas) {
tgtAssert(dynamic_cast<tgt::QtThreadedCanvas*>(canvas) != 0, "Canvas must be of type QtThreadedCanvas!"); tgtAssert(dynamic_cast<tgt::QtThreadedCanvas*>(canvas) != nullptr, "Canvas must be of type QtThreadedCanvas!");
Painter::setCanvas(canvas); Painter::setCanvas(canvas);
} }
......
...@@ -91,10 +91,6 @@ namespace campvis { ...@@ -91,10 +91,6 @@ namespace campvis {
void setErrorTexture(tgt::Texture* texture); void setErrorTexture(tgt::Texture* texture);
/**
* Slot being notified when the pipeline's render target changed.
*/
void onRenderTargetChanged();
private: private:
/** /**
...@@ -106,10 +102,7 @@ namespace campvis { ...@@ -106,10 +102,7 @@ namespace campvis {
AbstractPipeline* _pipeline; ///< Pipeline to render AbstractPipeline* _pipeline; ///< Pipeline to render
tgt::Shader* _copyShader; ///< Shader for copying the render target to the framebuffer. tgt::Shader* _copyShader; ///< Shader for copying the render target to the framebuffer.
tbb::atomic<bool> _dirty; ///< Flag whether render result is dirty and needs to be rerendered. tgt::Texture* _errorTexture; ///< Pointer to error texture
std::condition_variable _renderCondition; ///< conditional wait condition for rendering
tgt::Texture* _errorTexture;
}; };
} }
......
...@@ -138,7 +138,6 @@ namespace campvis { ...@@ -138,7 +138,6 @@ namespace campvis {
executePipeline(); executePipeline();
// paint on canvas // paint on canvas
// FIXME: clean up the whole painter crap...
_canvas->getPainter()->paint(); _canvas->getPainter()->paint();
} }
......
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