Skip to content

Commit 992b720

Browse files
committed
Added support for reading --rh resource.vsgt and passing ResourceHints to viewer.compile(..)
1 parent 6e1dedd commit 992b720

File tree

3 files changed

+47
-28
lines changed

3 files changed

+47
-28
lines changed

examples/app/vsgcameras/vsgcameras.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ int main(int argc, char** argv)
104104
// set up defaults and read command line arguments to override them
105105
vsg::CommandLine arguments(&argc, argv);
106106

107+
108+
auto options = vsg::Options::create();
109+
options->fileCache = vsg::getEnv("VSG_FILE_CACHE");
110+
options->paths = vsg::getEnvPaths("VSG_FILE_PATH");
111+
#ifdef vsgXchange_all
112+
// add vsgXchange's support for reading and writing 3rd party file formats
113+
options->add(vsgXchange::all::create());
114+
#endif
115+
107116
auto windowTraits = vsg::WindowTraits::create();
108117
windowTraits->windowTitle = "vsgcameras - Multiple Views with different ways of configuring/tracking Cameras";
109118
windowTraits->debugLayer = arguments.read({"--debug", "-d"});
@@ -146,15 +155,13 @@ int main(int argc, char** argv)
146155
reportAverageFrameRate = true;
147156
}
148157

149-
if (arguments.errors()) return arguments.writeErrorMessages(std::cerr);
158+
vsg::ref_ptr<vsg::ResourceHints> resourceHints;
159+
if (auto resourceHintsFilename = arguments.value<vsg::Path>("", "--rh"))
160+
{
161+
resourceHints = vsg::read_cast<vsg::ResourceHints>(resourceHintsFilename, options);
162+
}
150163

151-
auto options = vsg::Options::create();
152-
options->fileCache = vsg::getEnv("VSG_FILE_CACHE");
153-
options->paths = vsg::getEnvPaths("VSG_FILE_PATH");
154-
#ifdef vsgXchange_all
155-
// add vsgXchange's support for reading and writing 3rd party file formats
156-
options->add(vsgXchange::all::create());
157-
#endif
164+
if (arguments.errors()) return arguments.writeErrorMessages(std::cerr);
158165

159166
vsg::Path filename = (argc > 1) ? arguments[1] : vsg::Path("models/lz.vsgt");
160167
auto scenegraph = vsg::read_cast<vsg::Node>(filename, options);
@@ -307,7 +314,7 @@ int main(int argc, char** argv)
307314

308315
if (instrumentation) viewer->assignInstrumentation(instrumentation);
309316

310-
viewer->compile();
317+
viewer->compile(resourceHints);
311318

312319
// rendering main loop
313320
while (viewer->advanceToNextFrame())

examples/app/vsgmultiviews/vsgmultiviews.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ int main(int argc, char** argv)
7777
// set up defaults and read command line arguments to override them
7878
vsg::CommandLine arguments(&argc, argv);
7979

80+
auto options = vsg::Options::create();
81+
options->fileCache = vsg::getEnv("VSG_FILE_CACHE");
82+
options->paths = vsg::getEnvPaths("VSG_FILE_PATH");
83+
#ifdef vsgXchange_all
84+
// add vsgXchange's support for reading and writing 3rd party file formats
85+
options->add(vsgXchange::all::create());
86+
#endif
87+
8088
auto windowTraits = vsg::WindowTraits::create();
8189
windowTraits->windowTitle = "Multiple Views";
8290
windowTraits->debugLayer = arguments.read({"--debug", "-d"});
@@ -119,15 +127,13 @@ int main(int argc, char** argv)
119127
reportAverageFrameRate = true;
120128
}
121129

122-
if (arguments.errors()) return arguments.writeErrorMessages(std::cerr);
130+
vsg::ref_ptr<vsg::ResourceHints> resourceHints;
131+
if (auto resourceHintsFilename = arguments.value<vsg::Path>("", "--rh"))
132+
{
133+
resourceHints = vsg::read_cast<vsg::ResourceHints>(resourceHintsFilename, options);
134+
}
123135

124-
auto options = vsg::Options::create();
125-
options->fileCache = vsg::getEnv("VSG_FILE_CACHE");
126-
options->paths = vsg::getEnvPaths("VSG_FILE_PATH");
127-
#ifdef vsgXchange_all
128-
// add vsgXchange's support for reading and writing 3rd party file formats
129-
options->add(vsgXchange::all::create());
130-
#endif
136+
if (arguments.errors()) return arguments.writeErrorMessages(std::cerr);
131137

132138
vsg::ref_ptr<vsg::Node> scenegraph;
133139
vsg::ref_ptr<vsg::Node> scenegraph2;
@@ -214,7 +220,7 @@ int main(int argc, char** argv)
214220

215221
if (instrumentation) viewer->assignInstrumentation(instrumentation);
216222

217-
viewer->compile();
223+
viewer->compile(resourceHints);
218224

219225
// rendering main loop
220226
while (viewer->advanceToNextFrame())

examples/app/vsgwindows/vsgwindows.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ int main(int argc, char** argv)
3333
// set up defaults and read command line arguments to override them
3434
vsg::CommandLine arguments(&argc, argv);
3535

36+
auto options = vsg::Options::create();
37+
options->fileCache = vsg::getEnv("VSG_FILE_CACHE");
38+
options->paths = vsg::getEnvPaths("VSG_FILE_PATH");
39+
#ifdef vsgXchange_all
40+
// add vsgXchange's support for reading and writing 3rd party file formats
41+
options->add(vsgXchange::all::create());
42+
#endif
43+
44+
options->readOptions(arguments);
3645
auto windowTraits = vsg::WindowTraits::create();
3746
windowTraits->windowTitle = "Multiple Windows - first window";
3847
windowTraits->debugLayer = arguments.read({"--debug", "-d"});
@@ -85,20 +94,17 @@ int main(int argc, char** argv)
8594
reportAverageFrameRate = true;
8695
}
8796

97+
vsg::ref_ptr<vsg::ResourceHints> resourceHints;
98+
if (auto resourceHintsFilename = arguments.value<vsg::Path>("", "--rh"))
99+
{
100+
resourceHints = vsg::read_cast<vsg::ResourceHints>(resourceHintsFilename, options);
101+
}
102+
88103
if (arguments.errors()) return arguments.writeErrorMessages(std::cerr);
89104

90105
bool separateDevices = arguments.read({"--no-shared-window", "-n"});
91106
bool multiThreading = arguments.read("--mt");
92107

93-
auto options = vsg::Options::create();
94-
options->fileCache = vsg::getEnv("VSG_FILE_CACHE");
95-
options->paths = vsg::getEnvPaths("VSG_FILE_PATH");
96-
#ifdef vsgXchange_all
97-
// add vsgXchange's support for reading and writing 3rd party file formats
98-
options->add(vsgXchange::all::create());
99-
#endif
100-
101-
options->readOptions(arguments);
102108

103109
if (separateDevices && VSG_MAX_DEVICES < 2)
104110
{
@@ -200,7 +206,7 @@ int main(int argc, char** argv)
200206

201207
if (instrumentation) viewer->assignInstrumentation(instrumentation);
202208

203-
viewer->compile();
209+
viewer->compile(resourceHints);
204210

205211
// rendering main loop
206212
while (viewer->advanceToNextFrame())

0 commit comments

Comments
 (0)