diff --git a/src/main.cpp b/src/main.cpp index e1a7d0b..3a540c9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,15 +2,27 @@ #include #include #include "include/ui_mainwindow.h" +#include +#include int main(int argc, char **argv) { QApplication app(argc, argv); + QCommandLineParser parser; + QCommandLineOption mtl_filepath_opt({"m", "material"}, "Material file path", "path"); + QCommandLineOption obj_filepath_opt({"o", "object"}, "Object file path", "path"); + parser.addOption(mtl_filepath_opt); + parser.addOption(obj_filepath_opt); + parser.process(app); + QString mtl_filepath = parser.value(mtl_filepath_opt); + QString obj_filepath = parser.value(obj_filepath_opt); + if (mtl_filepath.isEmpty() || obj_filepath.isEmpty()) { + return -1; + } QMainWindow w; Ui::MainWindow ui; ui.setupUi(&w); - - ui.openGLWidget->obj.load_mtl("untitled.mtl"); - ui.openGLWidget->obj.load_obj("untitled.obj"); + ui.openGLWidget->obj.load_mtl(mtl_filepath.toStdString()); + ui.openGLWidget->obj.load_obj(obj_filepath.toStdString()); QTimer timer_draw; QTimer timer_cam;