forked from gammaniac/Qt-GL-Simple-Scene
/
main.cpp
48 lines (36 loc) · 1.33 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <QApplication>
#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include "mainview.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// main window
QWidget win;
// GL format
QGLFormat format;
format.setVersion(4,3);
format.setProfile(QGLFormat::CoreProfile);
MainView *glView = new MainView(format);
QVBoxLayout *mainLayout = new QVBoxLayout(&win);
mainLayout->addWidget(glView);
QWidget *cPanel = new QWidget(&win);
QHBoxLayout *cPanelLayout = new QHBoxLayout();
cPanel->setLayout(cPanelLayout);
QPushButton *sShotButton = new QPushButton("Screen Shot");
cPanelLayout->addWidget(sShotButton);
QObject::connect( sShotButton, SIGNAL(clicked()), glView, SLOT(takeScreenShot()) );
QPushButton *switchButton = new QPushButton("Switch Buffers");
cPanelLayout->addWidget(switchButton);
QObject::connect(switchButton, SIGNAL(clicked()), glView, SLOT(switchModel()));
QPushButton *animButton = new QPushButton("Start/Stop Animation");
cPanelLayout->addWidget(animButton);
QObject::connect(animButton, SIGNAL(clicked()), glView, SLOT(toggleAnimation()) );
mainLayout->addWidget(cPanel);
win.setLayout(mainLayout);
win.setWindowTitle("Simple Scene");
win.show();
return app.exec();
}