MCPcopy Create free account
hub / github.com/LukasBanana/LLGL / ParseWindowSize

Function ParseWindowSize

examples/Cpp/ExampleBase/ExampleBase.cpp:196–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196static bool ParseWindowSize(LLGL::Extent2D& size, int argc, char* argv[])
197{
198 const LLGL::StringView resArg = "-res=";
199 for_subrange(i, 1, argc)
200 {
201 const LLGL::StringView arg = argv[i];
202 if (arg.compare(0, resArg.size(), resArg) == 0)
203 {
204 if (arg.size() < resArg.size() + 3)
205 return false;
206
207 char* tok = ::strtok(argv[i] + resArg.size(), "x");
208 int values[2] = {};
209 for (int tokIndex = 0; tok != nullptr && tokIndex < 2; ++tokIndex)
210 {
211 values[tokIndex] = ::atoi(tok);
212 tok = ::strtok(nullptr, "x");
213 }
214
215 size.width = static_cast<std::uint32_t>(std::max(1, std::min(values[0], 16384)));
216 size.height = static_cast<std::uint32_t>(std::max(1, std::min(values[1], 16384)));
217
218 return true;
219 }
220 }
221 return false;
222}
223
224static bool ParseSamples(std::uint32_t& samples, int argc, char* argv[])
225{

Callers 1

ParseProgramArgsMethod · 0.85

Calls 3

compareMethod · 0.80
for_subrangeFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected