diff --git a/src/core/StelApp.cpp b/src/core/StelApp.cpp index 57f2a17599a51..bbbf464889131 100644 --- a/src/core/StelApp.cpp +++ b/src/core/StelApp.cpp @@ -1082,6 +1082,10 @@ void StelApp::setViewportEffect(const QString& name) { viewportEffect = new StelViewportDistorterFisheyeToSphericMirror(w, h); } + else if (name == "viewportFaderEffect") + { + viewportEffect = new StelViewportFaderEffect(); + } else { qDebug() << "unknown viewport effect name:" << name; diff --git a/src/core/StelViewportEffect.cpp b/src/core/StelViewportEffect.cpp index 9ec6ed46e8855..31c06e63dcde1 100644 --- a/src/core/StelViewportEffect.cpp +++ b/src/core/StelViewportEffect.cpp @@ -344,12 +344,13 @@ void StelViewportDistorterFisheyeToSphericMirror::paintViewportBuffer(const QOpe GL(gl->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); } -void StelViewportFaderEffect::alterBuffer(QOpenGLFramebufferObject* buf) const +void StelViewportFaderEffect::paintViewportBuffer(const QOpenGLFramebufferObject* buf) const { - Q_UNUSED(buf) - // TODO: I am still unsure about how to use this. When I want to have a scene fading to black (effect of a light echo or showing star trails), - // will the main buffer be changed, or can I only apply an effect to the finally displayed image? - // https://stackoverflow.com/questions/6810591/how-to-make-fading-to-black-effect-with-opengl + StelPainter sPainter(StelApp::getInstance().getCore()->getProjection2d()); + QOpenGLFunctions* gl = sPainter.glFuncs(); + sPainter.setColor(1,1,1); + GL(gl->glBindTexture(GL_TEXTURE_2D, buf->texture())); + GL(gl->glBlendColor(1, 1, 1, 0.08)); + sPainter.setBlending(true, GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA); + sPainter.drawRect2d(0, 0, buf->width(), buf->height()); } - - diff --git a/src/core/StelViewportEffect.hpp b/src/core/StelViewportEffect.hpp index 4847dd3fc59c1..63d925d4a18c0 100644 --- a/src/core/StelViewportEffect.hpp +++ b/src/core/StelViewportEffect.hpp @@ -74,13 +74,11 @@ class StelViewportFaderEffect : public StelViewportEffect { public: StelViewportFaderEffect() {} - //~StelViewportFaderEffect() Q_DECL_OVERRIDE; virtual QString getName() const Q_DECL_OVERRIDE {return "viewportFaderEffect";} //! Alter the GL frame buffer, this method must not display anything. //! The implementation in this class reduces the brightness of the existing buffer. - virtual void alterBuffer(QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE; - //virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE; -//private: + // virtual void alterBuffer(QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE; + virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE; }; #endif // STELVIEWPORTEFFECT_HPP