Add support for checking of OpenGL extensions to provide better error messages

This commit is contained in:
Alexander Bock
2018-06-26 11:51:21 -04:00
parent fd28576425
commit f4d67893b4
4 changed files with 55 additions and 4 deletions

View File

@@ -56,8 +56,9 @@ public:
* Registers all of the OpenSpaceModule%s which are created by the CMake configuration
* and stored in the <code>moduleregistration.h</code> file. For all of those modules
* the OpenSpaceModule::initialize method with will called.
*
* \throw ghoul::RuntimeError If two modules in the default modules have the same
* name
* name
*/
void initialize(const std::map<std::string, ghoul::Dictionary>& moduleConfigurations);
@@ -80,9 +81,11 @@ public:
/**
* Registers the passed \p module with this ModuleEngine. The OpenSpaceModule::create
* method will be called on the \p module in the process.
*
* \param module The OpenSpaceModule that is to be registered
*
* \throw ghoul::RuntimeError If the name of the \p module was already registered
* previously
* previously
* \pre \p module must not be nullptr
*/
void registerModule(std::unique_ptr<OpenSpaceModule> module,
@@ -91,6 +94,7 @@ public:
/**
* Returns a list of all registered OpenSpaceModule%s that have been registered with
* this ModuleEngine. All returned OpenSpaceModule%s are guaranteed to be initialized.
*
* \return A list of all registered OpenSpaceModule%s
*/
std::vector<OpenSpaceModule*> modules() const;
@@ -99,6 +103,7 @@ public:
* Get the module subclass with given template argument. Requires the module subclass
* to have the public static member variable <code>name</code> which must be equal to
* the name of the module used in its constructor.
*
* \return a pointer to the module of the given subclass
*/
template <class ModuleSubClass>
@@ -107,6 +112,7 @@ public:
/**
* Returns the combined minimum OpenGL version. The return value is the maximum
* version of all registered modules' OpenGL versions.
*
* \return The combined minimum OpenGL version
*/
ghoul::systemcapabilities::Version requiredOpenGLVersion() const;

View File

@@ -50,7 +50,9 @@ public:
/**
* Constructs the OpenSpaceModule with a specific \p name. The uniqueness of the
* \p name will be checked at a later stage.
*
* \param name The name of this OpenSpace module
*
* \pre \p name must not be empty
*/
OpenSpaceModule(std::string name);
@@ -86,6 +88,7 @@ public:
/**
* Returns a list of Documentation classes that are valid for this OpenSpaceModule.
*
* \return A list of Documentation classes that are valid for this OpenSapceModule
*/
virtual std::vector<documentation::Documentation> documentations() const;
@@ -93,6 +96,7 @@ public:
/**
* Returns the Lua library with functions defined by this OpenSpaceModule. The default
* implementation returns an empty library.
*
* \return The Lua library with functions defined by this OpenSpaceModule
*/
virtual scripting::LuaLibrary luaLibrary() const;
@@ -102,6 +106,7 @@ public:
* OpenSpaceModule. Note that the #luaLibrary library is *not* contained in this list
* as this is solely the list of libraries as defined by, for example Renderables,
* defined in the OpenSpaceModule.
*
* \return A list of libraries defined by items contained in this OpenSpaceModule
*/
virtual std::vector<scripting::LuaLibrary> luaLibraries() const;
@@ -109,16 +114,27 @@ public:
/**
* Returns the minimum required OpenGL version of this OpenSpaceModule. Unless
* overwritten, it returns an OpenGL version of <code>3.3</code>.
*
* \return The minimum required OpenGL version of this OpenSpaceModule
*/
virtual ghoul::systemcapabilities::Version requiredOpenGLVersion() const;
/**
* Returns the list of required OpenGL extensions for this OpenSpaceModule. Unless
* overwritten, this function returns an empty list.
*
* \return The list of required OpenGL extensions necessary to use this
* OpenSpaceModule
*/
virtual std::vector<std::string> requiredOpenGLExtensions() const;
protected:
/**
* Customization point for each derived class. The internalInitialize method is called
* by the initialize method.
*
* \param configuration The configuration options that were read from the
* configuration file
* configuration file
*/
virtual void internalInitialize(const ghoul::Dictionary& configuration);

View File

@@ -530,11 +530,36 @@ void OpenSpaceEngine::initialize() {
if (OpenGLCap.openGLVersion() < version) {
throw ghoul::RuntimeError(
"Module required higher OpenGL version than is supported",
"An invluded module required a higher OpenGL version than is supported on "
"this syystem",
"OpenSpaceEngine"
);
}
{
// Check the available OpenGL extensions against the required extensions
using OCC = ghoul::systemcapabilities::OpenGLCapabilitiesComponent;
OCC& c = SysCap.component<OCC>();
bool hasDepthBuffer = c.isExtensionSupported("GL_NV_depth_buffer_float") ||
c.isExtensionSupported("GL_ARB_depth_buffer_float");
if (!hasDepthBuffer) {
LFATAL("OpenSpace requires support of either the 'GL_NV_depth_buffer_float' "
"or 'GL_ARB_depth_buffer_float' OpenGL extensions, which are not "
"available on this system. There is likely to be a crash incoming");
}
for (OpenSpaceModule* m : _engine->_moduleEngine->modules()) {
for (const std::string& ext : m->requiredOpenGLExtensions()) {
if (!SysCap.component<OCC>().isExtensionSupported(ext)) {
LFATAL(fmt::format(
"Module {} required OpenGL extension {} which is not available "
"on this system. Some functionality related to this module will "
"probably not work.", m->guiName(), ext
));
}
}
}
}
// Register Lua script functions
LDEBUG("Registering Lua libraries");
registerCoreClasses(*_scriptEngine);

View File

@@ -99,6 +99,10 @@ ghoul::systemcapabilities::Version OpenSpaceModule::requiredOpenGLVersion() cons
return { 3, 3, 0 };
}
std::vector<std::string> OpenSpaceModule::requiredOpenGLExtensions() const {
return {};
}
std::string OpenSpaceModule::modulePath() const {
std::string moduleIdentifier = identifier();
std::transform(