本文整理汇总了C++中QPlatformWindowFormat::setWindowApi方法的典型用法代码示例。如果您正苦于以下问题:C++ QPlatformWindowFormat::setWindowApi方法的具体用法?C++ QPlatformWindowFormat::setWindowApi怎么用?C++ QPlatformWindowFormat::setWindowApi使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPlatformWindowFormat
的用法示例。
在下文中一共展示了QPlatformWindowFormat::setWindowApi方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chooseContext
bool QGLContext::chooseContext(const QGLContext* shareContext)
{
Q_D(QGLContext);
if(!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) {
d->valid = false;
}else {
QWidget *widget = static_cast<QWidget *>(d->paintDevice);
if (!widget->platformWindow()){
QGLFormat glformat = format();
QPlatformWindowFormat winFormat = QGLFormat::toPlatformWindowFormat(glformat);
if (shareContext) {
winFormat.setSharedContext(shareContext->d_func()->platformContext);
}
if (widget->testAttribute(Qt::WA_TranslucentBackground))
winFormat.setAlpha(true);
winFormat.setWindowApi(QPlatformWindowFormat::OpenGL);
winFormat.setWindowSurface(false);
widget->setPlatformWindowFormat(winFormat);
widget->winId();//make window
}
d->platformContext = widget->platformWindow()->glContext();
Q_ASSERT(d->platformContext);
d->glFormat = QGLFormat::fromPlatformWindowFormat(d->platformContext->platformWindowFormat());
d->valid =(bool) d->platformContext;
if (d->valid) {
d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
}
d->setupSharing();
}
return d->valid;
}
示例2: d
QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
: d(new QGLTemporaryContextPrivate)
{
d->context = const_cast<QPlatformGLContext *>(QPlatformGLContext::currentContext());
if (d->context)
d->context->doneCurrent();
d->widget = new QWidget;
d->widget->setGeometry(0,0,3,3);
QPlatformWindowFormat format = d->widget->platformWindowFormat();
format.setWindowApi(QPlatformWindowFormat::OpenGL);
format.setWindowSurface(false);
d->widget->setPlatformWindowFormat(format);
d->widget->winId();
d->widget->platformWindow()->glContext()->makeCurrent();
}
示例3: createAndSetPlatformContext
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);
}