Make ShaderManager private property of Renderer
parent
8aaf7fb205
commit
dbd7090117
|
@ -20,6 +20,7 @@
|
|||
#include "asterism.h"
|
||||
#include "parser.h"
|
||||
#include "vecgl.h"
|
||||
#include "render.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -106,7 +107,7 @@ bool Asterism::isColorOverridden() const
|
|||
|
||||
/*! Draw visible asterisms.
|
||||
*/
|
||||
void AsterismList::render(Color defaultColor)
|
||||
void AsterismList::render(const Color& defaultColor, const Renderer& renderer)
|
||||
{
|
||||
if (vboId == 0)
|
||||
{
|
||||
|
@ -129,7 +130,7 @@ void AsterismList::render(Color defaultColor)
|
|||
glBindBuffer(GL_ARRAY_BUFFER, vboId);
|
||||
}
|
||||
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
|
||||
CelestiaGLProgram* prog = renderer.getShaderManager().getShader(shadprop);
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "stardb.h"
|
||||
#include "shadermanager.h"
|
||||
|
||||
class Renderer;
|
||||
class AsterismList;
|
||||
|
||||
class Asterism
|
||||
|
@ -60,7 +61,7 @@ class Asterism
|
|||
class AsterismList : public std::vector<Asterism*>
|
||||
{
|
||||
public:
|
||||
void render(Color color);
|
||||
void render(const Color& color, const Renderer& renderer);
|
||||
|
||||
private:
|
||||
void cleanup();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <GL/glew.h>
|
||||
#include "boundaries.h"
|
||||
#include "astro.h"
|
||||
#include "render.h"
|
||||
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
|
@ -71,7 +72,7 @@ void ConstellationBoundaries::lineto(float ra, float dec)
|
|||
}
|
||||
|
||||
|
||||
void ConstellationBoundaries::render(Color color)
|
||||
void ConstellationBoundaries::render(const Color& color, const Renderer& renderer)
|
||||
{
|
||||
if (vboId == 0)
|
||||
{
|
||||
|
@ -88,7 +89,7 @@ void ConstellationBoundaries::render(Color color)
|
|||
glBindBuffer(GL_ARRAY_BUFFER, vboId);
|
||||
}
|
||||
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
|
||||
CelestiaGLProgram* prog = renderer.getShaderManager().getShader(shadprop);
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "celutil/color.h"
|
||||
#include "shadermanager.h"
|
||||
|
||||
class Renderer;
|
||||
|
||||
class ConstellationBoundaries
|
||||
{
|
||||
|
@ -33,7 +34,7 @@ class ConstellationBoundaries
|
|||
|
||||
void moveto(float ra, float dec);
|
||||
void lineto(float ra, float dec);
|
||||
void render(Color color);
|
||||
void render(const Color& color, const Renderer& renderer);
|
||||
|
||||
private:
|
||||
void cleanup();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <Eigen/Geometry>
|
||||
|
||||
class Selection;
|
||||
class Renderer;
|
||||
|
||||
constexpr const float DSO_DEFAULT_ABS_MAGNITUDE = -1000.0f;
|
||||
|
||||
|
@ -92,7 +93,8 @@ class DeepSkyObject : public CatEntry
|
|||
const Eigen::Vector3f& offset,
|
||||
const Eigen::Quaternionf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize) = 0;
|
||||
float pixelSize,
|
||||
const Renderer*) = 0;
|
||||
|
||||
virtual unsigned int getRenderMask() const { return 0; }
|
||||
virtual unsigned int getLabelMask() const { return 0; }
|
||||
|
|
|
@ -255,7 +255,8 @@ void Galaxy::render(const GLContext& context,
|
|||
const Vector3f& offset,
|
||||
const Quaternionf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize)
|
||||
float pixelSize,
|
||||
const Renderer* /* unused */)
|
||||
{
|
||||
if (form == nullptr)
|
||||
{
|
||||
|
|
|
@ -45,19 +45,17 @@ class Galaxy : public DeepSkyObject
|
|||
double& distanceToPicker,
|
||||
double& cosAngleToBoundCenter) const;
|
||||
virtual bool load(AssociativeArray*, const std::string&);
|
||||
virtual void render(const GLContext& context,
|
||||
const Eigen::Vector3f& offset,
|
||||
virtual void render(const Eigen::Vector3f& offset,
|
||||
const Eigen::Quaternionf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize);
|
||||
virtual void renderGalaxyPointSprites(const GLContext& context,
|
||||
const Eigen::Vector3f& offset,
|
||||
float pixelSize,
|
||||
const Renderer* r = nullptr);
|
||||
virtual void renderGalaxyPointSprites(const Eigen::Vector3f& offset,
|
||||
const Eigen::Quaternionf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize);
|
||||
#if 0
|
||||
virtual void renderGalaxyEllipsoid(const GLContext& context,
|
||||
const Eigen::Vector3f& offset,
|
||||
virtual void renderGalaxyEllipsoid(const Eigen::Vector3f& offset,
|
||||
const Eigen::Quaternionf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize);
|
||||
|
|
|
@ -325,21 +325,21 @@ bool Globular::load(AssociativeArray* params, const string& resPath)
|
|||
}
|
||||
|
||||
|
||||
void Globular::render(const GLContext& context,
|
||||
const Vector3f& offset,
|
||||
const Quaternionf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize)
|
||||
void Globular::render(const Vector3f& offset,
|
||||
const Quaternionf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize,
|
||||
const Renderer* /* unused */)
|
||||
{
|
||||
#ifdef __CELVEC__
|
||||
renderGlobularPointSprites(context, fromEigen(offset), fromEigen(viewerOrientation), brightness, pixelSize);
|
||||
renderGlobularPointSprites(fromEigen(offset), fromEigen(viewerOrientation), brightness, pixelSize);
|
||||
#else
|
||||
renderGlobularPointSprites(context, offset, viewerOrientation, brightness, pixelSize);
|
||||
renderGlobularPointSprites(offset, viewerOrientation, brightness, pixelSize);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Globular::renderGlobularPointSprites(const GLContext& /*unused*/,
|
||||
void Globular::renderGlobularPointSprites(
|
||||
#ifdef __CELVEC__
|
||||
const Vec3f& offset,
|
||||
const Quatf& viewerOrientation,
|
||||
|
|
|
@ -66,12 +66,12 @@ class Globular : public DeepSkyObject
|
|||
double& distanceToPicker,
|
||||
double& cosAngleToBoundCenter) const;
|
||||
virtual bool load(AssociativeArray*, const std::string&);
|
||||
virtual void render(const GLContext& context,
|
||||
const Eigen::Vector3f& offset,
|
||||
virtual void render(const Eigen::Vector3f& offset,
|
||||
const Eigen::Quaternionf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize);
|
||||
virtual void renderGlobularPointSprites(const GLContext& context,
|
||||
float pixelSize,
|
||||
const Renderer* r = nullptr);
|
||||
virtual void renderGlobularPointSprites(
|
||||
#ifdef __CELVEC__
|
||||
const Vec3f& offset,
|
||||
const Quatf& viewerOrientation,
|
||||
|
|
|
@ -84,7 +84,8 @@ void Nebula::render(const GLContext& /*glcontext*/,
|
|||
const Vector3f& /*unused*/,
|
||||
const Quaternionf& /*unused*/,
|
||||
float /*unused*/,
|
||||
float pixelSize)
|
||||
float pixelSize,
|
||||
const Renderer* renderer)
|
||||
{
|
||||
Geometry* g = nullptr;
|
||||
if (geometry != InvalidResource)
|
||||
|
@ -97,7 +98,7 @@ void Nebula::render(const GLContext& /*glcontext*/,
|
|||
glScalef(getRadius(), getRadius(), getRadius());
|
||||
glRotate(getOrientation());
|
||||
|
||||
GLSLUnlit_RenderContext rc(getRadius());
|
||||
GLSLUnlit_RenderContext rc(renderer, getRadius());
|
||||
rc.setPointScale(2.0f * getRadius() / pixelSize);
|
||||
g->render(rc);
|
||||
glUseProgram(0);
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <celutil/reshandle.h>
|
||||
#include <celengine/deepskyobj.h>
|
||||
|
||||
|
||||
class Nebula : public DeepSkyObject
|
||||
{
|
||||
public:
|
||||
|
@ -33,7 +32,8 @@ class Nebula : public DeepSkyObject
|
|||
const Eigen::Vector3f& offset,
|
||||
const Eigen::Quaternionf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize);
|
||||
float pixelSize,
|
||||
const Renderer* renderer);
|
||||
|
||||
virtual unsigned int getRenderMask() const;
|
||||
virtual unsigned int getLabelMask() const;
|
||||
|
|
|
@ -67,7 +67,8 @@ void OpenCluster::render(const GLContext& /*unused*/,
|
|||
const Vector3f& /*unused*/,
|
||||
const Quaternionf& /*unused*/,
|
||||
float /*unused*/,
|
||||
float /*unused*/)
|
||||
float /*unused*/,
|
||||
const Renderer* /*unused*/)
|
||||
{
|
||||
// Nothing to do right now; open clusters are only visible as their
|
||||
// constituent stars and a label when labels are turned on. A good idea
|
||||
|
|
|
@ -33,7 +33,8 @@ class OpenCluster : public DeepSkyObject
|
|||
const Eigen::Vector3f& offset,
|
||||
const Eigen::Quaternionf& viewerOrientation,
|
||||
float brightness,
|
||||
float pixelSize);
|
||||
float pixelSize,
|
||||
const Renderer* r = nullptr);
|
||||
|
||||
virtual unsigned int getRenderMask() const;
|
||||
virtual unsigned int getLabelMask() const;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "body.h"
|
||||
#include <GL/glew.h>
|
||||
#include "vecgl.h"
|
||||
#include "render.h"
|
||||
|
||||
using namespace cmod;
|
||||
using namespace Eigen;
|
||||
|
@ -70,8 +71,9 @@ GetTextureHandle(Material::TextureResource* texResource)
|
|||
}
|
||||
|
||||
|
||||
RenderContext::RenderContext() :
|
||||
material(&defaultMaterial)
|
||||
RenderContext::RenderContext(const Renderer* _renderer) :
|
||||
material(&defaultMaterial),
|
||||
renderer(_renderer)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -295,7 +297,11 @@ setExtendedVertexArrays(const Mesh::VertexDescription& desc,
|
|||
|
||||
/***** GLSL render context ******/
|
||||
|
||||
GLSL_RenderContext::GLSL_RenderContext(const LightingState& ls, float _objRadius, const Quaternionf& orientation) :
|
||||
GLSL_RenderContext::GLSL_RenderContext(const Renderer* renderer,
|
||||
const LightingState& ls,
|
||||
float _objRadius,
|
||||
const Quaternionf& orientation) :
|
||||
RenderContext(renderer),
|
||||
lightingState(ls),
|
||||
objRadius(_objRadius),
|
||||
objScale(Vector3f::Constant(_objRadius)),
|
||||
|
@ -305,7 +311,11 @@ GLSL_RenderContext::GLSL_RenderContext(const LightingState& ls, float _objRadius
|
|||
}
|
||||
|
||||
|
||||
GLSL_RenderContext::GLSL_RenderContext(const LightingState& ls, const Eigen::Vector3f& _objScale, const Quaternionf& orientation) :
|
||||
GLSL_RenderContext::GLSL_RenderContext(const Renderer* renderer,
|
||||
const LightingState& ls,
|
||||
const Eigen::Vector3f& _objScale,
|
||||
const Quaternionf& orientation) :
|
||||
RenderContext(renderer),
|
||||
lightingState(ls),
|
||||
objRadius(_objScale.maxCoeff()),
|
||||
objScale(_objScale),
|
||||
|
@ -483,7 +493,8 @@ GLSL_RenderContext::makeCurrent(const Material& m)
|
|||
}
|
||||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shaderProps);
|
||||
assert(renderer != nullptr);
|
||||
CelestiaGLProgram* prog = renderer->getShaderManager().getShader(shaderProps);
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -639,7 +650,8 @@ GLSL_RenderContext::setLunarLambert(float l)
|
|||
|
||||
/***** GLSL-Unlit render context ******/
|
||||
|
||||
GLSLUnlit_RenderContext::GLSLUnlit_RenderContext(float _objRadius) :
|
||||
GLSLUnlit_RenderContext::GLSLUnlit_RenderContext(const Renderer* renderer, float _objRadius) :
|
||||
RenderContext(renderer),
|
||||
blendMode(Material::InvalidBlend),
|
||||
objRadius(_objRadius)
|
||||
{
|
||||
|
@ -696,7 +708,8 @@ GLSLUnlit_RenderContext::makeCurrent(const Material& m)
|
|||
shaderProps.texUsage |= ShaderProperties::VertexColors;
|
||||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shaderProps);
|
||||
assert(renderer != nullptr);
|
||||
CelestiaGLProgram* prog = renderer->getShaderManager().getShader(shaderProps);
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <celmodel/mesh.h>
|
||||
#include <Eigen/Geometry>
|
||||
|
||||
class Renderer;
|
||||
|
||||
class RenderContext
|
||||
{
|
||||
|
@ -22,7 +23,7 @@ class RenderContext
|
|||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
|
||||
RenderContext(const cmod::Material*);
|
||||
RenderContext();
|
||||
RenderContext(const Renderer*);
|
||||
virtual ~RenderContext() = default;
|
||||
|
||||
virtual void makeCurrent(const cmod::Material&) = 0;
|
||||
|
@ -59,6 +60,7 @@ class RenderContext
|
|||
Eigen::Quaternionf cameraOrientation; // required for drawing billboards
|
||||
|
||||
protected:
|
||||
const Renderer* renderer { nullptr };
|
||||
bool usePointSize{ false };
|
||||
bool useNormals{ true };
|
||||
bool useColors{ false };
|
||||
|
@ -72,16 +74,16 @@ class GLSL_RenderContext : public RenderContext
|
|||
public:
|
||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
|
||||
GLSL_RenderContext(const LightingState& ls, float _objRadius, const Eigen::Quaternionf& orientation);
|
||||
GLSL_RenderContext(const LightingState& ls, const Eigen::Vector3f& _objScale, const Eigen::Quaternionf& orientation);
|
||||
virtual ~GLSL_RenderContext();
|
||||
GLSL_RenderContext(const Renderer* r, const LightingState& ls, float _objRadius, const Eigen::Quaternionf& orientation);
|
||||
GLSL_RenderContext(const Renderer* r, const LightingState& ls, const Eigen::Vector3f& _objScale, const Eigen::Quaternionf& orientation);
|
||||
~GLSL_RenderContext() override;
|
||||
|
||||
virtual void makeCurrent(const cmod::Material&);
|
||||
virtual void setVertexArrays(const cmod::Mesh::VertexDescription& desc,
|
||||
const void* vertexData);
|
||||
void makeCurrent(const cmod::Material&) override;
|
||||
void setVertexArrays(const cmod::Mesh::VertexDescription& desc,
|
||||
const void* vertexData) override;
|
||||
|
||||
virtual void setLunarLambert(float);
|
||||
virtual void setAtmosphere(const Atmosphere*);
|
||||
void setLunarLambert(float);
|
||||
void setAtmosphere(const Atmosphere*);
|
||||
|
||||
private:
|
||||
void initLightingEnvironment();
|
||||
|
@ -106,12 +108,12 @@ class GLSL_RenderContext : public RenderContext
|
|||
class GLSLUnlit_RenderContext : public RenderContext
|
||||
{
|
||||
public:
|
||||
GLSLUnlit_RenderContext(float _objRadius);
|
||||
virtual ~GLSLUnlit_RenderContext();
|
||||
GLSLUnlit_RenderContext(const Renderer* r, float _objRadius);
|
||||
~GLSLUnlit_RenderContext() override;
|
||||
|
||||
virtual void makeCurrent(const cmod::Material&);
|
||||
virtual void setVertexArrays(const cmod::Mesh::VertexDescription& desc,
|
||||
const void* vertexData);
|
||||
void makeCurrent(const cmod::Material&) override;
|
||||
void setVertexArrays(const cmod::Mesh::VertexDescription& desc,
|
||||
const void* vertexData) override;
|
||||
|
||||
private:
|
||||
void initLightingEnvironment();
|
||||
|
@ -126,4 +128,3 @@ class GLSLUnlit_RenderContext : public RenderContext
|
|||
|
||||
|
||||
#endif // _CELENGINE_RENDCONTEXT_H_
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ double computeCosViewConeAngle(double verticalFOV, double width, double height)
|
|||
class PointStarVertexBuffer
|
||||
{
|
||||
public:
|
||||
PointStarVertexBuffer(unsigned int _capacity);
|
||||
PointStarVertexBuffer(const Renderer& _renderer, unsigned int _capacity);
|
||||
~PointStarVertexBuffer();
|
||||
void startPoints();
|
||||
void startSprites();
|
||||
|
@ -304,6 +304,7 @@ private:
|
|||
float pad;
|
||||
};
|
||||
|
||||
const Renderer& renderer;
|
||||
unsigned int capacity;
|
||||
unsigned int nStars{ 0 };
|
||||
StarVertex* vertices{ nullptr };
|
||||
|
@ -311,7 +312,9 @@ private:
|
|||
Texture* texture{ nullptr };
|
||||
};
|
||||
|
||||
PointStarVertexBuffer::PointStarVertexBuffer(unsigned int _capacity) :
|
||||
PointStarVertexBuffer::PointStarVertexBuffer(const Renderer& _renderer,
|
||||
unsigned int _capacity) :
|
||||
renderer(_renderer),
|
||||
capacity(_capacity)
|
||||
{
|
||||
vertices = new StarVertex[capacity];
|
||||
|
@ -328,7 +331,7 @@ void PointStarVertexBuffer::startSprites()
|
|||
shadprop.staticShader = true;
|
||||
shadprop.texUsage = ShaderProperties::PointSprite |
|
||||
ShaderProperties::NormalTexture;
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
|
||||
CelestiaGLProgram* prog = renderer.getShaderManager().getShader(shadprop);
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -496,8 +499,8 @@ Renderer::Renderer() :
|
|||
settingsChanged(true),
|
||||
objectAnnotationSetOpen(false)
|
||||
{
|
||||
pointStarVertexBuffer = new PointStarVertexBuffer(2048);
|
||||
glareVertexBuffer = new PointStarVertexBuffer(2048);
|
||||
pointStarVertexBuffer = new PointStarVertexBuffer(*this, 2048);
|
||||
glareVertexBuffer = new PointStarVertexBuffer(*this, 2048);
|
||||
skyVertices = new SkyVertex[MaxSkySlices * (MaxSkyRings + 1)];
|
||||
skyIndices = new uint32_t[(MaxSkySlices + 1) * 2 * MaxSkyRings];
|
||||
skyContour = new SkyContourPoint[MaxSkySlices + 1];
|
||||
|
@ -524,6 +527,8 @@ Renderer::Renderer() :
|
|||
{
|
||||
font[i] = nullptr;
|
||||
}
|
||||
|
||||
shaderManager = new ShaderManager();
|
||||
}
|
||||
|
||||
|
||||
|
@ -562,6 +567,8 @@ Renderer::~Renderer()
|
|||
|
||||
for(const auto tex : eclipseShadowTextures)
|
||||
delete tex;
|
||||
|
||||
delete shaderManager;
|
||||
}
|
||||
|
||||
|
||||
|
@ -4774,7 +4781,7 @@ void Renderer::renderObject(const Vector3f& pos,
|
|||
scaleFactors,
|
||||
textureResolution,
|
||||
renderFlags,
|
||||
obj.orientation, viewFrustum, *context);
|
||||
obj.orientation, viewFrustum, *context, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4797,7 +4804,8 @@ void Renderer::renderObject(const Vector3f& pos,
|
|||
geometryScale,
|
||||
renderFlags,
|
||||
obj.orientation,
|
||||
astro::daysToSecs(now - astro::J2000));
|
||||
astro::daysToSecs(now - astro::J2000),
|
||||
this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4807,7 +4815,8 @@ void Renderer::renderObject(const Vector3f& pos,
|
|||
geometryScale,
|
||||
renderFlags,
|
||||
obj.orientation,
|
||||
astro::daysToSecs(now - astro::J2000));
|
||||
astro::daysToSecs(now - astro::J2000),
|
||||
this);
|
||||
}
|
||||
|
||||
for (unsigned int i = 1; i < 8;/*context->getMaxTextures();*/ i++)
|
||||
|
@ -4829,7 +4838,8 @@ void Renderer::renderObject(const Vector3f& pos,
|
|||
radius, 1.0f - obj.semiAxes.y(),
|
||||
textureResolution,
|
||||
(renderFlags & ShowRingShadows) != 0 && lit,
|
||||
detailOptions.ringSystemSections);
|
||||
detailOptions.ringSystemSections,
|
||||
this);
|
||||
}
|
||||
|
||||
if (obj.atmosphere != nullptr)
|
||||
|
@ -4866,7 +4876,8 @@ void Renderer::renderObject(const Vector3f& pos,
|
|||
radius * atmScale,
|
||||
obj.orientation,
|
||||
viewFrustum,
|
||||
*context);
|
||||
*context,
|
||||
this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4950,7 +4961,8 @@ void Renderer::renderObject(const Vector3f& pos,
|
|||
renderFlags,
|
||||
obj.orientation,
|
||||
viewFrustum,
|
||||
*context);
|
||||
*context,
|
||||
this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4997,7 +5009,8 @@ void Renderer::renderObject(const Vector3f& pos,
|
|||
radius, 1.0f - obj.semiAxes.y(),
|
||||
textureResolution,
|
||||
(renderFlags & ShowRingShadows) != 0 && lit,
|
||||
detailOptions.ringSystemSections);
|
||||
detailOptions.ringSystemSections,
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5806,7 +5819,7 @@ void Renderer::renderAsterisms(const Universe& universe, float dist)
|
|||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
enableSmoothLines(renderFlags);
|
||||
universe.getAsterisms()->render(Color(ConstellationColor, opacity));
|
||||
universe.getAsterisms()->render(Color(ConstellationColor, opacity), *this);
|
||||
disableSmoothLines(renderFlags);
|
||||
}
|
||||
|
||||
|
@ -5827,7 +5840,7 @@ void Renderer::renderBoundaries(const Universe& universe, float dist)
|
|||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
enableSmoothLines(renderFlags);
|
||||
universe.getBoundaries()->render(Color(BoundaryColor, opacity));
|
||||
universe.getBoundaries()->render(Color(BoundaryColor, opacity), *this);
|
||||
disableSmoothLines(renderFlags);
|
||||
}
|
||||
|
||||
|
@ -6931,7 +6944,8 @@ void DSORenderer::process(DeepSkyObject* const & dso,
|
|||
relPos,
|
||||
observer->getOrientationf(),
|
||||
(float) brightness,
|
||||
pixelSize);
|
||||
pixelSize,
|
||||
renderer);
|
||||
glPopMatrix();
|
||||
|
||||
if (dsoRadius < 1000.0)
|
||||
|
|
|
@ -305,6 +305,8 @@ class Renderer
|
|||
LabelVerticalAlignment valign = VerticalAlignBottom,
|
||||
float size = 0.0f);
|
||||
|
||||
ShaderManager& getShaderManager() const { return *shaderManager; }
|
||||
|
||||
// Callbacks for renderables; these belong in a special renderer interface
|
||||
// only visible in object's render methods.
|
||||
void beginObjectAnnotations();
|
||||
|
@ -622,6 +624,7 @@ class Renderer
|
|||
|
||||
private:
|
||||
GLContext* context;
|
||||
ShaderManager* shaderManager{ nullptr };
|
||||
|
||||
int windowWidth;
|
||||
int windowHeight;
|
||||
|
|
|
@ -57,7 +57,8 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
uint64_t renderFlags,
|
||||
const Quaternionf& planetOrientation,
|
||||
const Frustum& frustum,
|
||||
const GLContext& context)
|
||||
const GLContext& context,
|
||||
const Renderer* renderer)
|
||||
{
|
||||
float radius = semiAxes.maxCoeff();
|
||||
|
||||
|
@ -224,7 +225,7 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
|
||||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
|
||||
CelestiaGLProgram* prog = renderer->getShaderManager().getShader(shadprop);
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -300,11 +301,12 @@ void renderGeometry_GLSL(Geometry* geometry,
|
|||
float geometryScale,
|
||||
uint64_t renderFlags,
|
||||
const Quaternionf& planetOrientation,
|
||||
double tsec)
|
||||
double tsec,
|
||||
const Renderer* renderer)
|
||||
{
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
GLSL_RenderContext rc(ls, geometryScale, planetOrientation);
|
||||
GLSL_RenderContext rc(renderer, ls, geometryScale, planetOrientation);
|
||||
|
||||
if ((renderFlags & Renderer::ShowAtmospheres) != 0)
|
||||
{
|
||||
|
@ -352,11 +354,12 @@ void renderGeometry_GLSL_Unlit(Geometry* geometry,
|
|||
float geometryScale,
|
||||
uint64_t /* renderFlags */,
|
||||
const Quaternionf& /* planetOrientation */,
|
||||
double tsec)
|
||||
double tsec,
|
||||
const Renderer* renderer)
|
||||
{
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
GLSLUnlit_RenderContext rc(geometryScale);
|
||||
GLSLUnlit_RenderContext rc(renderer, geometryScale);
|
||||
|
||||
rc.setPointScale(ri.pointScale);
|
||||
|
||||
|
@ -397,7 +400,8 @@ void renderClouds_GLSL(const RenderInfo& ri,
|
|||
uint64_t renderFlags,
|
||||
const Quaternionf& planetOrientation,
|
||||
const Frustum& frustum,
|
||||
const GLContext& context)
|
||||
const GLContext& context,
|
||||
const Renderer* renderer)
|
||||
{
|
||||
float radius = semiAxes.maxCoeff();
|
||||
|
||||
|
@ -474,7 +478,7 @@ void renderClouds_GLSL(const RenderInfo& ri,
|
|||
}
|
||||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
|
||||
CelestiaGLProgram* prog = renderer->getShaderManager().getShader(shadprop);
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -530,7 +534,8 @@ renderAtmosphere_GLSL(const RenderInfo& ri,
|
|||
float radius,
|
||||
const Quaternionf& /*planetOrientation*/,
|
||||
const Frustum& frustum,
|
||||
const GLContext& context)
|
||||
const GLContext& context,
|
||||
const Renderer* renderer)
|
||||
{
|
||||
// Currently, we just skip rendering an atmosphere when there are no
|
||||
// light sources, even though the atmosphere would still the light
|
||||
|
@ -547,7 +552,7 @@ renderAtmosphere_GLSL(const RenderInfo& ri,
|
|||
shadprop.lightModel = ShaderProperties::AtmosphereModel;
|
||||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
|
||||
CelestiaGLProgram* prog = renderer->getShaderManager().getShader(shadprop);
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -626,7 +631,8 @@ void renderRings_GLSL(RingSystem& rings,
|
|||
float planetOblateness,
|
||||
unsigned int textureResolution,
|
||||
bool renderShadow,
|
||||
unsigned int nSections)
|
||||
unsigned int nSections,
|
||||
const Renderer* renderer)
|
||||
{
|
||||
float inner = rings.innerRadius / planetRadius;
|
||||
float outer = rings.outerRadius / planetRadius;
|
||||
|
@ -651,7 +657,7 @@ void renderRings_GLSL(RingSystem& rings,
|
|||
|
||||
|
||||
// Get a shader for the current rendering configuration
|
||||
CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
|
||||
CelestiaGLProgram* prog = renderer->getShaderManager().getShader(shadprop);
|
||||
if (prog == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -751,7 +757,8 @@ void renderGeometryShadow_GLSL(Geometry* geometry,
|
|||
const LightingState& ls,
|
||||
float geometryScale,
|
||||
const Quaternionf& planetOrientation,
|
||||
double tsec)
|
||||
double tsec,
|
||||
const Renderer* renderer)
|
||||
{
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
|
@ -768,7 +775,7 @@ void renderGeometryShadow_GLSL(Geometry* geometry,
|
|||
// Render backfaces only in order to reduce self-shadowing artifacts
|
||||
glCullFace(GL_FRONT);
|
||||
|
||||
GLSL_RenderContext rc(ls, geometryScale, planetOrientation);
|
||||
GLSL_RenderContext rc(renderer, ls, geometryScale, planetOrientation);
|
||||
|
||||
rc.setPointScale(ri.pointScale);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <celengine/lightenv.h>
|
||||
#include <Eigen/Geometry>
|
||||
|
||||
class Renderer;
|
||||
|
||||
void renderEllipsoid_GLSL(const RenderInfo& ri,
|
||||
const LightingState& ls,
|
||||
|
@ -26,7 +27,8 @@ void renderEllipsoid_GLSL(const RenderInfo& ri,
|
|||
uint64_t renderFlags,
|
||||
const Eigen::Quaternionf& planetOrientation,
|
||||
const Frustum& frustum,
|
||||
const GLContext& context);
|
||||
const GLContext& context,
|
||||
const Renderer* renderer);
|
||||
|
||||
void renderGeometry_GLSL(Geometry* geometry,
|
||||
const RenderInfo& ri,
|
||||
|
@ -36,7 +38,8 @@ void renderGeometry_GLSL(Geometry* geometry,
|
|||
float geometryScale,
|
||||
uint64_t renderFlags,
|
||||
const Eigen::Quaternionf& planetOrientation,
|
||||
double tsec);
|
||||
double tsec,
|
||||
const Renderer* renderer);
|
||||
|
||||
void renderClouds_GLSL(const RenderInfo& ri,
|
||||
const LightingState& ls,
|
||||
|
@ -49,7 +52,8 @@ void renderClouds_GLSL(const RenderInfo& ri,
|
|||
uint64_t renderFlags,
|
||||
const Eigen::Quaternionf& planetOrientation,
|
||||
const Frustum& frustum,
|
||||
const GLContext& context);
|
||||
const GLContext& context,
|
||||
const Renderer* renderer);
|
||||
|
||||
void renderAtmosphere_GLSL(const RenderInfo& ri,
|
||||
const LightingState& ls,
|
||||
|
@ -57,7 +61,8 @@ void renderAtmosphere_GLSL(const RenderInfo& ri,
|
|||
float radius,
|
||||
const Eigen::Quaternionf& planetOrientation,
|
||||
const Frustum& frustum,
|
||||
const GLContext& context);
|
||||
const GLContext& context,
|
||||
const Renderer* renderer);
|
||||
|
||||
void renderRings_GLSL(RingSystem& rings,
|
||||
RenderInfo& ri,
|
||||
|
@ -66,7 +71,8 @@ void renderRings_GLSL(RingSystem& rings,
|
|||
float planetOblateness,
|
||||
unsigned int textureResolution,
|
||||
bool renderShadow,
|
||||
unsigned int nSections);
|
||||
unsigned int nSections,
|
||||
const Renderer* renderer);
|
||||
|
||||
void renderGeometry_GLSL_Unlit(Geometry* geometry,
|
||||
const RenderInfo& ri,
|
||||
|
@ -74,7 +80,8 @@ void renderGeometry_GLSL_Unlit(Geometry* geometry,
|
|||
float geometryScale,
|
||||
uint64_t renderFlags,
|
||||
const Eigen::Quaternionf& planetOrientation,
|
||||
double tsec);
|
||||
double tsec,
|
||||
const Renderer* renderer);
|
||||
|
||||
|
||||
class FramebufferObject
|
||||
|
|
|
@ -53,14 +53,6 @@ static const char* errorFragmentShaderSource =
|
|||
|
||||
static const char* CommonHeader = "#version 120\n";
|
||||
|
||||
ShaderManager&
|
||||
GetShaderManager()
|
||||
{
|
||||
static ShaderManager g_ShaderManager;
|
||||
|
||||
return g_ShaderManager;
|
||||
}
|
||||
|
||||
|
||||
ShaderProperties::ShaderProperties() :
|
||||
nLights(0),
|
||||
|
|
|
@ -294,6 +294,4 @@ class ShaderManager
|
|||
std::map<ShaderProperties, CelestiaGLProgram*> shaders;
|
||||
};
|
||||
|
||||
extern ShaderManager& GetShaderManager();
|
||||
|
||||
#endif // _CELENGINE_SHADERMANAGER_H_
|
||||
|
|
Loading…
Reference in New Issue