CalcMySky  v0.3.1
AtmosphereRenderer.hpp
Go to the documentation of this file.
1 #ifndef INCLUDE_ONCE_02040F35_0604_4759_A47D_71849AAC953D
2 #define INCLUDE_ONCE_02040F35_0604_4759_A47D_71849AAC953D
3 
6 #include <memory>
7 #include <functional>
8 
9 #include <QObject>
10 #include <QVector4D>
11 #include <qopengl.h>
12 
13 #include "Settings.hpp"
14 #include "Exception.hpp"
15 
17 #ifdef SHOWMYSKY_COMPILING_SHARED_LIB
18 # define SHOWMYSKY_DLL_PUBLIC Q_DECL_EXPORT
19 #elif defined SHOWMYSKY_COMPILING_CALCMYSKY
20 # define SHOWMYSKY_DLL_PUBLIC
21 #else
22 # define SHOWMYSKY_DLL_PUBLIC Q_DECL_IMPORT
23 #endif
24 
27 class QString;
28 class QOpenGLShaderProgram;
29 class QOpenGLFunctions_3_3_Core;
30 
31 namespace ShowMySky
32 {
33 
35 {
36 public:
41  {
42  std::vector<float> wavelengths;
43  std::vector<float> radiances;
44 
45  float azimuth;
46  float elevation;
47 
49  unsigned size() const { return wavelengths.size(); }
51  bool empty() const { return wavelengths.empty(); }
52  };
53 
57  struct Direction
58  {
59  float azimuth;
60  float elevation;
61  };
62 
67  {
68  int stepsDone;
69  int stepsToDo;
70  };
71 
72 public:
84  virtual void setDrawSurfaceCallback(std::function<void(QOpenGLShaderProgram& shprog)> const& drawSurface) = 0;
97  virtual int initDataLoading(QByteArray viewDirVertShaderSrc, QByteArray viewDirFragShaderSrc,
98  std::vector<std::pair<std::string,GLuint>> viewDirBindAttribLocations={}) = 0;
108  virtual void setViewDirShaders(QByteArray viewDirVertShaderSrc, QByteArray viewDirFragShaderSrc,
109  std::vector<std::pair<std::string,GLuint>> viewDirBindAttribLocations={}) = 0;
116  virtual LoadingStatus stepDataLoading() = 0;
130  virtual int initPreparationToDraw() = 0;
137  virtual LoadingStatus stepPreparationToDraw() = 0;
143  virtual QString currentActivity() const = 0;
148  virtual bool isReadyToRender() const = 0;
153  virtual bool isLoading() const = 0;
158  virtual bool canGrabRadiance() const = 0;
163  virtual bool canSetSolarSpectrum() const = 0;
171  virtual bool canRenderPrecomputedEclipsedDoubleScattering() const = 0;
179  virtual GLuint getLuminanceTexture() = 0;
188  virtual void draw(double brightness, bool clear) = 0;
197  virtual void resizeEvent(int width, int height) = 0;
209  virtual QVector4D getPixelLuminance(QPoint const& pixelPos) = 0;
218  virtual SpectralRadiance getPixelSpectralRadiance(QPoint const& pixelPos) = 0;
223  virtual std::vector<float> getWavelengths() = 0;
233  virtual void setSolarSpectrum(std::vector<float> const& spectralIrradianceAtTOA) = 0;
239  virtual void resetSolarSpectrum() = 0;
248  virtual Direction getViewDirection(QPoint const& pixelPos) = 0;
249 
250  virtual ~AtmosphereRenderer() = default;
251 
259  virtual int initShaderReloading() = 0;
265  virtual LoadingStatus stepShaderReloading() = 0;
276  virtual void setScattererEnabled(QString const& name, bool enable) = 0;
277 };
278 
279 }
280 
281 extern "C"
282 {
290 SHOWMYSKY_DLL_PUBLIC ShowMySky::AtmosphereRenderer*
291  ShowMySky_AtmosphereRenderer_create(QOpenGLFunctions_3_3_Core* gl,
292  QString const* pathToData,
293  ShowMySky::Settings* tools,
294  std::function<void(QOpenGLShaderProgram&)> const* drawSurface);
302 #define ShowMySky_ABI_version 15
303 
309 #define SHOWMYSKY_LIB_NAME (QT_VERSION_MAJOR==5 ? "ShowMySky-Qt5" : "ShowMySky-Qt6")
310 }
311 
312 #endif
virtual bool canGrabRadiance() const =0
Tell whether radiance of a pixel can be queried.
virtual int initPreparationToDraw()=0
Initialize step-by-step process of preparation to render.
virtual void resetSolarSpectrum()=0
Reset solar spectrum to the default.
Scene settings for AtmosphereRenderer.
Definition: Settings.hpp:9
virtual bool canSetSolarSpectrum() const =0
Tell whether solar spectrum can be changed.
Definition: AtmosphereRenderer.hpp:34
virtual void draw(double brightness, bool clear)=0
Do the drawing.
virtual LoadingStatus stepPreparationToDraw()=0
Perform a single step of preparation to draw.
virtual SpectralRadiance getPixelSpectralRadiance(QPoint const &pixelPos)=0
Get spectral radiance of a pixel.
virtual LoadingStatus stepDataLoading()=0
Perform a single step of data loading.
SHOWMYSKY_DLL_PUBLIC ShowMySky::AtmosphereRenderer * ShowMySky_AtmosphereRenderer_create(QOpenGLFunctions_3_3_Core *gl, QString const *pathToData, ShowMySky::Settings *tools, std::function< void(QOpenGLShaderProgram &)> const *drawSurface)
Entry point for the creator of AtmosphereRenderer.
virtual LoadingStatus stepShaderReloading()=0
Perform a single step of reloading of shaders.
Status of data loading process.
Definition: AtmosphereRenderer.hpp:66
float azimuth
Azimuth from which this radiance was measured, in degrees.
Definition: AtmosphereRenderer.hpp:45
virtual void setDrawSurfaceCallback(std::function< void(QOpenGLShaderProgram &shprog)> const &drawSurface)=0
Set the callback that will draw the screen surface.
float elevation
View elevation angle, in degrees.
Definition: AtmosphereRenderer.hpp:60
virtual Direction getViewDirection(QPoint const &pixelPos)=0
Get view direction of a pixel.
virtual void setSolarSpectrum(std::vector< float > const &spectralIrradianceAtTOA)=0
Set a custom solar spectrum.
virtual QVector4D getPixelLuminance(QPoint const &pixelPos)=0
Get luminance of a pixel.
int stepsDone
Number of steps done.
Definition: AtmosphereRenderer.hpp:68
float elevation
Elevation angle from which this radiance was measured, in degrees.
Definition: AtmosphereRenderer.hpp:46
virtual bool isLoading() const =0
Tell whether the renderer is in process of loading data.
Definition: AtmosphereRenderer.hpp:17
unsigned size() const
Number of points in the spectrum.
Definition: AtmosphereRenderer.hpp:49
virtual int initShaderReloading()=0
Initialize step-by-step process of reloading of shaders.
virtual void setViewDirShaders(QByteArray viewDirVertShaderSrc, QByteArray viewDirFragShaderSrc, std::vector< std::pair< std::string, GLuint >> viewDirBindAttribLocations={})=0
Replace the current view direction shaders with a new set.
virtual void setScattererEnabled(QString const &name, bool enable)=0
Enable or disable a single-scattering layer.
std::vector< float > radiances
Spectral radiance in .
Definition: AtmosphereRenderer.hpp:43
virtual bool canRenderPrecomputedEclipsedDoubleScattering() const =0
Tell whether precomputed eclipsed double scattering can be rendered.
bool empty() const
true if the spectrum has no points.
Definition: AtmosphereRenderer.hpp:51
virtual bool isReadyToRender() const =0
Tell whether the renderer is ready for a draw call.
virtual void resizeEvent(int width, int height)=0
Update render target size.
virtual int initDataLoading(QByteArray viewDirVertShaderSrc, QByteArray viewDirFragShaderSrc, std::vector< std::pair< std::string, GLuint >> viewDirBindAttribLocations={})=0
Initialize step-by-step process of loading of data.
float azimuth
View azimuth, in degrees.
Definition: AtmosphereRenderer.hpp:59
Spectral radiance of a pixel.
Definition: AtmosphereRenderer.hpp:40
virtual GLuint getLuminanceTexture()=0
Get OpenGL name of the luminance render target.
View direction of a pixel.
Definition: AtmosphereRenderer.hpp:57
virtual std::vector< float > getWavelengths()=0
Get the wavelengths used in computations.
virtual QString currentActivity() const =0
Get a string describing current activity.
std::vector< float > wavelengths
Wavelengths in nanometers.
Definition: AtmosphereRenderer.hpp:42
int stepsToDo
Total number of steps to do. Negative in case of error (e.g. when a step function was called at inapp...
Definition: AtmosphereRenderer.hpp:69