Skip to content

Commit 8062be7

Browse files
committed
Pass model path from command line argument
1 parent 885de8a commit 8062be7

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

.vscode/launch.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"type": "cppdbg",
1010
"request": "launch",
1111
"program": "${workspaceFolder}/build/pt",
12-
"args": [],
12+
"args": [
13+
"../assets/Duck.glb"
14+
],
1315
"stopAtEntry": false,
1416
"cwd": "${workspaceFolder}/build",
1517
"environment": [],
@@ -33,7 +35,9 @@
3335
"type": "cppvsdbg",
3436
"request": "launch",
3537
"program": "${workspaceFolder}/build/Debug/pt.exe",
36-
"args": [],
38+
"args": [
39+
"../../assets/Duck.glb"
40+
],
3741
"stopAtEntry": false,
3842
"cwd": "${workspaceFolder}/build/Debug",
3943
"environment": [],

src/bvh-visualizer/main.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ using namespace nlrs;
1414

1515
inline constexpr Extent2i imageSize = Extent2i{1280, 720};
1616

17-
int main()
17+
void printHelp() { std::cout << "Usage: bvh-visualizer <input_gltf_file>\n" << std::endl; }
18+
19+
int main(int argc, char** argv)
1820
{
19-
const nlrs::GltfModel model("Duck.glb");
21+
if (argc != 2)
22+
{
23+
printHelp();
24+
return 0;
25+
}
26+
27+
const nlrs::GltfModel model(argv[1]);
2028
const nlrs::Bvh bvh = nlrs::buildBvh(
2129
model.positions(), model.normals(), model.texCoords(), model.baseColorTextureIndices());
2230

src/pt/main.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,23 @@
1818
inline constexpr int defaultWindowWidth = 640;
1919
inline constexpr int defaultWindowHeight = 480;
2020

21-
int main()
21+
void printHelp() { std::printf("Usage: pt <input_gltf_file>\n"); }
22+
23+
int main(int argc, char** argv)
2224
{
25+
if (argc != 2)
26+
{
27+
printHelp();
28+
return 0;
29+
}
30+
2331
nlrs::Window window{nlrs::WindowDescriptor{
2432
.windowSize = nlrs::Extent2i{defaultWindowWidth, defaultWindowHeight},
2533
.title = "pt-playground 🛝",
2634
}};
2735

2836
{
29-
const nlrs::GltfModel model("Duck.glb");
37+
const nlrs::GltfModel model(argv[1]);
3038
const nlrs::Bvh bvh = nlrs::buildBvh(
3139
model.positions(), model.normals(), model.texCoords(), model.baseColorTextureIndices());
3240

src/textractor/main.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22
#include <common/texture.hpp>
33

44
#include <cassert>
5+
#include <cstdio>
56
#include <fstream>
67

7-
int main()
8+
void printHelp() { std::printf("Usage: textractor <input_gltf_file>\n"); }
9+
10+
int main(int argc, char** argv)
811
{
9-
const nlrs::GltfModel model("Duck.glb");
12+
if (argc != 2)
13+
{
14+
printHelp();
15+
return 0;
16+
}
17+
18+
nlrs::GltfModel model(argv[1]);
1019

1120
const auto baseColorTextures = model.baseColorTextures();
1221
for (std::size_t textureIdx = 0; textureIdx < baseColorTextures.size(); ++textureIdx)

0 commit comments

Comments
 (0)