Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL rendering command line flag #810

Merged
merged 2 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Engine/CLArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ CLArgs::printUsage(const std::string& programName)
" the settings and prior to executing Python commands or loading the project.\n"
" For choice settings, the value may be an integer index for the option, or\n"
" a quoted string, as in: --setting enableOpenGLRendering=\\\"enabled\\\"\n"
" --opengl <choice>\n"
" Select whether to activate OpenGL rendering or not. If disabled, even\n"
" though a Project enable GPU rendering, it will not be activated.\n"
" Choice can be one of \"enabled\" (enables OpenGL rendering if available)\n"
" \"disabled\" and \"foreground\" (uses OpenGL only\n"
" if not using %1Renderer and rendering is running in the foreground)\"\n"
" -c [ --cmd ] \"PythonCommand\"\n"
" Execute custom Python code passed as a script prior to executing the Python\n"
" script or loading the project passed as parameter. This option may be used\n"
Expand Down Expand Up @@ -1004,6 +1010,33 @@ CLArgsPrivate::parse()
}
}
}

{
QStringList::iterator it = hasToken( QString::fromUtf8("opengl"), QString() );
if ( it != args.end() ) {
it = args.erase(it);

if ( it == args.end() || it->startsWith( QChar::fromLatin1('-') ) ) {
std::cout << tr("You must specify a choice when using the --opengl option").toStdString() << std::endl;
error = 1;

return;
}

QString choice = *it;
it = args.erase(it);

if (choice != QString::fromUtf8("enabled") && choice != QString::fromUtf8("disabled") && choice != QString::fromUtf8("foreground")) {
std::cout << tr("Valid options for --opengl are enabled, disabled and foreground").toStdString() << std::endl;
error = 1;

return;
}

settingCommands.push_back( "NatronEngine.natron.getSettings().getParam(\"enableOpenGLRendering\").setValue(\"" + choice.toStdString() + "\")");
}
}

//Parse settings
for (;;) {
QStringList::iterator it = hasToken( QString::fromUtf8("setting"), QString() );
Expand Down
4 changes: 4 additions & 0 deletions Engine/EffectInstanceRenderRoI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,10 @@ EffectInstance::renderRoI(const RenderRoIArgs & args,
}
}
}
} else if ( appPTR->isOpenGLLoaded() && !appPTR->getCurrentSettings()->isOpenGLRenderingEnabled() && openGLSupport == ePluginOpenGLRenderSupportNeeded ) {
QString message = tr("OpenGL render is required for a plugin but it's currently disabled, please consider passing `--opengl enabled` to %1").arg(QString::fromUtf8(NATRON_APPLICATION_NAME));
setPersistentMessage(eMessageTypeError, message.toStdString());
return eRenderRoIRetCodeFailed;
}


Expand Down