Atmosphere.hpp   Atmosphere.hpp 
skipping to change at line 27 skipping to change at line 27
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _ATMOSTPHERE_HPP_ #ifndef _ATMOSTPHERE_HPP_
#define _ATMOSTPHERE_HPP_ #define _ATMOSTPHERE_HPP_
#include "Skylight.hpp" #include "Skylight.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
#include "renderer/StelIndexBuffer.hpp"
#include "renderer/StelVertexBuffer.hpp"
#include "Skybright.hpp" #include "Skybright.hpp"
#include "StelFader.hpp" #include "StelFader.hpp"
#include "StelProjector.hpp"
#include <QOpenGLBuffer>
class StelProjector; class StelProjector;
class StelToneReproducer; class StelToneReproducer;
class StelCore; class StelCore;
//! Compute and display the daylight sky color. //! Compute and display the daylight sky color using openGL.
//! The sky brightness is computed with the SkyBright class, the color with the SkyLight. //! The sky brightness is computed with the SkyBright class, the color with the SkyLight.
//! Don't use this class directly but use it through the LandscapeMgr. //! Don't use this class directly but use it through the LandscapeMgr.
class Atmosphere class Atmosphere
{ {
public: public:
Atmosphere(void); Atmosphere();
virtual ~Atmosphere(void); virtual ~Atmosphere();
//! Called on every update to recompute colors of the atmosphere.
//!
//! Must be called at least once after a call to draw(), as vertexGr
id
//! is lazily initialized at the first draw call.
void computeColor(double JD, Vec3d _sunPos, Vec3d moonPos, float moo nPhase, StelCore* core, void computeColor(double JD, Vec3d _sunPos, Vec3d moonPos, float moo nPhase, StelCore* core,
float eclipseFac, float latitude = float latitude = 45.f, float altitude = 200.f,
45.f, float altitude = 200.f, float temperature = 15.f, float relativeHumidity = 40.f);
float temperature = 15.f, float re void draw(StelCore* core);
lativeHumidity = 40.f);
void draw(StelCore* core, class StelRenderer* renderer);
void update(double deltaTime) {fader.update((int)(deltaTime*1000));} void update(double deltaTime) {fader.update((int)(deltaTime*1000));}
//! Set fade in/out duration in seconds //! Set fade in/out duration in seconds
void setFadeDuration(float duration) {fader.setDuration((int)(durati on*1000.f));} void setFadeDuration(float duration) {fader.setDuration((int)(durati on*1000.f));}
//! Get fade in/out duration in seconds //! Get fade in/out duration in seconds
float getFadeDuration() {return (float)fader.getDuration()/1000.f;} float getFadeDuration() {return (float)fader.getDuration()/1000.f;}
//! Define whether to display atmosphere //! Define whether to display atmosphere
void setFlagShow(bool b){fader = b;} void setFlagShow(bool b){fader = b;}
//! Get whether atmosphere is displayed //! Get whether atmosphere is displayed
bool getFlagShow() const {return fader;} bool getFlagShow() const {return fader;}
//! Get the actual atmosphere intensity due to eclipses + fader //! Get the actual atmosphere intensity due to eclipses + fader
//! @return the display intensity ranging from 0 to 1 //! @return the display intensity ranging from 0 to 1
float getRealDisplayIntensityFactor(void) const {return fader.getInt erstate()*eclipseFactor;} float getRealDisplayIntensityFactor() const {return fader.getInterst ate()*eclipseFactor;}
// let's you know how far faded in or out the atm is (0-1) // let's you know how far faded in or out the atm is (0-1)
float getFadeIntensity(void) const {return fader.getInterstate();} float getFadeIntensity() const {return fader.getInterstate();}
//! Get the average luminance of the atmosphere in cd/m2 //! Get the average luminance of the atmosphere in cd/m2
//! If atmosphere is off, the luminance includes the background star light + light pollution. //! If atmosphere is off, the luminance includes the background star light + light pollution.
//! Otherwise it includes the atmosphere + background starlight + ec lipse factor + light pollution. //! Otherwise it includes the atmosphere + background starlight + ec lipse factor + light pollution.
//! @return the last computed average luminance of the atmosphere in cd/m2. //! @return the last computed average luminance of the atmosphere in cd/m2.
float getAverageLuminance(void) const {return averageLuminance;} float getAverageLuminance() const {return averageLuminance;}
//! Set the light pollution luminance in cd/m^2 //! Set the light pollution luminance in cd/m^2
void setLightPollutionLuminance(float f) { lightPollutionLuminance = f; } void setLightPollutionLuminance(float f) { lightPollutionLuminance = f; }
//! Get the light pollution luminance in cd/m^2 //! Get the light pollution luminance in cd/m^2
float getLightPollutionLuminance() const { return lightPollutionLumi nance; } float getLightPollutionLuminance() const { return lightPollutionLumi nance; }
private: private:
// Vertex with a 2D position and a color.
struct Vertex
{
Vec2f position;
Vec4f color;
Vertex(const Vec2f position, const Vec4f& color) : position(
position), color(color) {}
VERTEX_ATTRIBUTES(Vec2f Position, Vec4f Color);
};
Vec4i viewport; Vec4i viewport;
Skylight sky; Skylight sky;
Skybright skyb; Skybright skyb;
int skyResolutionY, skyResolutionX; int skyResolutionY,skyResolutionX;
Vec2f* posGrid;
QOpenGLBuffer posGridBuffer;
QOpenGLBuffer indicesBuffer;
Vec4f* colorGrid;
QOpenGLBuffer colorGridBuffer;
//! The average luminance of the atmosphere in cd/m2 //! The average luminance of the atmosphere in cd/m2
float averageLuminance; float averageLuminance;
float eclipseFactor; float eclipseFactor;
LinearFader fader; LinearFader fader;
float lightPollutionLuminance; float lightPollutionLuminance;
//! Shader used for xyYToRGB computation. If NULL, shader is not use //! Vertex shader used for xyYToRGB computation
d. class QOpenGLShaderProgram* atmoShaderProgram;
class StelGLSLShader* shader; struct {
int alphaWaOverAlphaDa;
//! Rectangular grid of vertices making up the atmosphere. int oneOverGamma;
StelVertexBuffer<Vertex>* vertexGrid; int term2TimesOneOverMaxdLpOneOverGamma;
int brightnessScale;
//! Index buffers representing triangle strips for each row in the g int sunPos;
rid. int term_x, Ax, Bx, Cx, Dx, Ex;
QVector<StelIndexBuffer*> rowIndices; int term_y, Ay, By, Cy, Dy, Ey;
int projectionMatrix;
//! Renderer used to construct row index buffers at viewport changes int skyVertex;
. int skyColor;
//! } shaderAttribLocations;
//! Lazily initialized - NULL until the first draw call.
class StelRenderer* renderer;
//! Lazily loads the shader used for drawing.
//!
//! Called at the first call to draw().
//!
//! This should only be called if the Renderer supports GLSL.
//!
//! @return true on success, false on failure (allowing for a shader
-less fallback).
bool lazyLoadShader(class StelRenderer* renderer);
//! Update the vertex grid and index buffers.
//!
//! Called by computeColor after the viewport changes.
void updateGrid(const StelProjectorP projector);
}; };
#endif // _ATMOSTPHERE_HPP_ #endif // _ATMOSTPHERE_HPP_
 End of changes. 12 change blocks. 
61 lines changed or deleted 32 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/