MCPcopy Create free account
hub / github.com/RenderKit/ospray / initFromCommandLine

Function initFromCommandLine

ospray/common/OSPCommon.cpp:109–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109void initFromCommandLine(int *_ac, const char ***_av)
110{
111 using namespace rkcommon::utility;
112
113 auto &device = ospray::api::Device::current;
114
115 if (_ac && _av) {
116 int &ac = *_ac;
117 auto &av = *_av;
118
119 // If we have any device-params those must be set first to avoid
120 // initializing the device in an invalid or partial state
121 bool hadDeviceParams = false;
122 for (int i = 1; i < ac;) {
123 if (std::strncmp(av[i], "--osp:device-params", 19) == 0) {
124 hadDeviceParams = true;
125 std::string parmesan = getArgString(av[i]);
126 std::vector<std::string> parmList = split(parmesan, ',');
127 for (std::string &p : parmList) {
128 std::vector<std::string> kv = split(p, ':');
129 if (kv.size() != 2) {
130 postStatusMsg(
131 "Invalid parameters provided for --osp:device-params. "
132 "Must be formatted as <param>:<value>[,<param>:<value>,...]");
133 } else {
134 device->setParam(kv[0], kv[1]);
135 }
136 }
137 removeArgs(ac, av, i, 1);
138 } else {
139 ++i;
140 }
141 }
142 if (hadDeviceParams) {
143 device->commit();
144 }
145
146 for (int i = 1; i < ac;) {
147 std::string param = av[i];
148 // flag-style arguments
149 if (param == "--osp:debug") {
150 device->setParam("debug", true);
151 device->setParam("logOutput", std::string("cout"));
152 device->setParam("errorOutput", std::string("cerr"));
153 removeArgs(ac, av, i, 1);
154 } else if (param == "--osp:warn-as-error") {
155 device->setParam("warnAsError", true);
156 removeArgs(ac, av, i, 1);
157 } else if (param == "--osp:verbose") {
158 device->setParam("logLevel", OSP_LOG_INFO);
159 device->setParam("logOutput", std::string("cout"));
160 device->setParam("errorOutput", std::string("cerr"));
161 removeArgs(ac, av, i, 1);
162 } else if (param == "--osp:vv") {
163 device->setParam("logLevel", OSP_LOG_DEBUG);
164 device->setParam("logOutput", std::string("cout"));
165 device->setParam("errorOutput", std::string("cerr"));
166 removeArgs(ac, av, i, 1);

Callers 1

ospInitFunction · 0.85

Calls 6

getArgStringFunction · 0.85
postStatusMsgFunction · 0.85
getArgIntFunction · 0.85
sizeMethod · 0.45
setParamMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected