本文整理汇总了C++中QPlatformWindowFormat::windowApi方法的典型用法代码示例。如果您正苦于以下问题:C++ QPlatformWindowFormat::windowApi方法的具体用法?C++ QPlatformWindowFormat::windowApi怎么用?C++ QPlatformWindowFormat::windowApi使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPlatformWindowFormat
的用法示例。
在下文中一共展示了QPlatformWindowFormat::windowApi方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: q_configFromQPlatformWindowFormat
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
{
EGLConfig cfg = 0;
QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format);
configureAttributes.append(EGL_SURFACE_TYPE); //we only support eglconfigs for windows for now
configureAttributes.append(surfaceType);
configureAttributes.append(EGL_RENDERABLE_TYPE);
if (format.windowApi() == QPlatformWindowFormat::OpenVG) {
configureAttributes.append(EGL_OPENVG_BIT);
} else {
configureAttributes.append(EGL_OPENGL_ES2_BIT);
}
configureAttributes.append(EGL_NONE);
do {
// Get the number of matching configurations for this set of properties.
EGLint matching = 0;
if (!eglChooseConfig(display, configureAttributes.constData(), 0, 0, &matching) || !matching)
continue;
// If we want the best pixel format, then return the first
// matching configuration.
if (highestPixelFormat) {
eglChooseConfig(display, configureAttributes.constData(), &cfg, 1, &matching);
if (matching < 1)
continue;
return cfg;
}
// Fetch all of the matching configurations and find the
// first that matches the pixel format we wanted.
int i = configureAttributes.indexOf(EGL_RED_SIZE);
int confAttrRed = configureAttributes.at(i+1);
i = configureAttributes.indexOf(EGL_GREEN_SIZE);
int confAttrGreen = configureAttributes.at(i+1);
i = configureAttributes.indexOf(EGL_BLUE_SIZE);
int confAttrBlue = configureAttributes.at(i+1);
i = configureAttributes.indexOf(EGL_ALPHA_SIZE);
int confAttrAlpha = configureAttributes.at(i+1);
EGLint size = matching;
EGLConfig *configs = new EGLConfig [size];
eglChooseConfig(display, configureAttributes.constData(), configs, size, &matching);
for (EGLint index = 0; index < size; ++index) {
EGLint red, green, blue, alpha;
eglGetConfigAttrib(display, configs[index], EGL_RED_SIZE, &red);
eglGetConfigAttrib(display, configs[index], EGL_GREEN_SIZE, &green);
eglGetConfigAttrib(display, configs[index], EGL_BLUE_SIZE, &blue);
eglGetConfigAttrib(display, configs[index], EGL_ALPHA_SIZE, &alpha);
if (red == confAttrRed &&
green == confAttrGreen &&
blue == confAttrBlue &&
(confAttrAlpha == 0 ||
alpha == confAttrAlpha)) {
cfg = configs[index];
delete [] configs;
return cfg;
}
}
delete [] configs;
} while (q_reduceConfigAttributes(&configureAttributes));
qWarning("Cant find EGLConfig, returning null config");
return 0;
}