872 {
876 parser.addOptionSingle('h', "Display help message")
877 .addOptionSingle('v', "Print version")
878 .addOptionSingleValue('p', "assets path")
879 .addOptionDoubleValue('P', "path", "assets path")
880 .addOptionSingleValue('r', "Resolution WidthxHeight")
881 .addOptionDoubleValue('R', "resolution", "Resolution WidthxHeight")
882 .addOptionSingle('f', "fullscreen")
883 .addOptionDouble('F', "fullscreen", "fullscreen")
884 .addOptionDouble(301, "fast", "fast")
885 .addOptionDoubleValue(256, "filename", "input filename")
886 .addOptionDoubleValue(324, "model", "model filename (.obj, .mxmod, or .mxmod.z)")
887 .addOptionSingleValue('o', "output filename")
888 .addOptionDoubleValue(304, "output", "output filename")
889 .addOptionSingleValue('c', "crf value")
890 .addOptionDoubleValue(305, "crf", "crf value")
891 .addOptionDoubleValue(306, "encode-preset", "encoder preset")
892 .addOptionDoubleValue(307, "encode-tune", "encoder tune")
893 .addOptionDoubleValue(308, "encode-codec", "encoder codec policy or name")
894 .addOptionDouble(309, "encode-realtime", "encoder realtime mode")
895 .addOptionDouble(314, "mxwrite-block", "block MXWrite when its queue is full")
896 .addOptionDouble(310, "repeat", "repeat playback or wrapped textures")
897 .addOptionDouble(315, "binary", "use binary glyphs only")
898 .addOptionDouble(319, "enable-crt", "enable CRT post-processing at startup")
899 .addOptionDouble(320, "enable-vsync", "enable FIFO present mode / v-sync")
900 .addOptionDouble(322, "enable-screenshot", "enable F10 screenshot capture")
901 .addOptionDouble(325, "disable-sound", "disable background music")
902 .addOptionDouble(330, "benchmark", "enable application benchmark mode")
903 .addOptionDouble(331, "wireframe", "render supported 3D models as wireframes")
904 .addOptionDouble(326, "nowarpfix", "3dmath - disable perspective-correct texture mapping")
905 .addOptionDoubleValue(327, "framebuffer", "3dmath - software framebuffer size WidthxHeight")
906 .addOptionDouble(328, "disable-mipmap", "3dmath - disable mipmap generation and selection")
907 .addOptionDoubleValue(329, "mip-bias", "3dmath - mipmap level-of-detail bias (-16 to 16)")
908 .addOptionDoubleValue(321, "fps", "capture FPS override")
909 .addOptionSingleValue('z', "matrix rain font size")
910 .addOptionDoubleValue(316, "font-size", "matrix rain font size")
911 .addOptionSingleValue('j', "matrix rain font file path")
912 .addOptionDoubleValue(317, "font-path", "matrix rain font file path")
913 .addOptionSingleValue('C', "matrix rain RGB tint (#RRGGBB or R,G,B)")
914 .addOptionDoubleValue(318, "color", "matrix rain RGB tint (#RRGGBB or R,G,B)")
915 .addOptionDoubleValue(302, "resource", "resource file")
916 .addOptionDoubleValue(303, "resource_path", "resource data path")
917 .addOptionDoubleValue(257, "texture", "texture file (.png or .tex)")
918 .addOptionDoubleValue(323, "textures", "texture file (.png or .tex)")
919 .addOptionSingleValue('S', "shader SPV folder path (contains index.txt)")
920 .addOptionDoubleValue(258, "shader-path", "shader SPV folder path (contains index.txt)")
921 .addOptionDoubleValue(313, "fragment", "fragment shader SPV path")
922 .addOptionSingleValue('i', "acidcam filter mode index")
923 .addOptionDoubleValue(311, "index", "acidcam filter mode index")
924 .addOptionDoubleValue(312, "shader-index", "initial shader entry index")
925 .addOptionDoubleValue(300, "camera", "camera index");
926
928 std::string path;
929 int value = 0;
930 int tw = 1280, th = 720;
931 bool fullscreen = false;
932 bool fast = false;
933 bool resolutionSpecified = false;
934 std::string filename;
935 std::string model;
936 std::string output;
937 std::string crf;
938 std::string encodePreset;
939 std::string encodeTune;
940 std::string encodeCodec;
941 bool encodeRealtime = false;
942 bool mxwriteBlockWhenFull = false;
943 bool repeat = false;
944 bool binary = false;
945 bool enable_crt = false;
946 bool enable_vsync = false;
947 bool enable_screenshot = false;
948 bool disable_sound = false;
949 bool benchmark = false;
950 bool wireframe = false;
951 bool nowarpfix = false;
952 bool disable_mipmap = false;
953 float mip_bias = 0.0f;
955 bool framebufferSpecified = false;
956 double fps = 0.0;
957 int font_size = 22;
958 std::string font_path;
959 std::string color;
960 std::string texture;
961 std::string shaderPath;
962 std::string fragmentPath;
963 int camera_index = 0;
964 int index = 0;
965 int shader_index = 0;
966 std::string resource;
967 std::string resource_path;
968 while ((value = parser.proc(arg)) != -1) {
969 switch (value) {
970 case 303:
972 break;
973 case 302:
975 break;
976 case 256:
978 break;
979 case 324:
981 break;
982 case 'o':
983 case 304:
985 break;
986 case 'c':
987 case 305:
989 break;
990 case 306:
992 break;
993 case 307:
995 break;
996 case 308:
998 break;
999 case 309:
1000 encodeRealtime = true;
1001 break;
1002 case 314:
1003 mxwriteBlockWhenFull = true;
1004 break;
1005 case 310:
1006 repeat = true;
1007 break;
1008 case 315:
1009 binary = true;
1010 break;
1011 case 319:
1012 enable_crt = true;
1013 break;
1014 case 320:
1015 enable_vsync = true;
1016 break;
1017 case 322:
1018 enable_screenshot = true;
1019 break;
1020 case 325:
1021 disable_sound = true;
1022 break;
1023 case 330:
1024 benchmark = true;
1025 break;
1026 case 331:
1027 wireframe = true;
1028 break;
1029 case 326:
1030 nowarpfix = true;
1031 break;
1032 case 327: {
1033 const std::string::size_type separator = arg.
arg_value.find(
'x');
1034 if (separator == std::string::npos) {
1036 }
1039 if (framebuffer.
width <= 0 || framebuffer.
height <= 0) {
1041 }
1042 framebufferSpecified = true;
1043 } break;
1044 case 328:
1045 disable_mipmap = true;
1046 break;
1047 case 329: {
1049 if (parsed_mip_bias < -16.0 || parsed_mip_bias > 16.0) {
1051 }
1052 mip_bias = static_cast<float>(parsed_mip_bias);
1053 } break;
1054 case 321:
1056 if (fps <= 0.0) {
1058 }
1059 break;
1060 case 'z':
1061 case 316:
1063 if (font_size <= 0) {
1065 }
1066 break;
1067 case 'j':
1068 case 317:
1070 break;
1071 case 'C':
1072 case 318:
1074 break;
1075 case 257:
1076 case 323:
1078 break;
1079 case 'S':
1080 case 258:
1082 break;
1083 case 313:
1085 break;
1086 case 'h':
1087 case 'v':
1088 parser.help(std::cout);
1089 exit(EXIT_SUCCESS);
1090 break;
1091 case 'p':
1092 case 'P':
1094 break;
1095 case 'r':
1096 case 'R': {
1098 if (pos == std::string::npos) {
1100 }
1101 std::string left, right;
1106 if (tw <= 0 || th <= 0) {
1108 }
1109 resolutionSpecified = true;
1110 } break;
1111 case 'f':
1112 case 'F':
1113 fullscreen = true;
1114 break;
1115 case 301:
1116 fast = true;
1117 break;
1118 case 300:
1120 break;
1121 case 'i':
1122 case 311:
1124 break;
1125 case 312:
1127 break;
1128 }
1129 }
1130 if (path.empty()) {
1132 std::cerr << "mx: No path provided; using executable directory: " << path << '\n';
1133 } else {
1134 std::error_code error;
1135 const std::filesystem::path absolute_path = std::filesystem::absolute(path, error);
1136 if (!error) {
1137 path = absolute_path.lexically_normal().string();
1138 }
1139 }
1183 return args;
1184}
std::string executable_directory(const char *executable)
double parse_arg_double(const std::string &text, const std::string &option_name)
int parse_arg_int(const std::string &text, const std::string &option_name)
std::string parse_executable_name(const char *argv0)
void setDefaultEnableScreenshot(bool enabled)
void setDefaultExecutableName(const std::string &name)
String arg_value
Value string supplied after the option, if any.
Plain data structure returned by proc_args() with all common libmx2 CLI options.
FramebufferDimensions framebuffer
Software framebuffer size requested by --framebuffer.
std::string shaderPath
Optional SPV shader folder path (-S / --shader-path).
bool framebufferSpecified
Whether --framebuffer was provided.
std::string output
Optional output filename (--output).
std::string font_path
Optional font file path (--font-path).
bool mxwriteBlockWhenFull
Make MXWrite block instead of dropping frames (--mxwrite-block).
bool fast
Whether fast mode was requested (--fast).
int camera_index
Optional camera index.
bool enable_screenshot
Enable F10 screenshot capture (--enable-screenshot).
std::string encodeTune
Optional encoder tune (--encode-tune).
bool fullscreen
Whether fullscreen mode was requested.
int index
Optional acidcam filter mode index.
bool encodeRealtime
Enable low-latency encoder settings (--encode-realtime).
bool resolutionSpecified
Whether -r/–resolution was provided.
float mip_bias
Mipmap level-of-detail bias requested by --mip-bias.
std::string model
Optional model filename (--model).
bool enable_vsync
Enable FIFO present mode / v-sync (--enable-vsync).
std::string crf
Optional CRF value (--crf).
bool nowarpfix
Disable perspective-correct texture mapping (--nowarpfix).
std::string texture
Optional texture file path (--texture).
int height
Viewport height in pixels (default: 720).
double fps
Optional FPS override (--fps); non-positive means unspecified.
std::string encodeCodec
Optional encoder codec policy/name (--encode-codec).
std::string color
Optional rain RGB tint (--color).
std::string resource_path
Resource path.
bool repeat
Enable repeat behavior such as playback looping or wrapped textures.
std::string filename
Optional input filename (--filename).
std::string encodePreset
Optional encoder preset (--encode-preset).
std::string path
Asset root; proc_args() defaults it to the executable directory.
std::string fragmentPath
Optional fragment shader SPV path (--fragment).
std::string executable_name
Executable basename derived from argv[0].
bool benchmark
Enable application benchmark mode (--benchmark).
bool wireframe
Render supported 3D models as wireframes (--wireframe).
int width
Viewport width in pixels (default: 1280).
std::string resource
Resource file.
bool enable_crt
Enable CRT post-processing at startup (--enable-crt).
int shader_index
Optional initial shader entry index.
bool disable_mipmap
Disable mipmap generation and selection (--disable-mipmap).
int font_size
Matrix rain font size in pixels (--font-size).
bool binary
Use binary glyphs only (--binary).
bool disable_sound
Disable application background music (--disable-sound).
Parsed software framebuffer dimensions.
int width
Software framebuffer width in pixels.
int height
Software framebuffer height in pixels.