Remove glcontext.*

pull/1285/head
Andrew Tribick 2021-12-29 13:30:13 +01:00 committed by ajtribick
parent b683c7801d
commit 86f2aab284
16 changed files with 2 additions and 353 deletions

View File

@ -45,8 +45,6 @@ set(CELENGINE_SOURCES
galaxy.cpp
galaxy.h
geometry.h
#glcontext.cpp
#glcontext.h
glmarker.cpp
globular.cpp
globular.h

View File

@ -14,9 +14,6 @@
#include <string>
#include <iostream>
#include <celengine/astroobj.h>
#ifdef USE_GLCONTEXT
#include <celengine/glcontext.h>
#endif
#include <celengine/parser.h>
#include <celcompat/filesystem.h>
#include <Eigen/Core>

View File

@ -1,89 +0,0 @@
// glcontext.h
//
// Copyright (C) 2003, Chris Laurel <claurel@shatters.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
#include <algorithm>
#include "glcontext.h"
#include "glsupport.h"
using namespace std;
void GLContext::init(const vector<string>& ignoreExt)
{
auto* extensionsString = (char*) glGetString(GL_EXTENSIONS);
if (extensionsString != nullptr)
{
char* next = extensionsString;
while (*next != '\0')
{
while (*next != '\0' && *next != ' ')
next++;
string ext(extensionsString, next - extensionsString);
// scan the ignore list
auto iter = std::find(ignoreExt.begin(), ignoreExt.end(), ext);
if (iter == ignoreExt.end())
extensions.push_back(ext);
if (*next == '\0')
break;
next++;
extensionsString = next;
}
}
glGetIntegerv(GL_MAX_TEXTURE_UNITS,
(GLint*) &maxSimultaneousTextures);
}
bool GLContext::setRenderPath(GLRenderPath path)
{
if (!renderPathSupported(path))
return false;
renderPath = path;
return true;
}
bool GLContext::renderPathSupported(GLRenderPath path) const
{
switch (path)
{
case GLPath_GLSL:
return GLEW_VERSION_2_1 != GL_FALSE;
default:
return false;
}
}
GLContext::GLRenderPath GLContext::nextRenderPath()
{
#if 0
GLContext::GLRenderPath newPath = renderPath;
do {
newPath = (GLRenderPath) ((int) newPath + 1);;
if (newPath > GLPath_GLSL)
newPath = GLPath_Basic;
} while (newPath != renderPath && !renderPathSupported(newPath));
renderPath = newPath;
return renderPath;
#endif
return GLPath_GLSL;
}

View File

@ -1,41 +0,0 @@
// glcontext.h
//
// Copyright (C) 2003, Chris Laurel <claurel@shatters.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
#ifndef _CELENGINE_GLCONTEXT_H_
#define _CELENGINE_GLCONTEXT_H_
#include <vector>
#include <string>
class GLContext
{
public:
enum GLRenderPath
{
GLPath_GLSL = 8,
};
void init(const std::vector<std::string>& ignoreExt);
GLRenderPath getRenderPath() const { return renderPath; };
bool setRenderPath(GLRenderPath);
bool renderPathSupported(GLRenderPath) const;
GLRenderPath nextRenderPath();
int getMaxTextures() const { return maxSimultaneousTextures; };
private:
GLRenderPath renderPath{ GLPath_GLSL };
int maxSimultaneousTextures { 1 };
std::vector<std::string> extensions;
};
#endif // _CELENGINE_GLCONTEXT_H_

View File

@ -12,9 +12,6 @@
#define CELENGINE_LODSPHEREMESH_H_
#include <celengine/texture.h>
#ifdef USE_GLCONTEXT
#include <celengine/glcontext.h>
#endif
#include <Eigen/Geometry>
#include <celmath/frustum.h>

View File

@ -13,9 +13,6 @@
#include <Eigen/Core>
#include "octree.h"
#ifdef USE_GLCONTEXT
class GLContext;
#endif
class Observer;
class Renderer;
@ -26,9 +23,6 @@ template <class OBJ, class PREC> class ObjectRenderer : public OctreeProcessor<O
void process(const OBJ& /*unused*/, PREC /*unused*/, float /*unused*/) {};
const Observer* observer { nullptr };
#ifdef USE_GLCONTEXT
GLContext* context { nullptr };
#endif
Renderer* renderer { nullptr };
Eigen::Vector3f viewNormal;

View File

@ -84,9 +84,6 @@ std::ofstream hdrlog;
#include <sstream>
#include <iomanip>
#include <numeric>
#ifdef USE_GLCONTEXT
#include "glcontext.h"
#endif
#ifdef _MSC_VER
#include <malloc.h>
#ifndef alloca
@ -578,17 +575,10 @@ bool Renderer::OrbitPathListEntry::operator<(const Renderer::OrbitPathListEntry&
}
#ifdef USE_GLCONTEXT
bool Renderer::init(GLContext* _context,
#else
bool Renderer::init(
#endif
int winWidth, int winHeight,
DetailOptions& _detailOptions)
{
#ifdef USE_GLCONTEXT
context = _context;
#endif
detailOptions = _detailOptions;
// Initialize static meshes and textures common to all instances of Renderer
@ -4626,9 +4616,7 @@ void Renderer::renderPointStars(const StarDatabase& starDB,
Vector3d obsPos = observer.getPosition().toLy();
PointStarRenderer starRenderer;
#ifdef USE_GLCONTEXT
starRenderer.context = context;
#endif
starRenderer.renderer = this;
starRenderer.starDB = &starDB;
starRenderer.observer = &observer;
@ -4733,9 +4721,6 @@ void Renderer::renderDeepSkyObjects(const Universe& universe,
DSODatabase* dsoDB = universe.getDSOCatalog();
#ifdef USE_GLCONTEXT
dsoRenderer.context = context;
#endif
dsoRenderer.renderer = this;
dsoRenderer.dsoDB = dsoDB;
dsoRenderer.orientationMatrix= observer.getOrientationf().conjugate().toRotationMatrix();

View File

@ -24,9 +24,6 @@
#include <celengine/renderlistentry.h>
#include "vertexobject.h"
#ifdef USE_GLCONTEXT
class GLContext;
#endif
class RendererWatcher;
class FrameTree;
class ReferenceMark;
@ -129,11 +126,7 @@ class Renderer
FisheyeMode = 1
};
#ifdef USE_GLCONTEXT
bool init(GLContext*, int, int, DetailOptions&);
#else
bool init(int, int, DetailOptions&);
#endif
void shutdown() {};
void resize(int, int);
float getAspectRatio() const;
@ -362,10 +355,6 @@ class Renderer
float getBrightness();
#endif
#ifdef USE_GLCONTEXT
GLContext* getGLContext() { return context; }
#endif
void setStarStyle(StarStyle);
StarStyle getStarStyle() const;
void setResolution(unsigned int resolution);
@ -777,9 +766,6 @@ class Renderer
#endif
private:
#ifdef USE_GLCONTEXT
GLContext* context;
#endif
ShaderManager* shaderManager{ nullptr };
int windowWidth;

View File

@ -1214,28 +1214,6 @@ void CelestiaCore::charEntered(const char *c_p, int modifiers)
notifyWatchers(RenderFlagsChanged);
break;
case '\026': // Ctrl+V
#ifdef USE_GLCONTEXT
{
GLContext* context = renderer->getGLContext();
GLContext::GLRenderPath path = context->getRenderPath();
GLContext::GLRenderPath newPath = context->nextRenderPath();
if (newPath != path)
{
switch (newPath)
{
case GLContext::GLPath_GLSL:
flash(_("Render path: OpenGL 2.1"));
break;
}
context->setRenderPath(newPath);
notifyWatchers(RenderFlagsChanged);
}
}
#endif
break;
case '\027': // Ctrl+W
wireframe = !wireframe;
renderer->setRenderMode(wireframe ? RenderMode::Line : RenderMode::Fill);
@ -4072,15 +4050,6 @@ bool CelestiaCore::initRenderer()
Renderer::ShowAtmospheres |
Renderer::ShowAutoMag);
#ifdef USE_GLCONTEXT
GLContext* context = new GLContext();
context->init(config->ignoreGLExtensions);
// Choose the render path, starting with the least desirable
context->setRenderPath(GLContext::GLPath_GLSL);
//GetLogger()->verbose("render path: {}\n", context->getRenderPath());
#endif
Renderer::DetailOptions detailOptions;
detailOptions.orbitPathSamplePoints = config->orbitPathSamplePoints;
detailOptions.shadowTextureSize = config->shadowTextureSize;
@ -4090,11 +4059,7 @@ bool CelestiaCore::initRenderer()
detailOptions.linearFadeFraction = config->linearFadeFraction;
// Prepare the scene for rendering.
#ifdef USE_GLCONTEXT
if (!renderer->init(context, (int) width, (int) height, detailOptions))
#else
if (!renderer->init((int) width, (int) height, detailOptions))
#endif
{
fatalError(_("Failed to initialize renderer"), false);
return false;

View File

@ -518,9 +518,6 @@ void CelestiaAppWindow::writeSettings()
settings.setValue("LabelMode", renderer->getLabelMode());
settings.setValue("AmbientLightLevel", renderer->getAmbientLightLevel());
settings.setValue("StarStyle", renderer->getStarStyle());
#ifdef USE_GLCONTEXT
settings.setValue("RenderPath", (int) renderer->getGLContext()->getRenderPath());
#endif
settings.setValue("TextureResolution", renderer->getResolution());
ColorTableType colorsst;
const ColorTemperatureTable* current = renderer->getStarColorTable();

View File

@ -35,9 +35,6 @@
#include "celutil/gettext.h"
#include "celestia/celestiacore.h"
#include "celengine/simulation.h"
#ifdef USE_GLCONTEXT
#include "celengine/glcontext.h"
#endif
#include "qtglwidget.h"
@ -90,26 +87,6 @@ void CelestiaGlWidget::paintGL()
}
#ifdef USE_GLCONTEXT
static GLContext::GLRenderPath getBestAvailableRenderPath(const GLContext& /*glc*/)
{
#if 0
const GLContext::GLRenderPath renderPaths[] = {
GLContext::GLPath_GLSL,
};
for (auto renderPath : renderPaths)
{
if (glc.renderPathSupported(renderPath))
return renderPath;
}
#endif
return GLContext::GLPath_GLSL;
}
#endif
/*!
Set up the OpenGL rendering state, and define display list
*/
@ -149,22 +126,6 @@ void CelestiaGlWidget::initializeGL()
appCore->getSimulation()->setFaintestVisible((float) settings.value("Preferences/VisualMagnitude", DEFAULT_VISUAL_MAGNITUDE).toDouble());
// Read the saved render path
#ifdef USE_GLCONTEXT
GLContext::GLRenderPath bestPath = getBestAvailableRenderPath(*appRenderer->getGLContext());
GLContext::GLRenderPath savedPath = (GLContext::GLRenderPath) settings.value("RenderPath", bestPath).toInt();
// Use the saved path only if it's supported (otherwise a graphics card
// downgrade could cause Celestia to not function.)
GLContext::GLRenderPath usePath;
if (appRenderer->getGLContext()->renderPathSupported(savedPath))
usePath = savedPath;
else
usePath = bestPath;
appRenderer->getGLContext()->setRenderPath(usePath);
#endif
appRenderer->setSolarSystemMaxDistance(appCore->getConfig()->SolarSystemMaxDistance);
appRenderer->setShadowMapSize(appCore->getConfig()->ShadowMapSize);
}

View File

@ -28,9 +28,6 @@
#include "qtappwin.h"
#include "qtpreferencesdialog.h"
#include <celengine/render.h>
#ifdef USE_GLCONTEXT
#include <celengine/glcontext.h>
#endif
#include <celestia/celestiacore.h>
#include <celutil/gettext.h>
@ -70,10 +67,6 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, CelestiaCore* core) :
// Get flags
Renderer* renderer = appCore->getRenderer();
Observer* observer = appCore->getSimulation()->getActiveObserver();
#ifdef USE_GLCONTEXT
GLContext* glContext = appCore->getRenderer()->getGLContext();
GLContext::GLRenderPath renderPath = glContext->getRenderPath();
#endif
uint64_t renderFlags = renderer->getRenderFlags();
int orbitMask = renderer->getOrbitMask();
@ -169,14 +162,7 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, CelestiaCore* core) :
ui.featureSizeSlider->setValue(minimumFeatureSize);
ui.featureSizeEdit->setText(QString::number(minimumFeatureSize));
#ifdef USE_GLCONTEXT
if (glContext->renderPathSupported(GLContext::GLPath_GLSL))
ui.renderPathBox->addItem(_("OpenGL 2.1"), GLContext::GLPath_GLSL);
SetComboBoxValue(ui.renderPathBox, renderPath);
#else
ui.renderPathBox->addItem(_("OpenGL 2.1"), 0);
#endif
ui.antialiasLinesCheck->setChecked(renderFlags & Renderer::ShowSmoothLines);
ui.tintedIlluminationCheck->setChecked(renderFlags & Renderer::ShowTintedIllumination);
@ -706,19 +692,9 @@ void PreferencesDialog::on_featureSizeEdit_textEdited(const QString& text)
}
#ifdef USE_GLCONTEXT
void PreferencesDialog::on_renderPathBox_currentIndexChanged(int index)
{
GLContext* glContext = appCore->getRenderer()->getGLContext();
QVariant itemData = ui.renderPathBox->itemData(index, Qt::UserRole);
GLContext::GLRenderPath renderPath = (GLContext::GLRenderPath) itemData.toInt();
glContext->setRenderPath(renderPath);
}
#else
void PreferencesDialog::on_renderPathBox_currentIndexChanged(int /*index*/)
{
}
#endif
void PreferencesDialog::on_antialiasLinesCheck_stateChanged(int state)

