int main(int argc, char **argv) { QApplication app(argc, argv); // mask: on/off // opacity: on/off for (int i=0; i<4; ++i) { bool mask = i & 0x1; bool opacity = i & 0x2; Qt::WindowFlags flags = Qt::FramelessWindowHint; Widget *widget = new Widget(flags); GLWindow *window = new GLWindow(flags); widget->setGeometry(100 + 100 * i, 100, 80, 80); window->setGeometry(100 + 100 * i, 200, 80, 80); if (mask) { QRegion region(0, 0, 80, 80, QRegion::Ellipse); widget->setMask(region); window->setMask(region); } if (opacity) { widget->setWindowOpacity(0.5); window->setOpacity(0.5); } widget->show(); window->show(); } return app.exec(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); GLWindow *window = new GLWindow(QGLFormat()); window->show(); return app.exec(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); GLWindow w; w.show(); return a.exec(); }
int main( int argc, char ** argv ) { Q_INIT_RESOURCE(texture); QGuiApplication a( argc, argv ); GLWindow window; window.show(); return a.exec(); }
int main(int argc, char** argv) { auto glversion = gl::getAvailableVersion(); auto major = GL_GET_MAJOR_VERSION(glversion); auto minor = GL_GET_MINOR_VERSION(glversion); if (glversion < GL_MAKE_VERSION(4, 1)) { MessageBoxA(nullptr, "Interface requires OpenGL 4.1 or higher", "Unsupported", MB_OK); return 0; } QGuiApplication app(argc, argv); bool quitting = false; // FIXME need to handle window closing message so that we can stop the timer GLWindow* window = new GLWindow(); window->create(); window->show(); window->setSurfaceType(QSurface::OpenGLSurface); window->setFormat(getDefaultOpenGLSurfaceFormat()); bool contextCreated = false; QTimer* timer = new QTimer(); QObject::connect(timer, &QTimer::timeout, [&] { if (quitting) { return; } if (!contextCreated) { window->createContext(); contextCreated = true; } if (!window->makeCurrent()) { throw std::runtime_error("Failed"); } glClearColor(1.0f, 0.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); window->swapBuffers(); window->doneCurrent(); }); // FIXME need to handle window closing message so that we can stop the timer QObject::connect(&app, &QCoreApplication::aboutToQuit, [&] { quitting = true; QObject::disconnect(timer, &QTimer::timeout, nullptr, nullptr); timer->stop(); timer->deleteLater(); }); timer->setInterval(15); timer->setSingleShot(false); timer->start(); app.exec(); return 0; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QSurfaceFormat fmt; fmt.setDepthBufferSize(24); // fmt.setVersion(3, 3); // fmt.setProfile(QSurfaceFormat::CoreProfile); QSurfaceFormat::setDefaultFormat(fmt); GLWindow w; w.show(); return a.exec(); }