854 {
858 parser.addOptionSingle('h', "Display help message")
859 .addOptionSingle('v', "Print version")
860 .addOptionSingleValue('p', "assets path")
861 .addOptionDoubleValue('P', "path", "assets path")
862 .addOptionSingleValue('r', "Resolution WidthxHeight")
863 .addOptionDoubleValue('R', "resolution", "Resolution WidthxHeight")
864 .addOptionSingle('f', "fullscreen")
865 .addOptionDouble('F', "fullscreen", "fullscreen")
866 .addOptionDouble(301, "fast", "fast")
867 .addOptionDoubleValue(256, "filename", "input filename")
868 .addOptionDoubleValue(324, "model", "model filename (.obj, .mxmod, or .mxmod.z)")
869 .addOptionSingleValue('o', "output filename")
870 .addOptionDoubleValue(304, "output", "output filename")
871 .addOptionSingleValue('c', "crf value")
872 .addOptionDoubleValue(305, "crf", "crf value")
873 .addOptionDoubleValue(306, "encode-preset", "encoder preset")
874 .addOptionDoubleValue(307, "encode-tune", "encoder tune")
875 .addOptionDoubleValue(308, "encode-codec", "encoder codec policy or name")
876 .addOptionDouble(309, "encode-realtime", "encoder realtime mode")
877 .addOptionDouble(314, "mxwrite-block", "block MXWrite when its queue is full")
878 .addOptionDouble(310, "repeat", "repeat playback or wrapped textures")
879 .addOptionDouble(315, "binary", "use binary glyphs only")
880 .addOptionDouble(319, "enable-crt", "enable CRT post-processing at startup")
881 .addOptionDouble(320, "enable-vsync", "enable FIFO present mode / v-sync")
882 .addOptionDouble(322, "enable-screenshot", "enable F10 screenshot capture")
883 .addOptionDouble(325, "disable-sound", "disable background music")
884 .addOptionDouble(330, "benchmark", "enable application benchmark mode")
885 .addOptionDouble(331, "wireframe", "render supported 3D models as wireframes")
886 .addOptionDouble(326, "nowarpfix", "3dmath - disable perspective-correct texture mapping")
887 .addOptionDoubleValue(327, "framebuffer", "3dmath - software framebuffer size WidthxHeight")
888 .addOptionDouble(328, "disable-mipmap", "3dmath - disable mipmap generation and selection")
889 .addOptionDoubleValue(329, "mip-bias", "3dmath - mipmap level-of-detail bias (-16 to 16)")
890 .addOptionDoubleValue(321, "fps", "capture FPS override")
891 .addOptionSingleValue('z', "matrix rain font size")
892 .addOptionDoubleValue(316, "font-size", "matrix rain font size")
893 .addOptionSingleValue('j', "matrix rain font file path")
894 .addOptionDoubleValue(317, "font-path", "matrix rain font file path")
895 .addOptionSingleValue('C', "matrix rain RGB tint (#RRGGBB or R,G,B)")
896 .addOptionDoubleValue(318, "color", "matrix rain RGB tint (#RRGGBB or R,G,B)")
897 .addOptionDoubleValue(302, "resource", "resource file")
898 .addOptionDoubleValue(303, "resource_path", "resource data path")
899 .addOptionDoubleValue(257, "texture", "texture file (.png or .tex)")
900 .addOptionDoubleValue(323, "textures", "texture file (.png or .tex)")
901 .addOptionSingleValue('S', "shader SPV folder path (contains index.txt)")
902 .addOptionDoubleValue(258, "shader-path", "shader SPV folder path (contains index.txt)")
903 .addOptionDoubleValue(313, "fragment", "fragment shader SPV path")
904 .addOptionSingleValue('i', "acidcam filter mode index")
905 .addOptionDoubleValue(311, "index", "acidcam filter mode index")
906 .addOptionDoubleValue(312, "shader-index", "initial shader entry index")
907 .addOptionDoubleValue(300, "camera", "camera index");
908
910 std::string path;
911 int value = 0;
912 int tw = 1280, th = 720;
913 bool fullscreen = false;
914 bool fast = false;
915 bool resolutionSpecified = false;
916 std::string filename;
918 std::string output;
919 std::string crf;
920 std::string encodePreset;
921 std::string encodeTune;
922 std::string encodeCodec;
923 bool encodeRealtime = false;
924 bool mxwriteBlockWhenFull = false;
925 bool repeat = false;
926 bool binary = false;
927 bool enable_crt = false;
928 bool enable_vsync = false;
929 bool enable_screenshot = false;
930 bool disable_sound = false;
931 bool benchmark = false;
932 bool wireframe = false;
933 bool nowarpfix = false;
934 bool disable_mipmap = false;
935 float mip_bias = 0.0f;
937 bool framebufferSpecified = false;
938 double fps = 0.0;
939 int font_size = 22;
940 std::string font_path;
941 std::string color;
942 std::string texture;
943 std::string shaderPath;
944 std::string fragmentPath;
945 int camera_index = 0;
946 int index = 0;
947 int shader_index = 0;
948 std::string resource;
949 std::string resource_path;
950 while ((value = parser.proc(arg)) != -1) {
951 switch (value) {
952 case 303:
954 break;
955 case 302:
957 break;
958 case 256:
960 break;
961 case 324:
963 break;
964 case 'o':
965 case 304:
967 break;
968 case 'c':
969 case 305:
971 break;
972 case 306:
974 break;
975 case 307:
977 break;
978 case 308:
980 break;
981 case 309:
982 encodeRealtime = true;
983 break;
984 case 314:
985 mxwriteBlockWhenFull = true;
986 break;
987 case 310:
988 repeat = true;
989 break;
990 case 315:
991 binary = true;
992 break;
993 case 319:
994 enable_crt = true;
995 break;
996 case 320:
997 enable_vsync = true;
998 break;
999 case 322:
1000 enable_screenshot = true;
1001 break;
1002 case 325:
1003 disable_sound = true;
1004 break;
1005 case 330:
1006 benchmark = true;
1007 break;
1008 case 331:
1009 wireframe = true;
1010 break;
1011 case 326:
1012 nowarpfix = true;
1013 break;
1014 case 327: {
1015 const std::string::size_type separator = arg.
arg_value.find(
'x');
1016 if (separator == std::string::npos) {
1018 }
1021 if (framebuffer.
width <= 0 || framebuffer.
height <= 0) {
1023 }
1024 framebufferSpecified = true;
1025 } break;
1026 case 328:
1027 disable_mipmap = true;
1028 break;
1029 case 329: {
1031 if (parsed_mip_bias < -16.0 || parsed_mip_bias > 16.0) {
1033 }
1034 mip_bias = static_cast<float>(parsed_mip_bias);
1035 } break;
1036 case 321:
1038 if (fps <= 0.0) {
1040 }
1041 break;
1042 case 'z':
1043 case 316:
1045 if (font_size <= 0) {
1047 }
1048 break;
1049 case 'j':
1050 case 317:
1052 break;
1053 case 'C':
1054 case 318:
1056 break;
1057 case 257:
1058 case 323:
1060 break;
1061 case 'S':
1062 case 258:
1064 break;
1065 case 313:
1067 break;
1068 case 'h':
1069 case 'v':
1070 parser.help(std::cout);
1071 exit(EXIT_SUCCESS);
1072 break;
1073 case 'p':
1074 case 'P':
1076 break;
1077 case 'r':
1078 case 'R': {
1080 if (pos == std::string::npos) {
1082 }
1083 std::string left, right;
1088 if (tw <= 0 || th <= 0) {
1090 }
1091 resolutionSpecified = true;
1092 } break;
1093 case 'f':
1094 case 'F':
1095 fullscreen = true;
1096 break;
1097 case 301:
1098 fast = true;
1099 break;
1100 case 300:
1102 break;
1103 case 'i':
1104 case 311:
1106 break;
1107 case 312:
1109 break;
1110 }
1111 }
1112 if (path.empty()) {
1114 std::cerr << "mx: No path provided; using executable directory: " << path << '\n';
1115 } else {
1116 std::error_code error;
1117 const std::filesystem::path absolute_path = std::filesystem::absolute(path, error);
1118 if (!error) {
1119 path = absolute_path.lexically_normal().string();
1120 }
1121 }
1165 return args;
1166}
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.