diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-07-27 12:07:23 +0200 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2011-07-27 12:17:53 +0200 |
commit | b03f5fd47631d234d140b5a792eff80286c91e92 (patch) | |
tree | d3f447877d571a6525191e36d0bc1e20ec81e406 /src/platformsupport | |
parent | 233411bc1e69ef0ea72b173a7f6b26124c346857 (diff) |
More graceful choosing of EGL configs.
If someone asks for a depth buffer of size 32, we should try to give
them a smaller depth buffer if none of that size is available. Also,
don't unconditionally read the alpha size of the configure
attributes, since it might have been removed when reducing the config.
Change-Id: If2f9d49c1cc3ded015384f9551b19cd15c523ce3
Reviewed-on: http://codereview.qt.nokia.com/2269
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/platformsupport')
-rw-r--r-- | src/platformsupport/eglconvenience/qeglconvenience.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index 63f564c2d5..bb2613e05b 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -85,28 +85,28 @@ QVector<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format) QVector<EGLint> configAttributes; configAttributes.append(EGL_RED_SIZE); - configAttributes.append(redSize); + configAttributes.append(redSize > 0 ? redSize : 0); configAttributes.append(EGL_GREEN_SIZE); - configAttributes.append(greenSize); + configAttributes.append(greenSize > 0 ? greenSize : 0); configAttributes.append(EGL_BLUE_SIZE); - configAttributes.append(blueSize); + configAttributes.append(blueSize > 0 ? blueSize : 0); configAttributes.append(EGL_ALPHA_SIZE); - configAttributes.append(alphaSize); + configAttributes.append(alphaSize > 0 ? alphaSize : 0); configAttributes.append(EGL_DEPTH_SIZE); - configAttributes.append(depthSize); + configAttributes.append(depthSize > 0 ? depthSize : 0); configAttributes.append(EGL_STENCIL_SIZE); - configAttributes.append(stencilSize); + configAttributes.append(stencilSize > 0 ? stencilSize : 0); configAttributes.append(EGL_SAMPLES); - configAttributes.append(sampleCount); + configAttributes.append(sampleCount > 0 ? sampleCount : 0); configAttributes.append(EGL_SAMPLE_BUFFERS); - configAttributes.append(sampleCount? 1:0); + configAttributes.append(sampleCount > 0); return configAttributes; } @@ -178,12 +178,19 @@ bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes) i = configAttributes->indexOf(EGL_STENCIL_SIZE); if (i >= 0) { - configAttributes->remove(i,2); + if (configAttributes->at(i + 1) > 1) + configAttributes->replace(i + 1, 1); + else + configAttributes->remove(i, 2); return true; } + i = configAttributes->indexOf(EGL_DEPTH_SIZE); if (i >= 0) { - configAttributes->remove(i,2); + if (configAttributes->at(i + 1) > 1) + configAttributes->replace(i + 1, 1); + else + configAttributes->remove(i, 2); return true; } #ifdef EGL_BIND_TO_TEXTURE_RGB @@ -232,7 +239,7 @@ EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, i = configureAttributes.indexOf(EGL_BLUE_SIZE); int confAttrBlue = configureAttributes.at(i+1); i = configureAttributes.indexOf(EGL_ALPHA_SIZE); - int confAttrAlpha = configureAttributes.at(i+1); + int confAttrAlpha = i == -1 ? 0 : configureAttributes.at(i+1); EGLint size = matching; EGLConfig *configs = new EGLConfig [size]; |