int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); QSurfaceFormat fmt; fmt.setSamples(4); QSurfaceFormat::setDefaultFormat(fmt); Window window; window.show(); return app.exec(); }
QSurfaceFormat EGLDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const { QSurfaceFormat format = inputFormat; static const bool force888 = qEnvironmentVariableIntValue("GREENISLAND_QPA_FORCE888"); if (force888) { format.setRedBufferSize(8); format.setGreenBufferSize(8); format.setBlueBufferSize(8); } return format; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QSurfaceFormat format; format.setDepthBufferSize( 4 ); format.setSamples(24); format.setRenderableType(QSurfaceFormat::OpenGL); a.setStyle(QStyleFactory::create("Android")); MainWindow w; w.showMaximized(); return a.exec(); }
int main(int argc, char *argv[]) { QGuiApplication a(argc,argv); Window w; QSurfaceFormat f = w.requestedFormat(); f.setMajorVersion(3); f.setMinorVersion(3); w.setFormat(f); w.setWidth(640); w.setHeight(480); w.show(); return a.exec(); }
int main(int argc, char* argv[]) { QSurfaceFormat format; format.setRenderableType(QSurfaceFormat::OpenGL); format.setProfile(QSurfaceFormat::CoreProfile); format.setVersion(3,3); Magick::InitializeMagick(*argv); QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
bool QOpenGLFunctions_3_2_Compatibility::isContextCompatible(QOpenGLContext *context) { Q_ASSERT(context); QSurfaceFormat f = context->format(); const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion()); if (v < qMakePair(3, 2)) return false; if (f.profile() == QSurfaceFormat::CoreProfile) return false; return true; }
QSurfaceFormat QEglFSHooks::surfaceFormatFor(const QSurfaceFormat &inputFormat) const { QSurfaceFormat format = inputFormat; static const bool force888 = qgetenv("QT_QPA_EGLFS_FORCE888").toInt(); if (force888) { format.setRedBufferSize(8); format.setGreenBufferSize(8); format.setBlueBufferSize(8); } return format; }
GLView::GLView(int textureWidth, int textureHeight, std::function<void(GLView *)> initCallback) : QOpenGLWidget(), _textureWidth(textureWidth), _textureHeight(textureHeight) { #if __APPLE__ QSurfaceFormat glFormat; glFormat.setVersion( 3, 3 ); glFormat.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile); glFormat.setSwapBehavior(QSurfaceFormat::SwapBehavior::SingleBuffer); glFormat.setSwapInterval(0); setFormat(glFormat); #endif _initCallback = initCallback; }
static void app_init_open_gl() { if(app_open_gl_initialized == 0) { QSurfaceFormat format; format.setDepthBufferSize(24); format.setStencilBufferSize(8); format.setVersion(3, 2); format.setProfile(QSurfaceFormat::CoreProfile); QSurfaceFormat::setDefaultFormat(format); app_open_gl_initialized = 1; } }
int main( int argc, char ** argv ) { QApplication a( argc, argv ); QSurfaceFormat format; format.setDepthBufferSize(16); QSurfaceFormat::setDefaultFormat(format); // Two top-level windows with two QOpenGLWidget children in each. // The rendering for the four QOpenGLWidgets happens on four separate threads. GLWidget topLevelGlWidget; QPoint pos = QApplication::desktop()->availableGeometry(&topLevelGlWidget).topLeft() + QPoint(200, 200); topLevelGlWidget.setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example top level")); topLevelGlWidget.resize(200, 200); topLevelGlWidget.move(pos); topLevelGlWidget.show(); const QString glInfo = getGlString(topLevelGlWidget.context()->functions(), GL_VENDOR) + QLatin1Char('/') + getGlString(topLevelGlWidget.context()->functions(), GL_RENDERER); const bool supportsThreading = !glInfo.contains(QLatin1String("nouveau"), Qt::CaseInsensitive) && !glInfo.contains(QLatin1String("ANGLE"), Qt::CaseInsensitive) && !glInfo.contains(QLatin1String("llvmpipe"), Qt::CaseInsensitive); const QString toolTip = supportsThreading ? glInfo : glInfo + QStringLiteral("\ndoes not support threaded OpenGL."); topLevelGlWidget.setToolTip(toolTip); QScopedPointer<MainWindow> mw1; QScopedPointer<MainWindow> mw2; if (!QApplication::arguments().contains(QStringLiteral("--single"))) { if (supportsThreading) { pos += QPoint(100, 100); mw1.reset(new MainWindow); mw1->setToolTip(toolTip); mw1->move(pos); mw1->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #1")); mw1->show(); pos += QPoint(100, 100); mw2.reset(new MainWindow); mw2->setToolTip(toolTip); mw2->move(pos); mw2->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #2")); mw2->show(); } else { qWarning() << toolTip; } } return a.exec(); }
ListControll::ListControll(QObject *parent) : QObject(parent), QQuickImageProvider(QQuickImageProvider::Image) { resetProjectToDefault(); /* QList <QString> temp; temp.append("1"); temp.append("2"); temp.append("3"); temp.append("4"); temp.append("5"); temp.append("6"); test.append(temp); QList <int> temp_int; temp_int.append(200); temp_int.append(200); temp_int.append(200); temp_int.append(200); temp_int.append(200); temp_int.append(200); testWidth.append(temp_int); */ if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {\ QSurfaceFormat f = view.format();\ f.setProfile(QSurfaceFormat::CoreProfile);\ f.setVersion(4, 4);\ view.setFormat(f);\ }\ // view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit())); new QQmlFileSelector(view.engine(), &view);\ view.engine()->rootContext()->setContextProperty("timeControll", this); view.engine()->rootContext()->setContextProperty("viewerWidget", &view); cloneImg = new ImageClone(this); view.engine()->addImageProvider("imageProvider", cloneImg);//&image_provider); view.setSource(QUrl("qrc:/main.qml")); \ view.setResizeMode(QQuickView::SizeRootObjectToView); view.setPersistentOpenGLContext(true); view.setColor("transparent"); view.setMinimumHeight(205); view.setMinimumWidth(500); view.setHeight(view.minimumHeight()); view.setWidth(800); view.setFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::WindowTitleHint); //view.setMaximumHeight(215); //loadCurrentTextInTheFirstBlockWhenInit(); }
int KisOpenGL::initializeContext(QOpenGLContext* s) { #ifdef HAVE_OPENGL KisConfig cfg; dbgUI << "OpenGL: Opening new context"; // Double check we were given the version we requested QSurfaceFormat format = s->format(); glVersion = 100 * format.majorVersion() + format.minorVersion(); if (!SharedSurface) { SharedSurface = new QOffscreenSurface(); SharedSurface->setFormat(format); SharedSurface->create(); } if (!SharedContext) { SharedContext = new QOpenGLContext; SharedContext->setFormat(format); SharedContext->setShareContext(s); SharedContext->create(); SharedContext->makeCurrent(SharedSurface); } QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); QFile log(QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/krita-opengl.txt"); log.open(QFile::WriteOnly); QString vendor((const char*)f->glGetString(GL_VENDOR)); log.write(vendor.toLatin1()); log.write(", "); QString renderer((const char*)f->glGetString(GL_RENDERER)); log.write(renderer.toLatin1()); log.write(", "); QString version((const char*)f->glGetString(GL_VERSION)); log.write(version.toLatin1()); // Check if we have a bugged driver that needs fence workaround bool isOnX11 = false; #ifdef HAVE_X11 isOnX11 = true; #endif if ((isOnX11 && renderer.startsWith("AMD")) || cfg.forceOpenGLFenceWorkaround()) { NeedsFenceWorkaround = true; } #else Q_UNUSED(s); NeedsFenceWorkaround = false; #endif return glVersion; }
void debugFormatVersion() { QSurfaceFormat form = QSurfaceFormat::defaultFormat(); QSurfaceFormat::OpenGLContextProfile prof = form.profile(); const char *profile = prof == QSurfaceFormat::CoreProfile ? "Core" : prof == QSurfaceFormat::CompatibilityProfile ? "Compatibility" : "None"; printf("Requested format:\n"); printf(" Version: %d.%d\n", form.majorVersion(), form.minorVersion()); printf(" Profile: %s\n", profile); }
int main(int argc, char **argv) { QGuiApplication app(argc, argv); // create an OpenGL format specifier QSurfaceFormat format; // set the number of samples for multisampling // will need to enable glEnable(GL_MULTISAMPLE); once we have a context format.setSamples(4); #if defined( DARWIN) // at present mac osx Mountain Lion only supports GL3.2 // the new mavericks will have GL 4.x so can change format.setMajorVersion(4); format.setMinorVersion(1); #else // with luck we have the latest GL version so set to this format.setMajorVersion(4); format.setMinorVersion(3); #endif // now we are going to set to CoreProfile OpenGL so we can't use and old Immediate mode GL format.setProfile(QSurfaceFormat::CoreProfile); // now set the depth buffer to 24 bits format.setDepthBufferSize(24); QSurfaceFormat::setDefaultFormat(format); // now we are going to create our scene window OpenGLWindow window; // set the window size window.resize(1024, 720); // and finally show window.show(); return app.exec(); }
int main(int argc, char **argv) { // create an OpenGL format specifier QSurfaceFormat format; // set the number of samples for multisampling // will need to enable glEnable(GL_MULTISAMPLE); once we have a context format.setSamples(4); #if defined( DARWIN) // at present mac osx Mountain Lion only supports GL3.2 // the new mavericks will have GL 4.x so can change format.setMajorVersion(4); format.setMinorVersion(2); #else // with luck we have the latest GL version so set to this format.setMajorVersion(4); format.setMinorVersion(3); #endif // now we are going to set to CoreProfile OpenGL so we can't use and old Immediate mode GL format.setProfile(QSurfaceFormat::CoreProfile); // now set the depth buffer to 24 bits format.setDepthBufferSize(24); // this will set the format for all widgets QSurfaceFormat::setDefaultFormat(format); // make an instance of the QApplication CebApplication a(argc, argv); // Create a new MainWindow MainWindow w; // show main window w.show(); // show start dialog w.showStartDialog(); // hand control over to Qt framework return a.exec(); }
int main(int argc, char **argv) { QGuiApplication app(argc, argv); // create an OpenGL format specifier QSurfaceFormat format; // set the number of samples for multisampling // will need to enable glEnable(GL_MULTISAMPLE); once we have a context format.setSamples(4); format.setMajorVersion(3); format.setMinorVersion(2); // now we are going to set to Compat Profile OpenGL so we can use and old Immediate mode GL format.setProfile(QSurfaceFormat::CompatibilityProfile); // now set the depth buffer to 24 bits format.setDepthBufferSize(24); QSurfaceFormat::setDefaultFormat(format); // now we are going to create our scene window OpenGLWindow window; // we can now query the version to see if it worked std::cout<<"Profile is "<<format.majorVersion()<<" "<<format.minorVersion()<<"\n"; // set the window size window.resize(1024, 720); // and finally show window.show(); return app.exec(); }
static PIXELFORMATDESCRIPTOR qPixelFormatFromSurfaceFormat(const QSurfaceFormat &format, const QWindowsOpenGLAdditionalFormat &additional) { PIXELFORMATDESCRIPTOR pfd; initPixelFormatDescriptor(&pfd); pfd.iPixelType = PFD_TYPE_RGBA; pfd.iLayerType = PFD_MAIN_PLANE; pfd.dwFlags = PFD_SUPPORT_OPENGL; if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) pfd.dwFlags = PFD_SUPPORT_COMPOSITION; const bool isPixmap = (additional.formatFlags & QWindowsGLRenderToPixmap) != 0; pfd.dwFlags |= isPixmap ? PFD_DRAW_TO_BITMAP : PFD_DRAW_TO_WINDOW; if (!(additional.formatFlags & QWindowsGLDirectRendering)) pfd.dwFlags |= PFD_GENERIC_FORMAT; if (format.stereo()) pfd.dwFlags |= PFD_STEREO; if (format.swapBehavior() == QSurfaceFormat::DoubleBuffer && !isPixmap) pfd.dwFlags |= PFD_DOUBLEBUFFER; pfd.cDepthBits = format.depthBufferSize() >= 0 ? format.depthBufferSize() : 32; pfd.cAlphaBits = format.alphaBufferSize() > 0 ? format.alphaBufferSize() : 8; pfd.cStencilBits = format.stencilBufferSize() > 0 ? format.stencilBufferSize() : 8; if (additional.formatFlags & QWindowsGLAccumBuffer) pfd.cAccumRedBits = pfd.cAccumGreenBits = pfd.cAccumBlueBits = pfd.cAccumAlphaBits = 16; return pfd; }
int main(int argc, char** argv) { QApplication app(argc, argv); QSurfaceFormat format = QSurfaceFormat::defaultFormat(); format.setVersion(3, 3); format.setProfile(QSurfaceFormat::CoreProfile); format.setOption(QSurfaceFormat::DeprecatedFunctions, false); QSurfaceFormat::setDefaultFormat(format); MainGUI gui; gui.showMaximized(); return app.exec(); }
int main(int argc, char** argv) { Q_INIT_RESOURCE(texture); QApplication a(argc, argv); QSurfaceFormat format; format.setVersion(3,3); format.setProfile(QSurfaceFormat::CoreProfile); QSurfaceFormat::setDefaultFormat(format); GLWidget glwidget; glwidget.show(); return a.exec(); }
int main(int argc, char *argv[]) { srand (static_cast <unsigned> (time(0))); QApplication app(argc, argv); QSurfaceFormat fmt; fmt.setSamples(4); QSurfaceFormat::setDefaultFormat(fmt); Window window; window.show(); return app.exec(); }
QT_BEGIN_NAMESPACE QShapedPixmapWindow::QShapedPixmapWindow() : QWindow(), m_backingStore(0) { QSurfaceFormat format; format.setAlphaBufferSize(8); setFormat(format); setSurfaceType(RasterSurface); setFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint | Qt::WindowTransparentForInput); create(); m_backingStore = new QBackingStore(this); }
GLWidget::GLWidget(QWidget *parent) : QOpenGLWidget(parent), m_xRot(0), m_yRot(0), m_zRot(0), m_program(0), m_elementBuffer(QOpenGLBuffer::IndexBuffer), m_obj(), color(1.0f,1.0f,1.0f) { QSurfaceFormat fmt = format(); fmt.setAlphaBufferSize(8); setFormat(fmt); }
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(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QSurfaceFormat format; format.setSamples(4); format.setVersion(4,0); format.setProfile(QSurfaceFormat::CoreProfile); QSurfaceFormat::setDefaultFormat(format); MainWindow w; w.show(); return a.exec(); }
int main(int argc, char **argv) { QApplication app(argc, argv); QSurfaceFormat format = QSurfaceFormat::defaultFormat(); format.setVersion(3, 3); format.setProfile(QSurfaceFormat::CoreProfile); format.setOption(QSurfaceFormat::DeprecatedFunctions, false); QSurfaceFormat::setDefaultFormat(format); OGLWidget widget; widget.resize(800, 600); widget.show(); return app.exec(); }
//! [1] int main(int argc, char **argv) { QGuiApplication app(argc, argv); qmlRegisterType<BezierCurve>("CustomGeometry", 1, 0, "BezierCurve"); QQuickView view; QSurfaceFormat format = view.format(); format.setSamples(16); view.setFormat(format); view.setSource(QUrl("qrc:///scenegraph/customgeometry/main.qml")); view.show(); app.exec(); }
ContextPoolContext::ContextPoolContext(QOpenGLContext* share_context, bool reserved) : reserved(reserved), count(0), surface(NULL), context(NULL) { QSurfaceFormat format; format.setMajorVersion(3); format.setMinorVersion(2); format.setSwapInterval(0); format.setSwapBehavior(QSurfaceFormat::SingleBuffer); format.setRenderableType(QSurfaceFormat::OpenGL); format.setProfile(QSurfaceFormat::CoreProfile); format.setOption(QSurfaceFormat::DebugContext); surface = new QOffscreenSurface(); surface->setFormat(format); surface->create(); if (!surface->isValid()) { throw; } context = new QOpenGLContext(); context->setShareContext(share_context); context->setFormat(surface->requestedFormat()); if (!context->create()) { throw; } context->makeCurrent(surface); gl = context->versionFunctions<QOpenGLFunctions_3_2_Core>(); if (gl == nullptr || !gl->initializeOpenGLFunctions()) { throw; } indirect = new QOpenGLExtension_ARB_multi_draw_indirect(); if (!indirect->initializeOpenGLFunctions()) { throw; } vab = new QOpenGLExtension_ARB_vertex_attrib_binding(); if (!vab->initializeOpenGLFunctions()) { throw; } sso = new QOpenGLExtension_ARB_separate_shader_objects(); if (!sso->initializeOpenGLFunctions()) { throw; } tex = new QOpenGLExtension_ARB_texture_buffer_object(); if (!tex->initializeOpenGLFunctions()) { throw; } buffer = (QOpenGLExtension_ARB_buffer_storage)context->getProcAddress("glBufferStorage"); debug = new QOpenGLExtension_ARB_debug_output(); if (!debug->initializeOpenGLFunctions()) { throw; } debug->glDebugMessageCallbackARB(debug_callback, nullptr); debug->glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, 0, GL_FALSE); debug->glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, 0, GL_TRUE); context->doneCurrent(); context->moveToThread(nullptr); }
static HGLRC createContext(const QOpenGLStaticContext &staticContext, HDC hdc, const QSurfaceFormat &format, const QWindowsOpenGLAdditionalFormat &, HGLRC shared = 0) { enum { attribSize = 11 }; if (!staticContext.hasExtensions()) return 0; int attributes[attribSize]; int attribIndex = 0; qFill(attributes, attributes + attribSize, int(0)); const int requestedVersion = (format.majorVersion() << 8) + format.minorVersion(); if (requestedVersion > 0x0101) { attributes[attribIndex++] = WGL_CONTEXT_MAJOR_VERSION_ARB; attributes[attribIndex++] = format.majorVersion(); attributes[attribIndex++] = WGL_CONTEXT_MINOR_VERSION_ARB; attributes[attribIndex++] = format.minorVersion(); } if (requestedVersion >= 0x0300) { attributes[attribIndex++] = WGL_CONTEXT_FLAGS_ARB; attributes[attribIndex] = 0; if (format.testOption(QSurfaceFormat::DeprecatedFunctions)) attributes[attribIndex] |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; if (format.testOption(QSurfaceFormat::DebugContext)) attributes[attribIndex++] |= WGL_CONTEXT_DEBUG_BIT_ARB; attribIndex++; } if (requestedVersion >= 0x0302) { switch (format.profile()) { case QSurfaceFormat::NoProfile: break; case QSurfaceFormat::CoreProfile: attributes[attribIndex++] = WGL_CONTEXT_PROFILE_MASK_ARB; attributes[attribIndex++] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; break; case QSurfaceFormat::CompatibilityProfile: attributes[attribIndex++] = WGL_CONTEXT_PROFILE_MASK_ARB; attributes[attribIndex++] = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; break; } } if (QWindowsContext::verboseGL) qDebug("%s: Creating context version %d.%d with %d attributes", __FUNCTION__, format.majorVersion(), format.minorVersion(), attribIndex / 2); const HGLRC result = staticContext.wglCreateContextAttribsARB(hdc, shared, attributes); if (!result) qErrnoWarning("%s: wglCreateContextAttribsARB() failed.", __FUNCTION__); return result; }
int main(int argc, char *argv[]) { QSurfaceFormat format; format.setMajorVersion( 4 ); format.setMinorVersion( 1 ); format.setProfile( QSurfaceFormat::CoreProfile ); QSurfaceFormat::setDefaultFormat(format); QApplication a(argc, argv); MainWindow m; m.show(); return a.exec(); }
int main(int argc, char **argv) { QGuiApplication app(argc, argv); QSurfaceFormat format; format.setSamples(16); TriangleWindow window; window.setFormat(format); window.resize(640, 480); window.show(); window.setAnimating(true); return app.exec(); }