summaryrefslogtreecommitdiff
path: root/src/opengl/qgl_egl.cpp
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2010-03-10 14:50:59 +0100
committerTom Cooksey <thomas.cooksey@nokia.com>2010-03-10 15:27:46 +0100
commit9bf426a2af27ad5bfdb35706c3ed48e77f654f4d (patch)
tree1a97b6d63cb2f5503a13ee7f4e97dce8eab3db9d /src/opengl/qgl_egl.cpp
parent7ddf13c8fba2aadf00c0d6c822c6b4acbd3bd54f (diff)
downloadqt4-tools-9bf426a2af27ad5bfdb35706c3ed48e77f654f4d.tar.gz
Update QGLFormat from EGLConfig properly
Previously, some members of QGLFormat (like alphaBufferSize) would be left to the initial -1 value. Reviewed-By: TrustMe
Diffstat (limited to 'src/opengl/qgl_egl.cpp')
-rw-r--r--src/opengl/qgl_egl.cpp70
1 files changed, 32 insertions, 38 deletions
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index 3d146b7f9d..c08d6fd109 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -111,46 +111,40 @@ void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLForma
eglProperties.setValue(EGL_SAMPLE_BUFFERS, sampleCount ? 1 : 0);
}
-
// Updates "format" with the parameters of the selected configuration.
-void qt_egl_update_format(const QEglContext& context, QGLFormat& format)
+void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config)
{
- EGLint value = 0;
-
- if (context.configAttrib(EGL_RED_SIZE, &value))
- format.setRedBufferSize(value);
- if (context.configAttrib(EGL_GREEN_SIZE, &value))
- format.setGreenBufferSize(value);
- if (context.configAttrib(EGL_BLUE_SIZE, &value))
- format.setBlueBufferSize(value);
- if (context.configAttrib(EGL_ALPHA_SIZE, &value)) {
- format.setAlpha(value != 0);
- if (format.alpha())
- format.setAlphaBufferSize(value);
- }
-
- if (context.configAttrib(EGL_DEPTH_SIZE, &value)) {
- format.setDepth(value != 0);
- if (format.depth())
- format.setDepthBufferSize(value);
- }
-
- if (context.configAttrib(EGL_LEVEL, &value))
- format.setPlane(value);
-
- if (context.configAttrib(EGL_SAMPLE_BUFFERS, &value)) {
- format.setSampleBuffers(value != 0);
- if (format.sampleBuffers()) {
- context.configAttrib(EGL_SAMPLES, &value);
- format.setSamples(value);
- }
- }
-
- if (context.configAttrib(EGL_STENCIL_SIZE, &value)) {
- format.setStencil(value != 0);
- if (format.stencil())
- format.setStencilBufferSize(value);
- }
+ EGLint redSize = 0;
+ EGLint greenSize = 0;
+ EGLint blueSize = 0;
+ EGLint alphaSize = 0;
+ EGLint depthSize = 0;
+ EGLint stencilSize = 0;
+ EGLint sampleCount = 0;
+ EGLint level = 0;
+
+ EGLDisplay display = QEgl::display();
+ eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize);
+ eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize);
+ eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize);
+ eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize);
+ eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize);
+ eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize);
+ eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount);
+ eglGetConfigAttrib(display, config, EGL_LEVEL, &level);
+
+ format.setRedBufferSize(redSize);
+ format.setGreenBufferSize(greenSize);
+ format.setBlueBufferSize(blueSize);
+ format.setAlphaBufferSize(alphaSize);
+ format.setDepthBufferSize(depthSize);
+ format.setStencilBufferSize(stencilSize);
+ format.setSamples(sampleCount);
+ format.setPlane(level + 1); // EGL calls level 0 "normal" whereas Qt calls 1 "normal"
+ format.setDirectRendering(true); // All EGL contexts are direct-rendered
+ format.setRgba(true); // EGL doesn't support colour index rendering
+ format.setStereo(false); // EGL doesn't support stereo buffers
+ format.setAccumBufferSize(0); // EGL doesn't support accululation buffers
// Clear the EGL error state because some of the above may
// have errored out because the attribute is not applicable