void KisOpenGL::initialize() { #ifdef HAVE_OPENGL dbgUI << "OpenGL: initializing"; KisConfig cfg; QSurfaceFormat format; format.setProfile(QSurfaceFormat::CompatibilityProfile); format.setOptions(QSurfaceFormat::DeprecatedFunctions); format.setDepthBufferSize(24); format.setStencilBufferSize(8); format.setVersion(3, 2); // if (cfg.disableDoubleBuffering()) { if (false) { format.setSwapBehavior(QSurfaceFormat::SingleBuffer); } else { format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); } format.setSwapInterval(0); // Disable vertical refresh syncing QSurfaceFormat::setDefaultFormat(format); #endif }
QSurfaceFormat qglx_reduceSurfaceFormat(const QSurfaceFormat &format, bool *reduced) { QSurfaceFormat retFormat = format; *reduced = true; if (retFormat.redBufferSize() > 1) { retFormat.setRedBufferSize(1); } else if (retFormat.greenBufferSize() > 1) { retFormat.setGreenBufferSize(1); } else if (retFormat.blueBufferSize() > 1) { retFormat.setBlueBufferSize(1); } else if (retFormat.samples() > 1) { retFormat.setSamples(qMin(retFormat.samples() / 2, 16)); } else if (retFormat.stereo()) { retFormat.setStereo(false); }else if (retFormat.stencilBufferSize() > 0) { retFormat.setStencilBufferSize(0); }else if (retFormat.hasAlpha()) { retFormat.setAlphaBufferSize(0); }else if (retFormat.depthBufferSize() > 0) { retFormat.setDepthBufferSize(0); }else if (retFormat.swapBehavior() != QSurfaceFormat::SingleBuffer) { retFormat.setSwapBehavior(QSurfaceFormat::SingleBuffer); }else{ *reduced = false; } return retFormat; }
OGLViewer::OGLViewer(QWidget *parent) : QOpenGLWidget(parent), mTimeCount(0), mFps(30) , mSelectMode(OBJECT_SELECT) , mViewCamera(new PerspectiveCamera(Point3f(10, 6, 11), Point3f(0, 0, 0), Vector3f(0, 1, 0), width() / float(height()))) , box_mesh(new TriangleMesh("../../scene/obj/cube_large.obj")) , model_mesh(new TriangleMesh("../../scene/obj/monkey.obj")) { // Set surface format for current widget QSurfaceFormat format; format.setDepthBufferSize(32); format.setStencilBufferSize(8); format.setSamples(4); format.setVersion(4, 5); format.setProfile(QSurfaceFormat::CoreProfile); this->setFormat(format); // Link timer trigger /*process_time.start(); QTimer *timer = new QTimer(this); //timer->setSingleShot(false); connect(timer, SIGNAL(timeout()), this, SLOT(update())); timer->start(0);*/ }
OGLViewer::OGLViewer(QWidget *parent) : QOpenGLWidget(parent), tcount(0), fps(30) , simp_lv(1) , m_selectMode(OBJECT_SELECT) { // Set surface format for current widget QSurfaceFormat format; format.setDepthBufferSize(32); format.setStencilBufferSize(8); format.setVersion(4, 5); format.setProfile(QSurfaceFormat::CoreProfile); this->setFormat(format); // Read obj file //box_mesh = new Mesh("../../scene/obj/cube_large.obj"); //model_mesh = new Mesh("../../scene/obj/monkey.obj"); #ifdef _DEBUG hds_box = new HDS_Mesh("../../scene/obj/frog.obj"); #else hds_box = new HDS_Mesh("quad_cube.obj"); #endif //hds_box->reIndexing(); //hds_box->validate(); simp_mesh = new Simplification(simp_lv, hds_box); resetCamera(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QApplication::setApplicationName("Editor"); QApplication::setApplicationVersion("1.0"); #if C3_OS == C3_OS_WINDOWS_NT //Windows native theme looks so ugly app.setStyle("fusion"); #endif QCommandLineParser parser; parser.setApplicationDescription("The Editor"); parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption dataDirOption("root", "Root directory location.\nThis will override ENGINE_ROOT.", "path"); parser.addOption(dataDirOption); parser.process(app); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QString absPath; if(!parser.value(dataDirOption).isEmpty()) { absPath = parser.value(dataDirOption); } else if(env.contains("ENGINE_ROOT")) absPath = env.value("ENGINE_ROOT"); else absPath = "."; QFileInfo dirInfo(absPath); if(!dirInfo.exists() || !dirInfo.isDir() || !QFileInfo::exists(absPath + "/Data")) { const char* msg = "Invalid root directory!"; QMessageBox::critical(nullptr, app.applicationName(), msg); throw msg; } absPath = dirInfo.canonicalFilePath(); EngineLoader.SetRootDirectory(absPath.toUtf8().constData()); c3::RC.Loader = &EngineLoader; c3::RC.Loader->InitEngine(); c3::FEditor EditorController; c3::RC.Editor = &EditorController; QSurfaceFormat format; format.setVersion(4, 5); format.setProfile(QSurfaceFormat::CoreProfile); format.setDepthBufferSize(24); format.setStencilBufferSize(8); QSurfaceFormat::setDefaultFormat(format); MainWindow mainWindow; c3::FLogDisplay* LogDisplay = static_cast<c3::FLogDisplay*>(EditorController.GetLogDisplay()); QObject::connect(LogDisplay, &c3::FLogDisplay::LogRefreshed, &mainWindow, &MainWindow::OnLogChanged); mainWindow.showMaximized(); app.exec(); }
static QSurfaceFormat qSurfaceFormatFromPixelFormat(const PIXELFORMATDESCRIPTOR &pfd, QWindowsOpenGLAdditionalFormat *additionalIn = 0) { QSurfaceFormat format; if (pfd.dwFlags & PFD_DOUBLEBUFFER) format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); format.setDepthBufferSize(pfd.cDepthBits); if (pfd.iPixelType == PFD_TYPE_RGBA) format.setAlphaBufferSize(pfd.cAlphaBits); format.setRedBufferSize(pfd.cRedBits); format.setGreenBufferSize(pfd.cGreenBits); format.setBlueBufferSize(pfd.cBlueBits); format.setStencilBufferSize(pfd.cStencilBits); format.setStereo(pfd.dwFlags & PFD_STEREO); if (additionalIn) { QWindowsOpenGLAdditionalFormat additional; if (isDirectRendering(pfd)) additional.formatFlags |= QWindowsGLDirectRendering; if (hasGLOverlay(pfd)) additional.formatFlags |= QWindowsGLOverlay; if (pfd.cAccumRedBits) additional.formatFlags |= QWindowsGLAccumBuffer; if (testFlag(pfd.dwFlags, PFD_DRAW_TO_BITMAP)) { additional.formatFlags |= QWindowsGLRenderToPixmap; additional.pixmapDepth = pfd.cColorBits; } *additionalIn = additional; } return format; }
SsvepBciScreen::SsvepBciScreen(QSharedPointer<SsvepBci> pSsvepBci, QSharedPointer<SsvepBciSetupStimulusWidget> pSsvepBciSetupStimulusWidget, QOpenGLWidget *parent) : m_pSsvepBci(pSsvepBci) , m_pSsvepBciSetupStimulusWidget(pSsvepBciSetupStimulusWidget) , m_pScreenKeyboard(QSharedPointer<ScreenKeyboard>(new ScreenKeyboard(m_pSsvepBci, m_pSsvepBciSetupStimulusWidget, QSharedPointer<SsvepBciScreen>(this)))) , m_dXPosCross(0.5) , m_dYPosCross(0.5) , m_dStep(0.01) , m_bUseScreenKeyboard(false) , m_qPainter(this) , m_qCrossColor(Qt::red) , m_bClearScreen(true) { Q_UNUSED(parent); // register Meta Type qRegisterMetaType<MyQList>("MyQList"); //set format of the QOpenGLWidget (enable vsync and setup buffers) QSurfaceFormat format; format.setDepthBufferSize(24); format.setStencilBufferSize(8); format.setSwapInterval(1); setFormat(format); // set update behaviour to preserved-swap-buffer setUpdateBehavior(UpdateBehavior::PartialUpdate); // connect classResult and frequency list signal of SsvepBci class to setClassResult slot connect(m_pSsvepBci.data(), &SsvepBci::classificationResult, this, &SsvepBciScreen::setClassResults); connect(m_pSsvepBci.data(), &SsvepBci::getFrequencyLabels, this, &SsvepBciScreen::updateFrequencyList); // initialize freqList m_lFreqList << 6.66 << 7.5 << 8.57 << 10 << 12; }
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() { static QSurfaceFormat format; static std::once_flag once; std::call_once(once, [] { #if defined(USE_GLES) format.setRenderableType(QSurfaceFormat::OpenGLES); format.setRedBufferSize(8); format.setGreenBufferSize(8); format.setBlueBufferSize(8); format.setAlphaBufferSize(8); #else format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); #endif if (gl::Context::enableDebugLogger()) { format.setOption(QSurfaceFormat::DebugContext); } // Qt Quick may need a depth and stencil buffer. Always make sure these are available. format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS); format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS); int major, minor; ::gl::getTargetVersion(major, minor); format.setMajorVersion(major); format.setMinorVersion(minor); }); return format; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); Q_INIT_RESOURCE(ARehab_vTerapeuta); QSurfaceFormat format; format.setVersion(4, 3); format.setProfile(QSurfaceFormat::CoreProfile); format.setOption(QSurfaceFormat::DebugContext); format.setRenderableType(QSurfaceFormat::OpenGL); format.setDepthBufferSize(24); format.setStencilBufferSize(8); format.setSamples(4); format.setSwapInterval(0); //Disable VSync QSurfaceFormat::setDefaultFormat(format); ARehabGUIDesigner::ARehabMainWindow w; QFile styleFile(":/styles/main.qss"); styleFile.open(QFile::ReadOnly); app.setStyleSheet(QLatin1String(styleFile.readAll())); styleFile.close(); w.show(); return (app.exec()); }
void ccApplication::init() { //See http://doc.qt.io/qt-5/qopenglwidget.html#opengl-function-calls-headers-and-qopenglfunctions /** Calling QSurfaceFormat::setDefaultFormat() before constructing the QApplication instance is mandatory on some platforms (for example, OS X) when an OpenGL core profile context is requested. This is to ensure that resource sharing between contexts stays functional as all internal contexts are created using the correct version and profile. **/ { QSurfaceFormat format = QSurfaceFormat::defaultFormat(); format.setSwapBehavior( QSurfaceFormat::DoubleBuffer ); format.setStencilBufferSize( 0 ); #ifdef CC_GL_WINDOW_USE_QWINDOW format.setStereo( true ); #endif #ifdef Q_OS_MAC format.setVersion( 2, 1 ); // must be 2.1 - see ccGLWindow::functions() format.setProfile( QSurfaceFormat::CoreProfile ); #endif #ifdef QT_DEBUG format.setOption( QSurfaceFormat::DebugContext, true ); #endif QSurfaceFormat::setDefaultFormat( format ); } // The 'AA_ShareOpenGLContexts' attribute must be defined BEFORE the creation of the Q(Gui)Application // DGM: this is mandatory to enable exclusive full screen for ccGLWidget (at least on Windows) QCoreApplication::setAttribute( Qt::AA_ShareOpenGLContexts ); }
void QMinimalEglScreen::createAndSetPlatformContext() { QSurfaceFormat platformFormat; QByteArray depthString = qgetenv("QT_QPA_EGLFS_DEPTH"); if (depthString.toInt() == 16) { platformFormat.setDepthBufferSize(16); platformFormat.setRedBufferSize(5); platformFormat.setGreenBufferSize(6); platformFormat.setBlueBufferSize(5); m_depth = 16; m_format = QImage::Format_RGB16; } else { platformFormat.setDepthBufferSize(24); platformFormat.setStencilBufferSize(8); platformFormat.setRedBufferSize(8); platformFormat.setGreenBufferSize(8); platformFormat.setBlueBufferSize(8); m_depth = 32; m_format = QImage::Format_RGB32; } if (!qEnvironmentVariableIsEmpty("QT_QPA_EGLFS_MULTISAMPLE")) platformFormat.setSamples(4); EGLConfig config = q_configFromGLFormat(m_dpy, platformFormat); EGLNativeWindowType eglWindow = 0; #ifdef Q_OPENKODE if (kdInitializeNV() == KD_ENOTINITIALIZED) { qFatal("Did not manage to initialize openkode"); } KDWindow *window = kdCreateWindow(m_dpy,config,0); kdRealizeWindow(window,&eglWindow); #endif #ifdef QEGL_EXTRA_DEBUG q_printEglConfig(m_dpy, config); #endif m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL); if (m_surface == EGL_NO_SURFACE) { qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError()); eglTerminate(m_dpy); qFatal("EGL error"); } // qWarning("Created surface %dx%d\n", w, h); QEGLPlatformContext *platformContext = new QMinimalEglContext(platformFormat, 0, m_dpy); m_platformContext = platformContext; EGLint w,h; // screen size detection eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w); eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h); m_geometry = QRect(0,0,w,h); }
OGLViewer::OGLViewer(QWidget *parent) : QOpenGLWidget(parent), tcount(0) , fps(30), timestep(1.0 / fps), isSim(false) { // Set surface format for current widget QSurfaceFormat format; format.setDepthBufferSize(32); format.setStencilBufferSize(8); format.setVersion(4, 5); format.setProfile(QSurfaceFormat::CoreProfile); this->setFormat(format); // Link timer trigger process_time.start(); QTimer *timer = new QTimer(this); /*timer->setSingleShot(false);*/ connect(timer, SIGNAL(timeout()), this, SLOT(update())); timer->start(0); // Read obj file #ifdef _DEBUG box_mesh = new Mesh("../../scene/obj/cube_huge.obj"); poly_mesh = new Mesh("../../scene/obj/bunny_simple.obj"); poly_bound = new Mesh("../../scene/obj/bunny_bound.obj"); #else box_mesh = new Mesh("cube_large.obj"); poly_mesh = new Mesh("bunny_simple.obj"); poly_bound = new Mesh("bunny_bound.obj"); #endif // _DEBUG poly_bound->refine(triangleList); mytree = new KdTreeAccel(triangleList); texW = sparkTex.getWidth(); texH = sparkTex.getHeight(); sparkTex.getPixelsRGBA(tex_pixels); // Initialize particle generators //Point3D newpos(0.0, 0.0, 0.0), vel(0.3, 1.0, 1.0), vel_var(0.3, 0.3, 0.3); ParticleGenerator* pg = new ParticleGenerator( 3500, 1000, 20, timestep, 3, 0.6, 2.0, 1.2, Point3D(0.0, 5.0, 0.0), Vector3D(0, -10, 0), Vector3D(1, 0, 0), ParticleGenerator::CONCENTRIC_DISK, 0.5); Vector3D* gravity = new Vector3D(0.0, -9.8, 0.0); Vector3D* wind = new Vector3D(0, 0.0, 0.0); pg->addForce(gravity); pg->addForce(wind); pgs.push_back(pg); pg->exportVBO(ptc_size, ptc_verts, ptc_vels, ptc_life, ptc_alive, true); pg->addCollision(mytree); resetCamera(); // Initialize transform matrix matrix.setIdentity();// setRotation(20, 0, 0); matrix.exportVBO(model_mat); }
int main(int argc, char* argv[]) { // read the header const auto header = sepia::read_header(sepia::filename_to_ifstream(filename)); // create the Qt Application QGuiApplication app(argc, argv); // register Chameleon types qmlRegisterType<chameleon::background_cleaner>("Chameleon", 1, 0, "BackgroundCleaner"); qmlRegisterType<chameleon::dvs_display>("Chameleon", 1, 0, "DvsDisplay"); qmlRegisterType<chameleon::flow_display>("Chameleon", 1, 0, "FlowDisplay"); // pass the header properties to qml QQmlApplicationEngine application_engine; application_engine.rootContext()->setContextProperty("header_width", header.width); application_engine.rootContext()->setContextProperty("header_height", header.height); // load the view and setup the window properties for OpenGL renderring application_engine.loadData( #include "optical_flow.qml" ); auto window = qobject_cast<QQuickWindow*>(application_engine.rootObjects().first()); { QSurfaceFormat format; format.setDepthBufferSize(24); format.setStencilBufferSize(8); format.setVersion(3, 3); format.setProfile(QSurfaceFormat::CoreProfile); window->setFormat(format); } // retrieve pointers to the displays generated by qml auto dvs_display = window->findChild<chameleon::dvs_display*>("dvs_display"); auto flow_display = window->findChild<chameleon::flow_display*>("flow_display"); // create the event handling pipeline auto observable = sepia::make_observable<sepia::type::dvs>( sepia::filename_to_ifstream(filename), tarsier::make_replicate<sepia::dvs_event>( [&](sepia::dvs_event dvs_event) { dvs_display->push(dvs_event); }, sepia::make_split<sepia::type::dvs>( tarsier::make_compute_flow<sepia::simple_event, flow_event>( header.width, header.height, 3, // spatial window's radius 10000, // temporal window 8, // minimum number of events in the spatio-temporal window required to trigger a flow event [&](sepia::simple_event simple_event, float vx, float vy) -> flow_event { return {simple_event.t, simple_event.x, simple_event.y, vx, vy}; }, [&](flow_event flow_event) { flow_display->push(flow_event); }), [](sepia::simple_event) {})), [](std::exception_ptr) {}, []() { return true; }); // run the Qt Application return app.exec(); }
void MainWindow::updateView() { QSurfaceFormat format; format.setDepthBufferSize(16); format.setStencilBufferSize(8); if (m_transparent) format.setAlphaBufferSize(8); if (m_checkboxMultiSample->isChecked()) format.setSamples(4); State state = m_radioView->isChecked() ? UseWindow : UseWidget; if (m_format == format && m_state == state) return; m_format = format; m_state = state; QString text = m_currentRootObject ? m_currentRootObject->property("currentText").toString() : QStringLiteral("Hello Qt"); QUrl source("qrc:qquickviewcomparison/test.qml"); if (m_state == UseWindow) { QQuickView *quickView = new QQuickView; // m_transparent is not supported here since many systems have problems with semi-transparent child windows quickView->setFormat(m_format); quickView->setResizeMode(QQuickView::SizeRootObjectToView); connect(quickView, &QQuickView::statusChanged, this, &MainWindow::onStatusChangedView); connect(quickView, &QQuickView::sceneGraphError, this, &MainWindow::onSceneGraphError); quickView->setSource(source); m_currentRootObject = quickView->rootObject(); switchTo(QWidget::createWindowContainer(quickView)); } else if (m_state == UseWidget) { QQuickWidget *quickWidget = new QQuickWidget; if (m_transparent) { quickWidget->setClearColor(Qt::transparent); quickWidget->setAttribute(Qt::WA_TranslucentBackground); } quickWidget->setFormat(m_format); quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView); connect(quickWidget, &QQuickWidget::statusChanged, this, &MainWindow::onStatusChangedWidget); connect(quickWidget, &QQuickWidget::sceneGraphError, this, &MainWindow::onSceneGraphError); quickWidget->setSource(source); m_currentRootObject = quickWidget->rootObject(); switchTo(quickWidget); } if (m_currentRootObject) { m_currentRootObject->setProperty("currentText", text); m_currentRootObject->setProperty("multisample", m_checkboxMultiSample->isChecked()); m_currentRootObject->setProperty("translucency", m_transparent); } m_overlayLabel->raise(); }
void HsQMLContextControl::controlContext() { // Do nothing if no window if (!mWindow) { return; } // Do nothing if changes are being deferred if (mDefer || !mWhen) { mPending = true; return; } mPending = false; QSurfaceFormat fmt = mOriginal; if (mMajorVersion >= 0) { fmt.setMajorVersion(mMajorVersion); } if (mMinorVersion >= 0) { fmt.setMinorVersion(mMinorVersion); } if (mContextType >= 0) { fmt.setRenderableType(static_cast<QSurfaceFormat::RenderableType>( mContextType)); } if (mContextProfile >= 0) { fmt.setProfile(static_cast<QSurfaceFormat::OpenGLContextProfile>( mContextProfile)); } if (mDeprecatedFunctionsSet) { #if QT_VERSION >= 0x050300 fmt.setOption(QSurfaceFormat::DeprecatedFunctions, mDeprecatedFunctions); #else if (mDeprecatedFunctions) { fmt.setOption(QSurfaceFormat::DeprecatedFunctions); } #endif } fmt.setDepthBufferSize(qMax(fmt.depthBufferSize(), mDepthBufferSize)); fmt.setStencilBufferSize(qMax(fmt.stencilBufferSize(), mStencilBufferSize)); if (fmt == mWindow->requestedFormat()) { return; } mWindow->setFormat(fmt); // Recreate OpenGL context mWindow->setPersistentOpenGLContext(false); mWindow->setPersistentSceneGraph(false); bool visible = mWindow->isVisible(); mWindow->destroy(); mWindow->releaseResources(); mWindow->setVisible(visible); mWindow->setPersistentOpenGLContext(true); mWindow->setPersistentSceneGraph(true); }
Window::Window() : QOpenGLWidget() { QSurfaceFormat format; format.setSamples(8); format.setStencilBufferSize(8); setFormat(format); printf("Version Major:%d minor:%d \n",format.version().first, format.version().second); datachanged = colorchanged = true; }
QSurfaceFormat QSGContext::defaultSurfaceFormat() const { QSurfaceFormat format; format.setDepthBufferSize(24); format.setStencilBufferSize(8); if (QQuickWindow::hasDefaultAlphaBuffer()) format.setAlphaBufferSize(8); format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); return format; }
ReplayRenderWidget::ReplayRenderWidget(QWidget *parent) : QOpenGLWidget(parent) { QSurfaceFormat format; format.setDepthBufferSize(24); format.setStencilBufferSize(8); format.setVersion(4, 5); format.setProfile(QSurfaceFormat::CompatibilityProfile); setFormat(format); }
QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat) { QSurfaceFormat format; EGLint redSize = 0; EGLint greenSize = 0; EGLint blueSize = 0; EGLint alphaSize = 0; EGLint depthSize = 0; EGLint stencilSize = 0; EGLint sampleCount = 0; EGLint renderableType = 0; eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize); eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize); eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize); eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize); eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount); eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &renderableType); if (referenceFormat.renderableType() == QSurfaceFormat::OpenVG && (renderableType & EGL_OPENVG_BIT)) format.setRenderableType(QSurfaceFormat::OpenVG); #ifdef EGL_VERSION_1_4 else if (referenceFormat.renderableType() == QSurfaceFormat::OpenGL && (renderableType & EGL_OPENGL_BIT)) format.setRenderableType(QSurfaceFormat::OpenGL); else if (referenceFormat.renderableType() == QSurfaceFormat::DefaultRenderableType #ifndef QT_NO_OPENGL && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL #endif && (renderableType & EGL_OPENGL_BIT)) format.setRenderableType(QSurfaceFormat::OpenGL); #endif else format.setRenderableType(QSurfaceFormat::OpenGLES); format.setRedBufferSize(redSize); format.setGreenBufferSize(greenSize); format.setBlueBufferSize(blueSize); format.setAlphaBufferSize(alphaSize); format.setDepthBufferSize(depthSize); format.setStencilBufferSize(stencilSize); format.setSamples(sampleCount); format.setStereo(false); // EGL doesn't support stereo buffers format.setSwapInterval(referenceFormat.swapInterval()); // Clear the EGL error state because some of the above may // have errored out because the attribute is not applicable // to the surface type. Such errors don't matter. eglGetError(); return format; }
Quiddiards::Quiddiards(QWidget* parent) : QOpenGLWidget(parent) { /* init parameters */ QSurfaceFormat format; format.setDepthBufferSize(24); format.setStencilBufferSize(8); format.setVersion(3, 2); QSurfaceFormat::setDefaultFormat(format); initUI(); }
QTestWindow() { setSurfaceType(QSurface::OpenGLSurface); QSurfaceFormat format; // Qt Quick may need a depth and stencil buffer. Always make sure these are available. format.setDepthBufferSize(16); format.setStencilBufferSize(8); format.setVersion(4, 5); format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile); format.setOption(QSurfaceFormat::DebugContext); setFormat(format); _context = new QOpenGLContext; _context->setFormat(format); _context->create(); show(); makeCurrent(); gpu::Context::init<gpu::GLBackend>(); { QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this); logger->initialize(); // initializes in the current context, i.e. ctx logger->enableMessages(); connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) { qDebug() << debugMessage; }); // logger->startLogging(QOpenGLDebugLogger::SynchronousLogging); } qDebug() << (const char*)glGetString(GL_VERSION); //_textRenderer[0] = TextRenderer::getInstance(SANS_FONT_FAMILY, 12, false); //_textRenderer[1] = TextRenderer::getInstance(SERIF_FONT_FAMILY, 12, false, // TextRenderer::SHADOW_EFFECT); //_textRenderer[2] = TextRenderer::getInstance(MONO_FONT_FAMILY, 48, -1, // false, TextRenderer::OUTLINE_EFFECT); //_textRenderer[3] = TextRenderer::getInstance(INCONSOLATA_FONT_FAMILY, 24); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearColor(0.2f, 0.2f, 0.2f, 1); glDisable(GL_DEPTH_TEST); makeCurrent(); setFramePosition(QPoint(-1000, 0)); resize(QSize(800, 600)); }
QSurfaceFormat getDefaultOpenGlSurfaceFormat() { QSurfaceFormat format; // Qt Quick may need a depth and stencil buffer. Always make sure these are available. format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS); format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS); format.setVersion(4, 1); #ifdef DEBUG format.setOption(QSurfaceFormat::DebugContext); #endif // FIXME move to core as soon as possible format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile); return format; }
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; } }
QMapboxGL::QMapboxGL(QWindow *parent) : QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, parent) , d_ptr(new QMapboxGLPrivate(this)) { QSurfaceFormat format; format.setRedBufferSize(8); format.setGreenBufferSize(8); format.setBlueBufferSize(8); format.setStencilBufferSize(8); format.setAlphaBufferSize(8); format.setDepthBufferSize(16); setFormat(format); }
void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES3, TestFunction const & fn) { std::vector<char> buf(strlen(testName) + 1); strcpy(buf.data(), testName); char * raw = buf.data(); int argc = 1; QApplication app(argc, &raw); QSurfaceFormat fmt; fmt.setAlphaBufferSize(8); fmt.setBlueBufferSize(8); fmt.setGreenBufferSize(8); fmt.setRedBufferSize(8); fmt.setStencilBufferSize(0); fmt.setSamples(0); fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer); fmt.setSwapInterval(1); fmt.setDepthBufferSize(16); if (apiOpenGLES3) { fmt.setProfile(QSurfaceFormat::CoreProfile); fmt.setVersion(3, 2); } else { fmt.setProfile(QSurfaceFormat::CompatibilityProfile); fmt.setVersion(2, 1); } auto surface = std::make_unique<QOffscreenSurface>(); surface->setFormat(fmt); surface->create(); auto context = std::make_unique<QOpenGLContext>(); context->setFormat(fmt); context->create(); context->makeCurrent(surface.get()); if (fn) fn(apiOpenGLES3); context->doneCurrent(); surface->destroy(); QTimer::singleShot(0, &app, SLOT(quit())); app.exec(); }
QtWaylandMotorcarCompositor *QtWaylandMotorcarCompositor::create(int argc, char** argv, motorcar::Scene *scene) { // Enable the following to have touch events generated from mouse events. // Very handy for testing touch event delivery without a real touch device. // QGuiApplication::setAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents, true); QGuiApplication *app = new QGuiApplication(argc, argv); QScreen *screen = NULL; //screen = QGuiApplication::primaryScreen(); screen = QGuiApplication::screens().back(); QRect screenGeometry = screen->geometry(); QSurfaceFormat format; // std::cout << "color buffer size: " << format.redBufferSize() << std::endl; // format.setRedBufferSize(8); // format.setGreenBufferSize(8); // format.setBlueBufferSize(8); // format.setAlphaBufferSize(8); format.setDepthBufferSize(8); format.setStencilBufferSize(8); format.setSwapInterval(1); format.setStencilBufferSize(8); QRect geom = screenGeometry; // if (QCoreApplication::arguments().contains(QLatin1String("-nofullscreen"))) // geom = QRect(screenGeometry.width() / 4, screenGeometry.height() / 4, // screenGeometry.width() / 2, screenGeometry.height() / 2); QOpenGLWindow *window = new QOpenGLWindow(format, geom); return new QtWaylandMotorcarCompositor(window, app, scene); }
int main(int argc, char** argv) { QSurfaceFormat format; format.setDepthBufferSize(24); format.setStencilBufferSize(8); format.setVersion(4, 1); format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); format.setOption(QSurfaceFormat::DebugContext); QSurfaceFormat::setDefaultFormat(format); // setFormat(format); QGuiApplication app(argc, argv); TestWindow window; return app.exec(); }
ImageViewerPanel::ImageViewerPanel(QWidget *parent) : QOpenGLWidget(parent) //, frame{ 0,0, 640,0, 640,480, 0,480 } , frame{ -1,-1, 1,-1, 1,1, -1,1 } , imgsize{ 640, 480 } , textures(nullptr) , texType(DISPLAY_TYPE::BEAUTY) { QSurfaceFormat format; format.setDepthBufferSize(32); format.setStencilBufferSize(8); //format.setSamples(16); format.setVersion(4, 5); //format.setProfile(QSurfaceFormat::CoreProfile); this->setFormat(format); this->create(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QSurfaceFormat format; format.setVersion(4, 3); format.setProfile(QSurfaceFormat::CoreProfile); format.setDepthBufferSize(24); format.setStencilBufferSize(8); format.setOption(QSurfaceFormat::DebugContext); QSurfaceFormat::setDefaultFormat(format); YSLaboratoryView lab; lab.show(); return app.exec(); }
OGLViewer::OGLViewer(QWidget *parent) : QOpenGLWidget(parent) , view_cam(new perspCamera( Point3f(10, 6, 10), Point3f(0.0, 0.0, 0.0), Vector3f(0, 1, 0), width() / Float(height()))) , model_mesh(new TriangleMesh("../../scene/obj/unitCube.obj")) { auto ctx = this->context(); cout << "default fbo:\t" << defaultFramebufferObject() << endl; // Set surface format for current widget QSurfaceFormat format; format.setDepthBufferSize(32); format.setStencilBufferSize(8); format.setSamples(4); format.setVersion(4, 5); format.setProfile(QSurfaceFormat::CoreProfile); this->setFormat(format); }