goat3d
diff goatview/src/main.cc @ 75:76dea247f75c
in progress
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 08 May 2014 00:50:16 +0300 |
parents | 9862541fdcf5 |
children | 9785847d52d4 |
line diff
1.1 --- a/goatview/src/main.cc Tue May 06 13:26:52 2014 +0300 1.2 +++ b/goatview/src/main.cc Thu May 08 00:50:16 2014 +0300 1.3 @@ -1,9 +1,47 @@ 1.4 #include <QtWidgets/QtWidgets> 1.5 +#include <QtCore/QtCore> 1.6 #include "goatview.h" 1.7 1.8 int main(int argc, char **argv) 1.9 { 1.10 QApplication app(argc, argv); 1.11 + app.setOrganizationName("Mutant Stargoat"); 1.12 + app.setOrganizationDomain("mutantstargoat.com"); 1.13 + app.setApplicationName("GoatView"); 1.14 + settings = new QSettings; 1.15 + 1.16 + QCommandLineParser argparse; 1.17 + argparse.addHelpOption(); 1.18 + 1.19 + argparse.addPositionalArgument("scene", "scene file to open"); 1.20 + argparse.addOption(QCommandLineOption("a", "add animation file")); 1.21 + argparse.process(app); 1.22 + 1.23 + const QStringList &args = argparse.positionalArguments(); 1.24 + if(!args.isEmpty()) { 1.25 + if(args.count() > 1) { 1.26 + fprintf(stderr, "please specify at most one scene file to open\n"); 1.27 + return 1; 1.28 + } 1.29 + std::string fname = args.at(0).toStdString(); 1.30 + printf("loading scene file: %s ...\n", fname.c_str()); 1.31 + if(!(scene = goat3d_create()) || goat3d_load(scene, fname.c_str())) { 1.32 + fprintf(stderr, "failed to load scene: %s\n", fname.c_str()); 1.33 + return 1; 1.34 + } 1.35 + } 1.36 + 1.37 + const QStringList &anims = argparse.values("a"); 1.38 + QStringList::const_iterator it = anims.begin(); 1.39 + while(it != anims.end()) { 1.40 + std::string fname = it++->toStdString(); 1.41 + printf("loading animation file: %s ...\n", fname.c_str()); 1.42 + 1.43 + if(goat3d_load_anim(scene, fname.c_str()) == -1) { 1.44 + fprintf(stderr, "failed to load animation: %s\n", fname.c_str()); 1.45 + return 1; 1.46 + } 1.47 + } 1.48 1.49 GoatView gview; 1.50 gview.show();