Skip to content

Commit

Permalink
Continue a bit the trail fader viewport effect
Browse files Browse the repository at this point in the history
Started by Georg in the previous commit.  This can be enabled by setting

    [video]
    viewport_effect = viewportFaderEffect

in the config file.

This effect simply applies a mix of the current frame with the one
before.  Need to see if there is a way to improve the effect somehow.
  • Loading branch information
guillaumechereau authored and gzotti committed Oct 14, 2023
1 parent 51bf016 commit a4ae4b4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/core/StelApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,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;
Expand Down
15 changes: 8 additions & 7 deletions src/core/StelViewportEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,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());
}


6 changes: 2 additions & 4 deletions src/core/StelViewportEffect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a4ae4b4

Please sign in to comment.