本文整理汇总了C++中ArgParse::command_line方法的典型用法代码示例。如果您正苦于以下问题:C++ ArgParse::command_line方法的具体用法?C++ ArgParse::command_line怎么用?C++ ArgParse::command_line使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgParse
的用法示例。
在下文中一共展示了ArgParse::command_line方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: threads
static void
getargs (int argc, char *argv[])
{
bool help = false;
ArgParse ap;
ap.options ("maketx -- convert images to tiled, MIP-mapped textures\n"
OIIO_INTRO_STRING "\n"
"Usage: maketx [options] file...",
"%*", parse_files, "",
"--help", &help, "Print help message",
"-v", &verbose, "Verbose status messages",
"-o %s", &outputfilename, "Output filename",
"-t %d", &nthreads, "Number of threads (default: #cores)",
"-u", &updatemode, "Update mode",
"--format %s", &fileformatname, "Specify output file format (default: guess from extension)",
"--nchannels %d", &nchannels, "Specify the number of output image channels.",
"-d %s", &dataformatname, "Set the output data format to one of: "
"uint8, sint8, uint16, sint16, half, float",
"--tile %d %d", &tile[0], &tile[1], "Specify tile size",
"--separate", &separate, "Use planarconfig separate (default: contiguous)",
// "--ingamma %f", &ingamma, "Specify gamma of input files (default: 1)",
// "--outgamma %f", &outgamma, "Specify gamma of output files (default: 1)",
// "--opaquewidth %f", &opaquewidth, "Set z fudge factor for volume shadows",
"--fov %f", &fov, "Field of view for envcube/shadcube/twofish",
"--fovcot %f", &fovcot, "Override the frame aspect ratio. Default is width/height.",
"--wrap %s", &wrap, "Specify wrap mode (black, clamp, periodic, mirror)",
"--swrap %s", &swrap, "Specific s wrap mode separately",
"--twrap %s", &twrap, "Specific t wrap mode separately",
"--resize", &doresize, "Resize textures to power of 2 (default: no)",
"--noresize", &noresize, "Do not resize textures to power of 2 (deprecated)",
"--filter %s", &filtername, filter_help_string().c_str(),
"--nomipmap", &nomipmap, "Do not make multiple MIP-map levels",
"--checknan", &checknan, "Check for NaN and Inf values (abort if found)",
"--Mcamera %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f",
&Mcam[0][0], &Mcam[0][1], &Mcam[0][2], &Mcam[0][3],
&Mcam[1][0], &Mcam[1][1], &Mcam[1][2], &Mcam[1][3],
&Mcam[2][0], &Mcam[2][1], &Mcam[2][2], &Mcam[2][3],
&Mcam[3][0], &Mcam[3][1], &Mcam[3][2], &Mcam[3][3],
"Set the camera matrix",
"--Mscreen %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f",
&Mscr[0][0], &Mscr[0][1], &Mscr[0][2], &Mscr[0][3],
&Mscr[1][0], &Mscr[1][1], &Mscr[1][2], &Mscr[1][3],
&Mscr[2][0], &Mscr[2][1], &Mscr[2][2], &Mscr[2][3],
&Mscr[3][0], &Mscr[3][1], &Mscr[3][2], &Mscr[3][3],
"Set the camera matrix",
"--hash", &embed_hash, "Embed SHA-1 hash of pixels in the header",
"--prman-metadata", &prman_metadata, "Add prman specific metadata",
"--constant-color-detect", &constant_color_detect, "Create 1-tile textures from constant color inputs",
"--monochrome-detect", &monochrome_detect, "Create 1-channel textures from monochrome inputs",
"--stats", &stats, "Print runtime statistics",
//FIXME "-c %s", &channellist, "Restrict/shuffle channels",
//FIXME "-debugdso"
//FIXME "-note %s", ¬e, "Append a note to the image comments",
"<SEPARATOR>", "Basic modes (default is plain texture):",
"--shadow", &shadowmode, "Create shadow map",
// "--shadcube", &shadowcubemode, "Create shadow cube (file order: px,nx,py,ny,pz,nz) (UNIMPLEMENTED)",
// "--volshad", &volshadowmode, "Create volume shadow map (UNIMP)",
"--envlatl", &envlatlmode, "Create lat/long environment map",
"--envcube", &envcubemode, "Create cubic env map (file order: px, nx, py, ny, pz, nz) (UNIMP)",
// "--lightprobe", &lightprobemode, "Convert a lightprobe to cubic env map (UNIMP)",
// "--latl2envcube", &latl2envcubemode, "Convert a lat-long env map to a cubic env map (UNIMP)",
// "--vertcross", &vertcrossmode, "Convert a vertical cross layout to a cubic env map (UNIMP)",
"<SEPARATOR>", "Configuration Presets",
"--prman", &prman, "Use PRMan-safe settings for tile size, planarconfig, and metadata.",
"--oiio", &oiio, "Use OIIO-optimized settings for tile size, planarconfig, metadata, and constant-color optimizations.",
NULL);
if (ap.parse (argc, (const char**)argv) < 0) {
std::cerr << ap.geterror() << std::endl;
ap.usage ();
exit (EXIT_FAILURE);
}
if (help) {
ap.usage ();
exit (EXIT_FAILURE);
}
full_command_line = ap.command_line ();
int optionsum = ((int)shadowmode + (int)shadowcubemode + (int)volshadowmode +
(int)envlatlmode + (int)envcubemode +
(int)lightprobemode + (int)vertcrossmode +
(int)latl2envcubemode);
if (optionsum > 1) {
std::cerr << "maketx ERROR: At most one of the following options may be set:\n"
<< "\t--shadow --shadcube --volshad --envlatl --envcube\n"
<< "\t--lightprobe --vertcross --latl2envcube\n";
ap.usage ();
exit (EXIT_FAILURE);
}
if (optionsum == 0)
mipmapmode = true;
if (doresize)
noresize = false;
if (prman && oiio) {
std::cerr << "maketx ERROR: '--prman' compatibility, and '--oiio' optimizations are mutually exclusive.\n";
std::cerr << "\tIf you'd like both prman and oiio compatibility, you should choose --prman\n";
std::cerr << "\t(at the expense of oiio-specific optimizations)\n";
ap.usage ();
exit (EXIT_FAILURE);
//.........这里部分代码省略.........
示例2: if
//.........这里部分代码省略.........
}
int optionsum = ((int)shadowmode + (int)envlatlmode + (int)envcubemode +
(int)lightprobemode);
if (optionsum > 1) {
std::cerr << "maketx ERROR: At most one of the following options may be set:\n"
<< "\t--shadow --envlatl --envcube --lightprobe\n";
ap.usage ();
exit (EXIT_FAILURE);
}
if (optionsum == 0)
mipmapmode = true;
if (prman && oiio) {
std::cerr << "maketx ERROR: '--prman' compatibility, and '--oiio' optimizations are mutually exclusive.\n";
std::cerr << "\tIf you'd like both prman and oiio compatibility, you should choose --prman\n";
std::cerr << "\t(at the expense of oiio-specific optimizations)\n";
ap.usage ();
exit (EXIT_FAILURE);
}
if (filenames.size() != 1) {
std::cerr << "maketx ERROR: requires exactly one input filename\n";
exit (EXIT_FAILURE);
}
// std::cout << "Converting " << filenames[0] << " to " << outputfilename << "\n";
// Figure out which data format we want for output
if (! dataformatname.empty()) {
if (dataformatname == "uint8")
configspec.format = TypeDesc::UINT8;
else if (dataformatname == "int8" || dataformatname == "sint8")
configspec.format = TypeDesc::INT8;
else if (dataformatname == "uint16")
configspec.format = TypeDesc::UINT16;
else if (dataformatname == "int16" || dataformatname == "sint16")
configspec.format = TypeDesc::INT16;
else if (dataformatname == "half")
configspec.format = TypeDesc::HALF;
else if (dataformatname == "float")
configspec.format = TypeDesc::FLOAT;
else if (dataformatname == "double")
configspec.format = TypeDesc::DOUBLE;
}
configspec.tile_width = tile[0];
configspec.tile_height = tile[1];
configspec.tile_depth = tile[2];
configspec.attribute ("compression", compression);
if (fovcot != 0.0f)
configspec.attribute ("fovcot", fovcot);
configspec.attribute ("planarconfig", separate ? "separate" : "contig");
if (Mcam != Imath::M44f(0.0f))
configspec.attribute ("worldtocamera", TypeDesc::TypeMatrix, &Mcam);
if (Mscr != Imath::M44f(0.0f))
configspec.attribute ("worldtoscreen", TypeDesc::TypeMatrix, &Mscr);
std::string wrapmodes = (swrap.size() ? swrap : wrap) + ',' +
(twrap.size() ? twrap : wrap);
configspec.attribute ("wrapmodes", wrapmodes);
configspec.attribute ("maketx:verbose", verbose);
configspec.attribute ("maketx:stats", stats);
configspec.attribute ("maketx:resize", doresize);
configspec.attribute ("maketx:nomipmap", nomipmap);
configspec.attribute ("maketx:updatemode", updatemode);
configspec.attribute ("maketx:constant_color_detect", constant_color_detect);
configspec.attribute ("maketx:monochrome_detect", monochrome_detect);
configspec.attribute ("maketx:opaque_detect", opaque_detect);
configspec.attribute ("maketx:unpremult", unpremult);
configspec.attribute ("maketx:incolorspace", incolorspace);
configspec.attribute ("maketx:outcolorspace", outcolorspace);
configspec.attribute ("maketx:checknan", checknan);
configspec.attribute ("maketx:fixnan", fixnan);
configspec.attribute ("maketx:set_full_to_pixels", set_full_to_pixels);
configspec.attribute ("maketx:highlightcomp", (int)do_highlight_compensation);
if (filtername.size())
configspec.attribute ("maketx:filtername", filtername);
configspec.attribute ("maketx:nchannels", nchannels);
configspec.attribute ("maketx:channelnames", channelnames);
if (fileformatname.size())
configspec.attribute ("maketx:fileformatname", fileformatname);
configspec.attribute ("maketx:prman_metadata", prman_metadata);
configspec.attribute ("maketx:oiio_options", oiio);
configspec.attribute ("maketx:prman_options", prman);
if (mipimages.size())
configspec.attribute ("maketx:mipimages", Strutil::join(mipimages,";"));
std::string cmdline = Strutil::format ("OpenImageIO %s : %s",
OIIO_VERSION_STRING, ap.command_line());
configspec.attribute ("Software", cmdline);
configspec.attribute ("maketx:full_command_line", cmdline);
if (ignore_unassoc) {
configspec.attribute ("maketx:ignore_unassoc", (int)ignore_unassoc);
ImageCache *ic = ImageCache::create (); // get the shared one
ic->attribute ("unassociatedalpha", (int)ignore_unassoc);
}
}