Skip to content

Commit 4f0cab6

Browse files
committed
Maybe proceed with a ViewportEffect?
1 parent 09912ab commit 4f0cab6

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

src/core/StelViewportEffect.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ StelViewportDistorterFisheyeToSphericMirror::StelViewportDistorterFisheyeToSpher
7373

7474
// width of the not yet distorted image
7575
newProjectorParams.devicePixelsPerPixel = 1;
76+
// FIXME: The name of the config value has been wrong since first commit in 2010!
7677
newProjectorParams.viewportXywh[2] = conf.value("spheric_mirror/newProjectorParams.viewportXywh[2]idth", originalProjectorParams.viewportXywh[2] * params.devicePixelsPerPixel).toInt();
7778
if (newProjectorParams.viewportXywh[2] <= 0)
7879
{
@@ -84,6 +85,7 @@ StelViewportDistorterFisheyeToSphericMirror::StelViewportDistorterFisheyeToSpher
8485
}
8586

8687
// height of the not yet distorted image
88+
// FIXME: The name of the config value has been wrong since first commit in 2010!
8789
newProjectorParams.viewportXywh[3] = conf.value("spheric_mirror/newProjectorParams.viewportXywh[3]eight", originalProjectorParams.viewportXywh[3] * params.devicePixelsPerPixel).toInt();
8890
if (newProjectorParams.viewportXywh[3] <= 0)
8991
{
@@ -148,7 +150,7 @@ StelViewportDistorterFisheyeToSphericMirror::StelViewportDistorterFisheyeToSpher
148150

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

349+
void StelViewportFaderEffect::alterBuffer(QOpenGLFramebufferObject* buf) const
350+
{
351+
Q_UNUSED(buf)
352+
// 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),
353+
// will the main buffer be changed, or can I only apply an effect to the finally displayed image?
354+
// https://stackoverflow.com/questions/6810591/how-to-make-fading-to-black-effect-with-opengl
355+
}
356+
357+

src/core/StelViewportEffect.hpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class StelViewportEffect
3737
//! The default implementation does nothing.
3838
virtual void alterBuffer(QOpenGLFramebufferObject*) const {;}
3939
//! Draw the viewport on the screen.
40-
//! @param buf the GL frame buffer containing the Stellarium viewport alreay drawn.
40+
//! @param buf the GL frame buffer containing the Stellarium viewport already drawn.
4141
//! The default implementation paints the buffer on the fullscreen.
4242
virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const;
4343
//! Distort an x,y position according to the distortion.
@@ -50,10 +50,10 @@ class StelViewportDistorterFisheyeToSphericMirror : public StelViewportEffect
5050
{
5151
public:
5252
StelViewportDistorterFisheyeToSphericMirror(int screen_w,int screen_h);
53-
~StelViewportDistorterFisheyeToSphericMirror();
54-
virtual QString getName() const {return "sphericMirrorDistorter";}
55-
virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const;
56-
virtual void distortXY(qreal& x, qreal& y) const;
53+
~StelViewportDistorterFisheyeToSphericMirror() Q_DECL_OVERRIDE;
54+
virtual QString getName() const Q_DECL_OVERRIDE {return "sphericMirrorDistorter";}
55+
virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE;
56+
virtual void distortXY(qreal& x, qreal& y) const Q_DECL_OVERRIDE;
5757
private:
5858
const int screen_w;
5959
const int screen_h;
@@ -70,5 +70,18 @@ class StelViewportDistorterFisheyeToSphericMirror : public StelViewportEffect
7070
QVector<Vec2f> displayTexCoordList;
7171
};
7272

73+
class StelViewportFaderEffect : public StelViewportEffect
74+
{
75+
public:
76+
StelViewportFaderEffect() {}
77+
//~StelViewportFaderEffect() Q_DECL_OVERRIDE;
78+
virtual QString getName() const Q_DECL_OVERRIDE {return "viewportFaderEffect";}
79+
//! Alter the GL frame buffer, this method must not display anything.
80+
//! The implementation in this class reduces the brightness of the existing buffer.
81+
virtual void alterBuffer(QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE;
82+
//virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const Q_DECL_OVERRIDE;
83+
//private:
84+
};
85+
7386
#endif // STELVIEWPORTEFFECT_HPP
7487

0 commit comments

Comments
 (0)