mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-04 10:25:29 +00:00
Move GLSL version check to ProjectM class constructor
Log a fatal error if it fails.
This commit is contained in:
@ -13,17 +13,6 @@ namespace MilkdropPreset {
|
||||
MilkdropStaticShaders::MilkdropStaticShaders(bool useGLES)
|
||||
: m_useGLES(useGLES)
|
||||
{
|
||||
m_GLSLVersion = Renderer::Shader::GetShaderLanguageVersion();
|
||||
|
||||
if (m_GLSLVersion.major == 0)
|
||||
{
|
||||
throw std::runtime_error("Could not retrieve OpenGL shader language version. Is OpenGL available and the context initialized?");
|
||||
}
|
||||
if (m_GLSLVersion.major < 3)
|
||||
{
|
||||
throw std::runtime_error("OpenGL shader language version 3 or higher is required, but not available in the current context.");
|
||||
}
|
||||
|
||||
if (m_useGLES)
|
||||
{
|
||||
// If GLES is enabled, use the embedded specification language variant.
|
||||
|
||||
@ -64,7 +64,6 @@ private:
|
||||
std::string AddVersionHeader(std::string shader_text);
|
||||
|
||||
bool m_useGLES{false}; //!< Whether or not to use GLES shaders.
|
||||
Renderer::Shader::GlslVersion m_GLSLVersion{}; //!< The queried GLSL version.
|
||||
std::string m_versionHeader; //!< The version header to prepended by AddVersionHeader.
|
||||
M4::GLSLGenerator::Version m_GLSLGeneratorVersion; //!< The GLSL generator version to pass to the hlslparser generator.
|
||||
};
|
||||
|
||||
@ -192,16 +192,14 @@ void ProjectM::RenderFrame(uint32_t targetFramebufferObject /*= 0*/)
|
||||
|
||||
void ProjectM::Initialize()
|
||||
{
|
||||
/** Initialise start time */
|
||||
// Check OpenGL first before allocating any additional memory.
|
||||
CheckGLSLVersion();
|
||||
|
||||
m_timeKeeper = std::make_unique<TimeKeeper>(m_presetDuration,
|
||||
m_softCutDuration,
|
||||
m_hardCutDuration,
|
||||
m_easterEgg);
|
||||
|
||||
/** Nullify frame stash */
|
||||
|
||||
/** Initialise per-pixel matrix calculations */
|
||||
/** We need to initialise this before the builtin param db otherwise bass/mid etc won't bind correctly */
|
||||
m_textureManager = std::make_unique<Renderer::TextureManager>(m_textureSearchPaths);
|
||||
m_shaderCache = std::make_unique<Renderer::ShaderCache>();
|
||||
|
||||
@ -213,14 +211,38 @@ void ProjectM::Initialize()
|
||||
|
||||
m_presetFactoryManager->initialize();
|
||||
|
||||
/* Set the seed to the current time in seconds */
|
||||
srand(time(nullptr));
|
||||
|
||||
LoadIdlePreset();
|
||||
|
||||
m_timeKeeper->StartPreset();
|
||||
}
|
||||
|
||||
void ProjectM::CheckGLSLVersion()
|
||||
{
|
||||
auto glslVersion = Renderer::Shader::GetShaderLanguageVersion();
|
||||
|
||||
if (glslVersion.major == 0)
|
||||
{
|
||||
std::string error = "Could not retrieve OpenGL shader language version. Is OpenGL available and the context initialized?";
|
||||
LOG_FATAL(error);
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
#ifdef USE_GLES
|
||||
if (glslVersion.major < 3)
|
||||
{
|
||||
std::string error = "OpenGL ES shading language version 3.00 or higher is required, but the current context only provides version " + std::to_string(glslVersion.major) + "." + std::to_string(glslVersion.minor) + ".";
|
||||
LOG_FATAL(error);
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
#else
|
||||
if (glslVersion.major < 3 || (glslVersion.major == 3 && glslVersion.minor < 30))
|
||||
{
|
||||
std::string error = "OpenGL shading language version 3.30 or higher is required, but the current context only provides version " + std::to_string(glslVersion.major) + "." + std::to_string(glslVersion.minor) + ".";
|
||||
LOG_FATAL(error);
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProjectM::LoadIdlePreset()
|
||||
{
|
||||
LoadPresetFile("idle://Geiss & Sperl - Feedback (projectM idle HDR mix).milk", false);
|
||||
|
||||
@ -259,6 +259,8 @@ public:
|
||||
private:
|
||||
void Initialize();
|
||||
|
||||
void CheckGLSLVersion();
|
||||
|
||||
void StartPresetTransition(std::unique_ptr<Preset>&& preset, bool hardCut);
|
||||
|
||||
void LoadIdlePreset();
|
||||
|
||||
Reference in New Issue
Block a user