View File

@ -196,9 +196,6 @@ struct AppPreferences
string altSurfaceName;
uint32_t textureResolution;
Renderer::StarStyle starStyle;
#ifdef USE_GLCONTEXT
GLContext::GLRenderPath renderPath;
#endif
bool renderPathSet;
};
@ -2486,10 +2483,6 @@ static bool LoadPreferencesFromRegistry(LPCTSTR regkey, AppPreferences& prefs)
GetRegistryValue(key, "StarsColor", &prefs.starsColor, sizeof(prefs.starsColor));
prefs.starStyle = Renderer::FuzzyPointStars;
GetRegistryValue(key, "StarStyle", &prefs.starStyle, sizeof(prefs.starStyle));
#ifdef USE_GLCONTEXT
prefs.renderPath = GLContext::GLPath_GLSL;
prefs.renderPathSet = GetRegistryValue(key, "RenderPath", &prefs.renderPath, sizeof(prefs.renderPath));
#endif
GetRegistryValue(key, "LastVersion", &prefs.lastVersion, sizeof(prefs.lastVersion));
GetRegistryValue(key, "TextureResolution", &prefs.textureResolution, sizeof(prefs.textureResolution));
@ -2551,9 +2544,6 @@ static bool SavePreferencesToRegistry(LPCTSTR regkey, AppPreferences& prefs)
SetRegistryInt(key, "LastVersion", prefs.lastVersion);
SetRegistryInt(key, "StarStyle", prefs.starStyle);
SetRegistryInt(key, "StarsColor", prefs.starsColor);
#ifdef USE_GLCONTEXT
SetRegistryInt(key, "RenderPath", prefs.renderPath);
#endif
SetRegistry(key, "AltSurface", prefs.altSurfaceName);
SetRegistryInt(key, "TextureResolution", prefs.textureResolution);
SetRegistryInt(key, "IgnoreOldFavorites", ignoreOldFavorites);
@ -2596,9 +2586,6 @@ static bool GetCurrentPreferences(AppPreferences& prefs)
prefs.starsColor = ColorTable_Enhanced;
if (current == GetStarColorTable(ColorTable_Blackbody_D65))
prefs.starsColor = ColorTable_Blackbody_D65;
#ifdef USE_GLCONTEXT
prefs.renderPath = appCore->getRenderer()->getGLContext()->getRenderPath();
#endif
prefs.textureResolution = appCore->getRenderer()->getResolution();
return true;
@ -3429,14 +3416,6 @@ int APIENTRY WinMain(HINSTANCE hInstance,
appCore->setDateFormat((astro::Date::Format) prefs.dateFormat);
appCore->getSimulation()->getActiveObserver()->setDisplayedSurface(prefs.altSurfaceName);
appCore->getRenderer()->setResolution(prefs.textureResolution);
#ifdef USE_GLCONTEXT
if (prefs.renderPathSet)
{
GLContext* glContext = appCore->getRenderer()->getGLContext();
if (glContext->renderPathSupported(prefs.renderPath))
glContext->setRenderPath(prefs.renderPath);
}
#endif
}
else
{

View File

@ -19,9 +19,6 @@
#include <celengine/astro.h>
#include <celengine/parser.h>
#include <celutil/tokenizer.h>
#ifdef USE_GLCONTEXT
#include <celengine/glcontext.h>
#endif
#include "cmdparser.h"
using namespace std;
@ -688,20 +685,7 @@ Command* CommandParser::parseCommand()
}
else if (commandName == "renderpath")
{
#if 0
GLContext::GLRenderPath glcpath = GLContext::GLPath_GLSL;
string path;
paramList->getString("path", path);
if (compareIgnoringCase(path, "glsl") == 0)
glcpath = GLContext::GLPath_GLSL;
cmd = new CommandRenderPath(glcpath);
#else
#ifdef USE_GLCONTEXT
cmd = new CommandRenderPath(GLContext::GLPath_GLSL);
#endif
#endif
// ignore: renderpath not supported
}
else if (commandName == "splitview")
{

View File

@ -11,9 +11,6 @@
#include <celengine/astro.h>
#include <celengine/asterism.h>
#include "execution.h"
#ifdef USE_GLCONTEXT
#include <celengine/glcontext.h>
#endif
#include <celestia/celestiacore.h>
#include <celengine/multitexture.h>
#include <celutil/filetype.h>
@ -694,30 +691,6 @@ void CommandSetTextureResolution::process(ExecutionEnvironment& env)
}
////////////////
// Set RenderPath command. Left for compatibility.
#ifdef USE_GLCONTEXT
CommandRenderPath::CommandRenderPath(GLContext::GLRenderPath _path) :
path(_path)
{
}
void CommandRenderPath::process(ExecutionEnvironment& /*env*/)
{
#if 0
GLContext* context = env.getRenderer()->getGLContext();
if (context != nullptr)
{
context->setRenderPath(path);
env.getCelestiaCore()->notifyWatchers(CelestiaCore::RenderFlagsChanged);
}
#endif
}
#endif
////////////////
// SplitView command

View File

@ -571,19 +571,6 @@ class CommandSetTextureResolution : public InstantaneousCommand
};
#ifdef USE_GLCONTEXT
class CommandRenderPath : public InstantaneousCommand
{
public:
CommandRenderPath(GLContext::GLRenderPath);
void process(ExecutionEnvironment&) override;
private:
GLContext::GLRenderPath path;
};
#endif
class CommandSplitView : public InstantaneousCommand
{
public: