Skip to content

Commit

Permalink
Maybe proceed with a ViewportEffect?
Browse files Browse the repository at this point in the history
  • Loading branch information
gzotti committed Sep 27, 2021
1 parent 545134f commit cda1261
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
13 changes: 11 additions & 2 deletions src/core/StelViewportEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ StelViewportDistorterFisheyeToSphericMirror::StelViewportDistorterFisheyeToSpher

// sharp image up to the border of the fisheye image, at the cost of
// accepting clamping artefacts. You can get rid of the clamping
// artefacts by specifying a viewport size a little less then
// artefacts by specifying a viewport size a little less than
// (1<<n)*(1<<n), for instance 1022*1022. With a viewport size
// of 512*512 and viewportFovDiameter=512 you will get clamping
// artefacts in the 3 otherwise black hills on the bottom of the image.
Expand Down Expand Up @@ -177,7 +177,7 @@ StelViewportDistorterFisheyeToSphericMirror::StelViewportDistorterFisheyeToSpher
QTextStream in;
QString fName = StelFileMgr::findFile(custom_distortion_file);
if (fName.isEmpty()) {
qWarning() << "WARNING: could not open custom_distortion_file:" << custom_distortion_file;
qWarning() << "WARNING: could not find custom_distortion_file:" << custom_distortion_file;
} else {
file.setFileName(fName);
if(file.open(QIODevice::ReadOnly))
Expand Down Expand Up @@ -344,3 +344,12 @@ void StelViewportDistorterFisheyeToSphericMirror::paintViewportBuffer(const QOpe
GL(gl->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
}

void StelViewportFaderEffect::alterBuffer(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
}


23 changes: 18 additions & 5 deletions src/core/StelViewportEffect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class StelViewportEffect
//! The default implementation does nothing.
virtual void alterBuffer(QOpenGLFramebufferObject*) const {;}
//! Draw the viewport on the screen.
//! @param buf the GL frame buffer containing the Stellarium viewport alreay drawn.
//! @param buf the GL frame buffer containing the Stellarium viewport already drawn.
//! The default implementation paints the buffer on the fullscreen.
virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const;
//! Distort an x,y position according to the distortion.
Expand All @@ -50,10 +50,10 @@ class StelViewportDistorterFisheyeToSphericMirror : public StelViewportEffect
{
public:
StelViewportDistorterFisheyeToSphericMirror(int screen_w,int screen_h);
~StelViewportDistorterFisheyeToSphericMirror();
virtual QString getName() const {return "sphericMirrorDistorter";}
virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const;
virtual void distortXY(qreal& x, qreal& y) const;
~StelViewportDistorterFisheyeToSphericMirror() Q_DECL_OVERRIDE;
virtual QString getName() const Q_DECL_OVERRIDE {return "sphericMirrorDistorter";}
virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE;
virtual void distortXY(qreal& x, qreal& y) const Q_DECL_OVERRIDE;
private:
const int screen_w;
const int screen_h;
Expand All @@ -70,5 +70,18 @@ class StelViewportDistorterFisheyeToSphericMirror : public StelViewportEffect
QVector<Vec2f> displayTexCoordList;
};

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:
};

#endif // STELVIEWPORTEFFECT_HPP

0 comments on commit cda1261

Please sign in to comment.