/*! \since 4.8 Returns a platform window format for the OpenGL format specified by \a format. */ QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format) { QPlatformWindowFormat retFormat; retFormat.setAccum(format.accum()); if (format.accumBufferSize() >= 0) retFormat.setAccumBufferSize(format.accumBufferSize()); retFormat.setAlpha(format.alpha()); if (format.alphaBufferSize() >= 0) retFormat.setAlphaBufferSize(format.alphaBufferSize()); if (format.blueBufferSize() >= 0) retFormat.setBlueBufferSize(format.blueBufferSize()); retFormat.setDepth(format.depth()); if (format.depthBufferSize() >= 0) retFormat.setDepthBufferSize(format.depthBufferSize()); retFormat.setDirectRendering(format.directRendering()); retFormat.setDoubleBuffer(format.doubleBuffer()); if (format.greenBufferSize() >= 0) retFormat.setGreenBufferSize(format.greenBufferSize()); if (format.redBufferSize() >= 0) retFormat.setRedBufferSize(format.redBufferSize()); retFormat.setRgba(format.rgba()); retFormat.setSampleBuffers(format.sampleBuffers()); if (format.samples() >= 0) retFormat.setSamples(format.samples()); retFormat.setStencil(format.stencil()); if (format.stencilBufferSize() >= 0) retFormat.setStencilBufferSize(format.stencilBufferSize()); retFormat.setStereo(format.stereo()); retFormat.setSwapInterval(format.swapInterval()); return retFormat; }
QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced) { QPlatformWindowFormat retFormat = format; *reduced = true; if (retFormat.sampleBuffers()) { retFormat.setSampleBuffers(false); } else if (retFormat.stereo()) { retFormat.setStereo(false); } else if (retFormat.accum()) { retFormat.setAccum(false); }else if (retFormat.stencil()) { retFormat.setStencil(false); }else if (retFormat.alpha()) { retFormat.setAlpha(false); }else if (retFormat.depth()) { retFormat.setDepth(false); }else if (retFormat.doubleBuffer()) { retFormat.setDoubleBuffer(false); }else{ *reduced = false; } return retFormat; }
void QEglFSScreen::createAndSetPlatformContext() { QPlatformWindowFormat platformFormat = QPlatformWindowFormat::defaultFormat(); platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL); QByteArray depthString = qgetenv("QT_QPA_EGLFS_DEPTH"); if (depthString.toInt() == 16) { platformFormat.setDepth(16); platformFormat.setRedBufferSize(5); platformFormat.setGreenBufferSize(6); platformFormat.setBlueBufferSize(5); m_depth = 16; m_format = QImage::Format_RGB16; } else { platformFormat.setDepth(32); platformFormat.setRedBufferSize(8); platformFormat.setGreenBufferSize(8); platformFormat.setBlueBufferSize(8); m_depth = 32; m_format = QImage::Format_RGB32; } if (!qgetenv("QT_QPA_EGLFS_MULTISAMPLE").isEmpty()) { platformFormat.setSampleBuffers(true); } EGLConfig config = q_configFromQPlatformWindowFormat(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 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); #ifdef QEGL_EXTRA_DEBUG qWarning("Configuration %d matches requirements\n", (int)config); for (index = 0; attrs[index].attr != -1; ++index) { EGLint value; if (eglGetConfigAttrib(m_dpy, config, attrs[index].attr, &value)) { qWarning("\t%s: %d\n", attrs[index].name, (int)value); } } qWarning("\n"); #endif EGLint temp; EGLint attribList[32]; temp = 0; attribList[temp++] = EGL_CONTEXT_CLIENT_VERSION; attribList[temp++] = 2; // GLES version 2 attribList[temp++] = EGL_NONE; QEGLPlatformContext *platformContext = new QEGLPlatformContext(m_dpy,config,attribList,m_surface,EGL_OPENGL_ES_API); 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); }