Commit 9b18b386 authored by Jan Möbius's avatar Jan Möbius

Be smarter when choosing renderers on startup.

Make sure wew switch to shader Pipeline when in CoreProfile.

closes #164
parent 54f7dbbe
......@@ -566,23 +566,37 @@ Core::init() {
// Set renderer
// ====================================================
QString defaultRendererKey = "Viewer" + QString::number(i)+"/DefaultRenderer";
QString defaultRendererName = OpenFlipperSettings().value(defaultRendererKey,"Default Classical Renderer Plugin").toString();
// Check if the renderer is there
int defaultRendererId = renderManager().getRendererId(defaultRendererName);
// Choose one of the two possible renderers. Shader Pipeline for Core Profile or Classical for Compatibility Profile
QString rendererDefault;
if ( defaultRendererId == -1 ) {
emit log(LOGERR,tr("Stored default renderer \"") + defaultRendererName + tr("\" is not available, trying Classical!"));
if ( OpenFlipper::Options::coreProfile() )
rendererDefault = "Shader Pipeline Renderer Plugin";
else
rendererDefault = "Default Classical Renderer Plugin";
// Check if the renderer is there
defaultRendererId = renderManager().getRendererId("Default Classical Renderer Plugin");
// Try to get a default renderer Name from the settings file. If it's not there, we fall back to the default set above
// based on the current OpenGL Profile
QString rendererKey = "Viewer" + QString::number(i)+"/DefaultRenderer";
QString rendererName = OpenFlipperSettings().value(rendererKey,rendererDefault).toString();
// Classical available?
if ( defaultRendererId != -1 ) {
renderManager().setActive(defaultRendererId,i);
// Check if the renderer is there. If a setting was in the options file, we try it here. Otherwise we are checking the default one.
int rendererId = renderManager().getRendererId(rendererName);
if ( rendererId == -1 ) {
// That failed. So either the one stored in the settings is not available or our default failed.
emit log(LOGERR,tr("Stored default renderer \"") + rendererName + tr("\" is not available, trying") + rendererDefault + "!");
// Anyway, lets try the default fallback:
rendererId = renderManager().getRendererId(rendererDefault);
// Successful?
if ( rendererId != -1 ) {
// Lets set it as the active one
renderManager().setActive(rendererId,i);
} else {
emit log(LOGERR,tr("Default classical renderer is also not available. Trying to use any other renderer i can find!"));
emit log(LOGERR,rendererDefault + tr(" renderer is also not available. Trying to use any other renderer i can find!"));
// debug information for this case, print renderer count and their names
const unsigned int rendererCount = renderManager().available();
......@@ -590,11 +604,11 @@ Core::init() {
for (unsigned int rendererId = 0 ; rendererId < rendererCount ; ++rendererId )
emit log(LOGERR, tr("Renderer ") + QString::number(rendererId) + ": " + renderManager()[rendererId]->name );
}
} else {
renderManager().setActive(defaultRendererId,i);
renderManager().setActive(rendererId,i);
}
}
// Warn the user in the log and via messagebox, that he is using the build in renderer only
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment