Stellarium 0.13.0
StelViewportEffect.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2010 Fabien Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELVIEWPORTEFFECT_HPP_
21 #define _STELVIEWPORTEFFECT_HPP_
22 
23 #include "VecMath.hpp"
24 #include "StelProjector.hpp"
25 #include <QOpenGLFunctions>
26 
27 class QOpenGLFramebufferObject;
28 
31 class StelViewportEffect: protected QOpenGLFunctions
32 {
33 public:
34  StelViewportEffect() {;}
35  virtual ~StelViewportEffect() {;}
36  virtual QString getName() {return "framebufferOnly";}
39  virtual void alterBuffer(QOpenGLFramebufferObject*) const {;}
43  virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const;
46  virtual void distortXY(float& x, float& y) const {Q_UNUSED(x); Q_UNUSED(y);}
47 };
48 
49 
51 {
52 public:
53  StelViewportDistorterFisheyeToSphericMirror(int screen_w,int screen_h);
55  virtual QString getName() {return "sphericMirrorDistorter";}
56  virtual void paintViewportBuffer(const QOpenGLFramebufferObject* buf) const;
57  virtual void distortXY(float& x, float& y) const;
58 private:
59  const int screen_w;
60  const int screen_h;
61  const StelProjector::StelProjectorParams originalProjectorParams;
62  StelProjector::StelProjectorParams newProjectorParams;
63  int viewport_texture_offset[2];
64  int texture_wh;
65 
66  Vec2f *texture_point_array;
67  int max_x,max_y;
68  double step_x,step_y;
69 
70  QVector<Vec2f> displayVertexList;
71  QVector<Vec4f> displayColorList;
72  QVector<Vec2f> displayTexCoordList;
73 };
74 
75 #endif // _STELVIEWPORTEFFECT_HPP_
76 
A templatized 2d vector compatible with openGL.
Definition: VecMath.hpp:32
virtual void distortXY(float &x, float &y) const
Distort an x,y position according to the distortion.
Definition: StelViewportEffect.hpp:46
Definition: StelViewportEffect.hpp:50
virtual void paintViewportBuffer(const QOpenGLFramebufferObject *buf) const
Draw the viewport on the screen.
Allow to apply visual effects on the whole Stellarium viewport.
Definition: StelViewportEffect.hpp:31
virtual void distortXY(float &x, float &y) const
Distort an x,y position according to the distortion.
Contains all the param needed to initialize a StelProjector.
Definition: StelProjector.hpp:94
virtual void paintViewportBuffer(const QOpenGLFramebufferObject *buf) const
Draw the viewport on the screen.
virtual void alterBuffer(QOpenGLFramebufferObject *) const
Alter the GL frame buffer, this method must not display anything.
Definition: StelViewportEffect.hpp:39