Skip to content

Commit

Permalink
MaterialXView startup improvements (#1132)
Browse files Browse the repository at this point in the history
- Simplify startup pathing to make install and dev builds behave the same.
- Disable display of window frame (on Windows at least) for offscreen rendering from command line.
  • Loading branch information
kwokcb committed Jan 4, 2023
1 parent fefce08 commit b926669
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions source/MaterialXView/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,13 @@ template<class T> void parseToken(std::string token, std::string type, T& res)
mx::FileSearchPath getDefaultSearchPath()
{
mx::FilePath modulePath = mx::FilePath::getModulePath();
mx::FilePath installRootPath = modulePath.getParentPath();
mx::FilePath devRootPath = installRootPath.getParentPath().getParentPath();
mx::FilePath parentPath = modulePath.getParentPath();

mx::FileSearchPath searchPath;
if ((devRootPath / "libraries").exists())
searchPath.append(modulePath);
if ((parentPath / "libraries").exists())
{
searchPath.append(devRootPath);
}
else
{
searchPath.append(installRootPath);
searchPath.append(parentPath);
}

return searchPath;
Expand Down Expand Up @@ -300,20 +296,22 @@ int main(int argc, char* const argv[])
viewer->setBakeHeight(bakeHeight);
viewer->setBakeFilename(bakeFilename);
viewer->initialize();
if (!bakeFilename.empty())

if (!captureFilename.empty())
{
viewer->bakeTextures();
viewer->requestFrameCapture(captureFilename);
viewer->draw_all();
viewer->requestExit();
}
else
{
viewer->set_visible(true);
}
if (!captureFilename.empty())
else if (!bakeFilename.empty())
{
viewer->requestFrameCapture(captureFilename);
viewer->bakeTextures();
viewer->requestExit();
}
else
{
viewer->set_visible(true);
}
ng::mainloop(refresh);
}
ng::shutdown();
Expand Down

0 comments on commit b926669

Please sign in to comment.