WidgetGL::WidgetGL(QWidget *parent, bool fullscreen) : QGLWidget(parent), ui(new Ui::WidgetGL) { rTri = 0.0; rQuad = 0.0; xRot = 0.0; yRot = 0.0; zRot = 0.0; zoom = 0.0; xpan = 0.0; ypan = 0.0; blend = false; bAnimate = false; left = 0.0; right = 0.0; bottom = 0.0; top = 0.0; m_fullscreen = fullscreen; this->setGeometry(10, 30, 640, 480); this->setWindowTitle(tr("Macai's OpenGL Framework demo4")); if(m_fullscreen) showFullScreen(); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(rotateOneStep())); }
Window::Window() { QGridLayout *mainLayout = new QGridLayout; for (int i = 0; i < NumRows; ++i) { for (int j = 0; j < NumColumns; ++j) { QColor clearColor; clearColor.setHsv(((i * NumColumns) + j) * 255 / (NumRows * NumColumns - 1), 255, 63); glWidgets[i][j] = new GLWidget(0, 0); glWidgets[i][j]->setClearColor(clearColor); glWidgets[i][j]->rotateBy(+42 * 16, +42 * 16, -21 * 16); mainLayout->addWidget(glWidgets[i][j], i, j); connect(glWidgets[i][j], SIGNAL(clicked()), this, SLOT(setCurrentGlWidget())); } } setLayout(mainLayout); currentGlWidget = glWidgets[0][0]; QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(rotateOneStep())); timer->start(20); setWindowTitle(tr("Textures")); }
void panel_de::rotateOneStep() { static bool first = true; static QTimer *timer = new QTimer(this); if(first) { connect(timer, SIGNAL(timeout()), this, SLOT(rotateOneStep())); timer->start(20); first = false; } ui->widget->rotateBy(+2 * 16, +2 * 16, -1 * 16); }
int Window::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: setCurrentGlWidget(); break; case 1: rotateOneStep(); break; default: ; } _id -= 2; } return _id; }
OGLContext::OGLContext(QWidget* parent) : QGLWidget(QGLFormat(QGL::SampleBuffers), parent) { // xRot: -167.684 yRot: 163.307 xRot=-167.684f; yRot=163.307f; zRot=0.0f; nScale = 1; qRotate = true; timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(rotateOneStep())); timer->start(20); }
Window::Window() { glWidgets[0][0] = new GLWidget(this, 0, 0); glWidgets[0][1] = new GLWidget(this, 1, 0); glWidgets[0][2] = new GLWidget(this, 2, 0); glWidgets[0][3] = new GLWidget(this, 3, 0); glWidgets[1][0] = new GLWidget(this, 4, 0); glWidgets[1][1] = new GLWidget(this, 5, 0); glWidgets[1][2] = new GLWidget(this, 6, 0); glWidgets[1][3] = new GLWidget(this, 7, 0); glWidgets[2][0] = new GLWidget(this, 8, 0); glWidgets[2][1] = new GLWidget(this, 9, 0); glWidgets[2][2] = new GLWidget(this, 10, 0); glWidgets[2][3] = new GLWidget(this, 11, 0); glWidgets[3][0] = new GLWidget(this, 12, 0); glWidgets[3][1] = new GLWidget(this, 13, 0); glWidgets[3][2] = new GLWidget(this, 14, 0); glWidgets[3][3] = new GLWidget(this, 15, 0); mainLayout = new QGridLayout; mouseOn = mouse[0] = mouse[1] = false; for (int i = 0; i < NumRows; ++i) { for (int j = 0; j < NumColumns; ++j) { mainLayout->addWidget(glWidgets[i][j], i, j); connect(glWidgets[i][j], SIGNAL(clicked()), this, SLOT(setCurrentGlWidget())); } } setLayout(mainLayout); currentGlWidget = glWidgets[0][0]; QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(rotateOneStep())); timer->start(20); setWindowTitle(tr("Sleep Dream Games")); shortcut(QKeySequence(Qt::Key_Escape), SLOT(keyHandleWM())); shortcut(QKeySequence(Qt::Key_Tab), SLOT(keyHandleWP())); shortcut(QKeySequence(Qt::Key_Space), SLOT(keyHandleXM())); shortcut(QKeySequence(Qt::Key_Enter), SLOT(keyHandleXP())); shortcut(QKeySequence(Qt::Key_Up), SLOT(keyHandleYM())); shortcut(QKeySequence(Qt::Key_Down), SLOT(keyHandleYP())); shortcut(QKeySequence(Qt::Key_Left), SLOT(keyHandleZM())); shortcut(QKeySequence(Qt::Key_Right), SLOT(keyHandleZP())); shortcut(QKeySequence(Qt::Key_Delete), SLOT(mouseFlip())); j = new Joystick(); connect(j,SIGNAL(keyHandleWM()), this , SLOT(keyHandleWM())); connect(j,SIGNAL(keyHandleWP()), this , SLOT(keyHandleWP())); connect(j,SIGNAL(keyHandleXM()), this , SLOT(keyHandleXM())); connect(j,SIGNAL(keyHandleXP()), this , SLOT(keyHandleXP())); connect(j,SIGNAL(keyHandleYM()), this , SLOT(keyHandleYM())); connect(j,SIGNAL(keyHandleYP()), this , SLOT(keyHandleYP())); connect(j,SIGNAL(keyHandleZM()), this , SLOT(keyHandleZM())); connect(j,SIGNAL(keyHandleZP()), this , SLOT(keyHandleZP())); QTimer *hot = new QTimer(this); connect(hot, SIGNAL(timeout()), this, SLOT(hotPlug())); hot->start(1000); }