Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp
- +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp
- @@ -42,6 +42,7 @@
- #include <QByteArray>
- #include "qeglconvenience_p.h"
- +#include "assert.h"
- QT_BEGIN_NAMESPACE
- @@ -212,73 +213,39 @@
- EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType)
- {
- - EGLConfig cfg = 0;
- - QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format);
- - configureAttributes.append(EGL_SURFACE_TYPE);
- - configureAttributes.append(surfaceType);
- -
- - configureAttributes.append(EGL_RENDERABLE_TYPE);
- - if (format.renderableType() == QSurfaceFormat::OpenVG)
- - configureAttributes.append(EGL_OPENVG_BIT);
- -#ifdef EGL_VERSION_1_4
- - else if (format.renderableType() == QSurfaceFormat::OpenGL)
- - configureAttributes.append(EGL_OPENGL_BIT);
- -#endif
- - else if (format.majorVersion() == 1)
- - configureAttributes.append(EGL_OPENGL_ES_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 = i == -1 ? 0 : 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 ((confAttrRed == 0 || red == confAttrRed) &&
- - (confAttrGreen == 0 || green == confAttrGreen) &&
- - (confAttrBlue == 0 || 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;
- + EGLint configCount = 0;
- + assert(eglGetConfigs(display, 0, 0, &configCount) == EGL_TRUE);
- + //qDebug("%d EGL configurations were found.", configCount);
- + EGLConfig* configs = new EGLConfig[configCount];
- + assert(eglGetConfigs(display, configs, configCount, &configCount) == EGL_TRUE);
- +
- + // List the configurations.
- + for (int i = 0; i < configCount; i++) {
- + EGLint redSize, blueSize, greenSize, alphaSize;
- + //assert(eglGetConfigAttrib(display, *(configs + i), EGL_RED_SIZE, &redSize) == EGL_TRUE);
- + //assert(eglGetConfigAttrib(display, *(configs + i), EGL_GREEN_SIZE, &greenSize) == EGL_TRUE);
- + //assert(eglGetConfigAttrib(display, *(configs + i), EGL_BLUE_SIZE, &blueSize) == EGL_TRUE);
- + //assert(eglGetConfigAttrib(display, *(configs + i), EGL_ALPHA_SIZE, &alphaSize) == EGL_TRUE);
- + //qDebug("Config %d: RGBA(%d, %d, %d, %d).", i, redSize, greenSize, blueSize, alphaSize);
- + }
- +
- + // Choose the first 32 bit configuration.
- + EGLConfig config;
- + int i = 0;
- + for (i = 0; i < configCount; i++) {
- + EGLint redSize, blueSize, greenSize, alphaSize;
- + assert(eglGetConfigAttrib(display, *(configs + i), EGL_RED_SIZE, &redSize) == EGL_TRUE);
- + assert(eglGetConfigAttrib(display, *(configs + i), EGL_GREEN_SIZE, &greenSize) == EGL_TRUE);
- + assert(eglGetConfigAttrib(display, *(configs + i), EGL_BLUE_SIZE, &blueSize) == EGL_TRUE);
- + assert(eglGetConfigAttrib(display, *(configs + i), EGL_ALPHA_SIZE, &alphaSize) == EGL_TRUE);
- + //qDebug("Config %d: RGBA(%d, %d, %d, %d).", i, redSize, greenSize, blueSize, alphaSize);
- + if (redSize == 8 && blueSize == 8 && greenSize == 8 && alphaSize == 8) {
- + config = *(configs + i);
- + break;
- + }
- + }
- + delete[] configs;
- + return config;
- }
- QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement