Cleanup code related to non-GLSL render paths

pull/110/head
Hleb Valoshka 2018-10-27 19:40:32 +03:00
parent 2828853d83
commit fa5ab79304
7 changed files with 67 additions and 123 deletions

View File

@ -763,6 +763,7 @@ Command* CommandParser::parseCommand()
}
else if (commandName == "renderpath")
{
#if 0
GLContext::GLRenderPath glcpath = GLContext::GLPath_GLSL;
string path;
paramList->getString("path", path);
@ -771,6 +772,9 @@ Command* CommandParser::parseCommand()
glcpath = GLContext::GLPath_GLSL;
cmd = new CommandRenderPath(glcpath);
#else
cmd = new CommandRenderPath(GLContext::GLPath_GLSL);
#endif
}
else if (commandName == "splitview")
{

View File

@ -753,7 +753,7 @@ void CommandSetTextureResolution::process(ExecutionEnvironment& env)
////////////////
// Set RenderPath command
// Set RenderPath command. Left for compatibility.
CommandRenderPath::CommandRenderPath(GLContext::GLRenderPath _path) :
path(_path)
@ -762,6 +762,7 @@ CommandRenderPath::CommandRenderPath(GLContext::GLRenderPath _path) :
void CommandRenderPath::process(ExecutionEnvironment& env)
{
#if 0
GLContext* context = env.getRenderer()->getGLContext();
if (context != nullptr)
@ -769,6 +770,7 @@ void CommandRenderPath::process(ExecutionEnvironment& env)
context->setRenderPath(path);
env.getCelestiaCore()->notifyWatchers(CelestiaCore::RenderFlagsChanged);
}
#endif
}

View File

@ -97,17 +97,10 @@ void Nebula::render(const GLContext& /*glcontext*/,
glScalef(getRadius(), getRadius(), getRadius());
glRotate(getOrientation());
if (glcontext.getRenderPath() == GLContext::GLPath_GLSL)
{
GLSLUnlit_RenderContext rc(getRadius());
rc.setPointScale(2.0f * getRadius() / pixelSize);
g->render(rc);
glUseProgram(0);
}
else
{
assert(glcontext.getRenderPath() != GLContext::GLPath_GLSL);
}
GLSLUnlit_RenderContext rc(getRadius());
rc.setPointScale(2.0f * getRadius() / pixelSize);
g->render(rc);
glUseProgram(0);
glEnable(GL_BLEND);
}

View File

