Skip to content

Commit

Permalink
[viewer] The opglv files does not require to set a root directory any…
Browse files Browse the repository at this point in the history
…more all file path can now be relative to the .opglv file that is loaded
  • Loading branch information
sherholz-intel committed Sep 18, 2024
1 parent 2f6087a commit 8b0e9e4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tools/openpgl-viewer/src/data/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include <nlohmann/json.hpp>
using json = nlohmann::json;

std::string get_path(std::string filename)
{
return filename.substr(0, filename.find_last_of("/\\"));
}

void Data::init()
{
m_device = new openpgl::cpp::Device(PGL_DEVICE_TYPE_CPU_4);
Expand All @@ -16,7 +21,12 @@ void Data::load(std::string filename)
{
std::ifstream f(filename);
json data = json::parse(f);
std::string rootDir = data["root"];
std::string rootDir = "";
if(data.contains("root"))
rootDir = data["root"];
else {
rootDir = get_path(filename);
}
std::string cameraFile = data["camera"];
std::string fieldFile = data["field"];
std::string samplesFile = data["samples"];
Expand Down

0 comments on commit 8b0e9e4

Please sign in to comment.