diff --git a/main.cpp b/main.cpp index f6862af..223bfad 100644 --- a/main.cpp +++ b/main.cpp @@ -8,9 +8,12 @@ int main(int argc, char **argv) { QMainWindow w; Ui::MainWindow ui; ui.setupUi(&w); - QTimer timer; - w.connect(&timer, SIGNAL(timeout()), ui.openGLWidget, SLOT(paintGL())); - timer.start(16); + QTimer timer_draw; + QTimer timer_cam; + w.connect(&timer_draw, SIGNAL(timeout()), ui.openGLWidget, SLOT(paintGL())); + w.connect(&timer_cam, SIGNAL(timeout()), ui.openGLWidget, SLOT(update_camera())); + timer_draw.start(16); + timer_cam.start(16); w.show(); return app.exec(); } diff --git a/moc_opglwidget.cpp b/moc_opglwidget.cpp index f5d5e4a..85488e5 100644 --- a/moc_opglwidget.cpp +++ b/moc_opglwidget.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_OPGLWidget_t { - QByteArrayData data[3]; - char stringdata0[20]; + QByteArrayData data[4]; + char stringdata0[34]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -34,10 +34,11 @@ static const qt_meta_stringdata_OPGLWidget_t qt_meta_stringdata_OPGLWidget = { { QT_MOC_LITERAL(0, 0, 10), // "OPGLWidget" QT_MOC_LITERAL(1, 11, 7), // "paintGL" -QT_MOC_LITERAL(2, 19, 0) // "" +QT_MOC_LITERAL(2, 19, 0), // "" +QT_MOC_LITERAL(3, 20, 13) // "update_camera" }, - "OPGLWidget\0paintGL\0" + "OPGLWidget\0paintGL\0\0update_camera" }; #undef QT_MOC_LITERAL @@ -47,7 +48,7 @@ static const uint qt_meta_data_OPGLWidget[] = { 8, // revision 0, // classname 0, 0, // classinfo - 1, 14, // methods + 2, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -55,9 +56,11 @@ static const uint qt_meta_data_OPGLWidget[] = { 0, // signalCount // slots: name, argc, parameters, tag, flags - 1, 0, 19, 2, 0x0a /* Public */, + 1, 0, 24, 2, 0x0a /* Public */, + 3, 0, 25, 2, 0x0a /* Public */, // slots: parameters + QMetaType::Void, QMetaType::Void, 0 // eod @@ -70,6 +73,7 @@ void OPGLWidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, (void)_t; switch (_id) { case 0: _t->paintGL(); break; + case 1: _t->update_camera(); break; default: ; } } @@ -105,13 +109,13 @@ int OPGLWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 1) + if (_id < 2) qt_static_metacall(this, _c, _id, _a); - _id -= 1; + _id -= 2; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 1) + if (_id < 2) *reinterpret_cast(_a[0]) = -1; - _id -= 1; + _id -= 2; } return _id; } diff --git a/opglwidget.cpp b/opglwidget.cpp index 993c12a..af870e1 100644 --- a/opglwidget.cpp +++ b/opglwidget.cpp @@ -26,7 +26,6 @@ void OPGLWidget::initializeGL() { } void OPGLWidget::paintGL() { - for (int i = 0; i < 3; i++) {loc[i] += vel[i];}; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); reorient(); @@ -72,3 +71,9 @@ void OPGLWidget::resizeGL(int w, int h) { glFrustum(-right, right, -top, top, 0.1f, 100.0f); glMatrixMode(GL_MODELVIEW); } + +void OPGLWidget::update_camera() { + for (int i = 0; i < 3; i++) { + loc[i] += vel[i]; + }; +} diff --git a/opglwidget.h b/opglwidget.h index c427934..667b33d 100644 --- a/opglwidget.h +++ b/opglwidget.h @@ -8,6 +8,7 @@ public: OPGLWidget(QWidget *parent) : QOpenGLWidget(parent) {} public slots: void paintGL(); + void update_camera(); protected: void initializeGL(); void resizeGL(int w, int h);