goat3d

annotate goatview/src/main.cc @ 103:45a9d493e98c

fixed the input latency issue by calling QWidget::update() instead of QGLWidget::updateGL() update schedules an update instead of redrawing immediately.
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 12 Sep 2015 17:40:02 +0300
parents 70b7c41a4f17
children
rev   line source
nuclear@73 1 #include <QtWidgets/QtWidgets>
nuclear@75 2 #include <QtCore/QtCore>
nuclear@73 3 #include "goatview.h"
nuclear@73 4
nuclear@73 5 int main(int argc, char **argv)
nuclear@73 6 {
nuclear@73 7 QApplication app(argc, argv);
nuclear@75 8 app.setOrganizationName("Mutant Stargoat");
nuclear@75 9 app.setOrganizationDomain("mutantstargoat.com");
nuclear@75 10 app.setApplicationName("GoatView");
nuclear@82 11
nuclear@82 12 GoatView gview;
nuclear@75 13
nuclear@75 14 QCommandLineParser argparse;
nuclear@75 15 argparse.addHelpOption();
nuclear@75 16
nuclear@75 17 argparse.addPositionalArgument("scene", "scene file to open");
nuclear@75 18 argparse.addOption(QCommandLineOption("a", "add animation file"));
nuclear@94 19 argparse.parse(app.arguments());
nuclear@75 20
nuclear@75 21 const QStringList &args = argparse.positionalArguments();
nuclear@75 22 if(!args.isEmpty()) {
nuclear@75 23 if(args.count() > 1) {
nuclear@75 24 fprintf(stderr, "please specify at most one scene file to open\n");
nuclear@75 25 return 1;
nuclear@75 26 }
nuclear@75 27 std::string fname = args.at(0).toStdString();
nuclear@75 28 printf("loading scene file: %s ...\n", fname.c_str());
nuclear@82 29 if(!gview.load_scene(fname.c_str())) {
nuclear@75 30 fprintf(stderr, "failed to load scene: %s\n", fname.c_str());
nuclear@75 31 return 1;
nuclear@75 32 }
nuclear@75 33 }
nuclear@75 34
nuclear@75 35 const QStringList &anims = argparse.values("a");
nuclear@75 36 QStringList::const_iterator it = anims.begin();
nuclear@75 37 while(it != anims.end()) {
nuclear@75 38 std::string fname = it++->toStdString();
nuclear@75 39 printf("loading animation file: %s ...\n", fname.c_str());
nuclear@75 40
nuclear@75 41 if(goat3d_load_anim(scene, fname.c_str()) == -1) {
nuclear@75 42 fprintf(stderr, "failed to load animation: %s\n", fname.c_str());
nuclear@75 43 return 1;
nuclear@75 44 }
nuclear@75 45 }
nuclear@73 46
nuclear@73 47 gview.show();
nuclear@73 48
nuclear@73 49 return app.exec();
nuclear@73 50 }