@ -4683,7 +4683,6 @@ void Renderer::renderObject(const Vector3f& pos,
if (obj.surface->baseTexture.tex[textureResolution] != InvalidResource)
ri.baseTex = obj.surface->baseTexture.find(textureResolution);
if ((obj.surface->appearanceFlags & Surface::ApplyBumpMap) != 0 &&
context->bumpMappingSupported() &&
obj.surface->bumpTexture.tex[textureResolution] != InvalidResource)
ri.bumpTex = obj.surface->bumpTexture.find(textureResolution);
if ((obj.surface->appearanceFlags & Surface::ApplyNightMap) != 0 &&
@ -4738,7 +4737,6 @@ void Renderer::renderObject(const Vector3f& pos,
}
ri.ambientColor = ambientColor;
ri.hazeColor = obj.surface->hazeColor;
ri.specularColor = obj.surface->specularColor;
ri.specularPower = obj.surface->specularPower;
ri.useTexEnvCombine = true;
@ -4864,20 +4862,12 @@ void Renderer::renderObject(const Vector3f& pos,
// A null model indicates that this body is a sphere
if (lit)
{
switch (context->getRenderPath())
{
case GLContext::GLPath_GLSL:
renderEllipsoid_GLSL(ri, ls,
const_cast<Atmosphere*>(obj.atmosphere), cloudTexOffset,
scaleFactors,
textureResolution,
renderFlags,
obj.orientation, viewFrustum, *context);
break;
default:
renderSphereDefault(ri, viewFrustum, true, *context);
}
renderEllipsoid_GLSL(ri, ls,
const_cast<Atmosphere*>(obj.atmosphere), cloudTexOffset,
scaleFactors,
textureResolution,
renderFlags,
obj.orientation, viewFrustum, *context);
}
else
{
@ -4890,61 +4880,47 @@ void Renderer::renderObject(const Vector3f& pos,
{
ResourceHandle texOverride = obj.surface->baseTexture.tex[textureResolution];
if (context->getRenderPath() == GLContext::GLPath_GLSL)
if (lit)
{
if (lit)
{
renderGeometry_GLSL(geometry,
ri,
texOverride,
ls,
obj.atmosphere,
geometryScale,
renderFlags,
obj.orientation,
astro::daysToSecs(now - astro::J2000));
}
else
{
renderGeometry_GLSL_Unlit(geometry,
ri,
texOverride,
geometryScale,
renderFlags,
obj.orientation,
astro::daysToSecs(now - astro::J2000));
}
for (unsigned int i = 1; i < 8;/*context->getMaxTextures();*/ i++)
{
glActiveTexture(GL_TEXTURE0 + i);
glDisable(GL_TEXTURE_2D);
}
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glUseProgram(0);
renderGeometry_GLSL(geometry,
ri,
texOverride,
ls,
obj.atmosphere,
geometryScale,
renderFlags,
obj.orientation,
astro::daysToSecs(now - astro::J2000));
}
else
{
assert(context->getRenderPath() != GLContext::GLPath_GLSL);
renderGeometry_GLSL_Unlit(geometry,
ri,
texOverride,
geometryScale,
renderFlags,
obj.orientation,
astro::daysToSecs(now - astro::J2000));
}
for (unsigned int i = 1; i < 8;/*context->getMaxTextures();*/ i++)
{
glActiveTexture(GL_TEXTURE0 + i);
glDisable(GL_TEXTURE_2D);
}
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glUseProgram(0);
}
}
if (obj.rings != nullptr && distance <= obj.rings->innerRadius)
{
if (context->getRenderPath() == GLContext::GLPath_GLSL)
{
renderRings_GLSL(*obj.rings, ri, ls,
radius, 1.0f - obj.semiAxes.y(),
textureResolution,
(renderFlags & ShowRingShadows) != 0 && lit,
detailOptions.ringSystemSections);
}
else
{
assert(context->getRenderPath() != GLContext::GLPath_GLSL);
}
renderRings_GLSL(*obj.rings, ri, ls,
radius, 1.0f - obj.semiAxes.y(),
textureResolution,
(renderFlags & ShowRingShadows) != 0 && lit,
detailOptions.ringSystemSections);
}
if (obj.atmosphere != nullptr)
@ -4972,8 +4948,7 @@ void Renderer::renderObject(const Vector3f& pos,
{
// Only use new atmosphere code in OpenGL 2.0 path when new style parameters are defined.
// TODO: convert old style atmopshere parameters
if (context->getRenderPath() == GLContext::GLPath_GLSL &&
atmosphere->mieScaleHeight > 0.0f)
if (atmosphere->mieScaleHeight > 0.0f)
{
float atmScale = 1.0f + atmosphere->height / radius;
@ -5056,24 +5031,17 @@ void Renderer::renderObject(const Vector3f& pos,
if (lit)
{
if (context->getRenderPath() == GLContext::GLPath_GLSL)
{
renderClouds_GLSL(ri, ls,
atmosphere,
cloudTex,
cloudNormalMap,
cloudTexOffset,
scaleFactors,
textureResolution,
renderFlags,
obj.orientation,
viewFrustum,
*context);
}
else
{
assert(context->getRenderPath() != GLContext::GLPath_GLSL);
}
renderClouds_GLSL(ri, ls,
atmosphere,
cloudTex,
cloudNormalMap,
cloudTexOffset,
scaleFactors,
textureResolution,
renderFlags,
obj.orientation,
viewFrustum,
*context);
}
else
{
@ -5115,18 +5083,11 @@ void Renderer::renderObject(const Vector3f& pos,
if (obj.rings != nullptr && distance > obj.rings->innerRadius)
{
glDepthMask(GL_FALSE);
if (context->getRenderPath() == GLContext::GLPath_GLSL)
{
renderRings_GLSL(*obj.rings, ri, ls,
radius, 1.0f - obj.semiAxes.y(),
textureResolution,
(renderFlags & ShowRingShadows) != 0 && lit,
detailOptions.ringSystemSections);
}
else
{
assert(context->getRenderPath() != GLContext::GLPath_GLSL);
}
renderRings_GLSL(*obj.rings, ri, ls,
radius, 1.0f - obj.semiAxes.y(),
textureResolution,
(renderFlags & ShowRingShadows) != 0 && lit,
detailOptions.ringSystemSections);
}
// Disable all light sources other than the first
@ -5237,7 +5198,7 @@ bool Renderer::testEclipse(const Body& receiver,
// If the caster has a ring system, see if it casts a shadow on the receiver.
// Ring shadows are only supported in the OpenGL 2.0 path.
if (caster.getRings() && context->getRenderPath() == GLContext::GLPath_GLSL)
if (caster.getRings())
{
bool shadowed = false;
@ -7882,7 +7843,6 @@ void Renderer::loadTextures(Body* body)
if (surface.baseTexture.tex[textureResolution] != InvalidResource)
surface.baseTexture.find(textureResolution);
if ((surface.appearanceFlags & Surface::ApplyBumpMap) != 0 &&
context->bumpMappingSupported() &&
surface.bumpTexture.tex[textureResolution] != InvalidResource)
surface.bumpTexture.find(textureResolution);
if ((surface.appearanceFlags & Surface::ApplyNightMap) != 0 &&

View File

@ -17,7 +17,6 @@ struct RenderInfo
Texture* nightTex;
Texture* glossTex;
Texture* overlayTex;
Color hazeColor;
Color specularColor;
float specularPower;
Eigen::Vector3f sunDir_eye;
@ -46,7 +45,6 @@ struct RenderInfo
nightTex(nullptr),
glossTex(nullptr),
overlayTex(nullptr),
hazeColor(0.0f, 0.0f, 0.0f),
specularColor(0.0f, 0.0f, 0.0f),
specularPower(0.0f),
sunDir_eye(Eigen::Vector3f::UnitZ()),

View File

@ -199,16 +199,6 @@ static void FillinSurface(Hash* surfaceData,
const std::string& path)
{
surfaceData->getColor("Color", surface->color);
// Haze is deprecated; used only in pre-OpenGL 2.0 render paths
Color hazeColor = surface->hazeColor;
float hazeDensity = hazeColor.alpha();
if (surfaceData->getColor("HazeColor", hazeColor) | surfaceData->getNumber("HazeDensity", hazeDensity))
{
surface->hazeColor = Color(hazeColor.red(), hazeColor.green(),
hazeColor.blue(), hazeDensity);
}
surfaceData->getColor("SpecularColor", surface->specularColor);
surfaceData->getNumber("SpecularPower", surface->specularPower);
@ -861,7 +851,6 @@ static Body* CreateBody(const string& name,
else
{
surface.color = Color(1.0f, 1.0f, 1.0f);
surface.hazeColor = Color(0.0f, 0.0f, 0.0f, 0.0f);
}
FillinSurface(planetData, &surface, path);
body->setSurface(surface);
@ -1256,9 +1245,8 @@ bool LoadSolarSystemObjects(istream& in,
}
else if (itemType == "AltSurface")
{
Surface* surface = new Surface(); // FIXME: check
Surface* surface = new Surface();
surface->color = Color(1.0f, 1.0f, 1.0f);
surface->hazeColor = Color(0.0f, 0.0f, 0.0f, 0.0f);
FillinSurface(objectData, surface, directory);
if (parent.body() != nullptr)
parent.body()->addAlternateSurface(primaryName, surface);

View File

@ -48,7 +48,6 @@ class Surface
uint32_t appearanceFlags;
Color color;
Color hazeColor;
Color specularColor;
float specularPower;
MultiResTexture baseTexture; // surface colors