54 int sampleCount = format.
samples();
58 if (format.
alpha() && alphaSize <= 0)
60 if (format.
depth() && depthSize <= 0)
62 if (format.
stencil() && stencilSize <= 0)
86 redSize = redSize > 0 ? redSize : 0;
87 greenSize = greenSize > 0 ? greenSize : 0;
88 blueSize = blueSize > 0 ? blueSize : 0;
89 alphaSize = alphaSize > 0 ? alphaSize : 0;
90 depthSize = depthSize > 0 ? depthSize : 0;
91 stencilSize = stencilSize > 0 ? stencilSize : 0;
92 sampleCount = sampleCount > 0 ? sampleCount : 0;
96 configAttributes.
append(EGL_RED_SIZE);
97 configAttributes.
append(redSize);
99 configAttributes.
append(EGL_GREEN_SIZE);
100 configAttributes.
append(greenSize);
102 configAttributes.
append(EGL_BLUE_SIZE);
103 configAttributes.
append(blueSize);
105 configAttributes.
append(EGL_ALPHA_SIZE);
106 configAttributes.
append(alphaSize);
108 configAttributes.
append(EGL_DEPTH_SIZE);
109 configAttributes.
append(depthSize);
111 configAttributes.
append(EGL_STENCIL_SIZE);
112 configAttributes.
append(stencilSize);
114 configAttributes.
append(EGL_SAMPLES);
115 configAttributes.
append(sampleCount);
117 configAttributes.
append(EGL_SAMPLE_BUFFERS);
118 configAttributes.
append(sampleCount? 1:0);
120 return configAttributes;
131 i = configAttributes->
indexOf(EGL_SWAP_BEHAVIOR);
133 configAttributes->
remove(i,2);
136 #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT 140 i = configAttributes->
indexOf(EGL_SURFACE_TYPE);
142 EGLint surfaceType = configAttributes->
at(i +1);
143 if (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) {
144 surfaceType ^= EGL_VG_ALPHA_FORMAT_PRE_BIT;
145 configAttributes->
replace(i+1,surfaceType);
156 i = configAttributes->
indexOf(EGL_BUFFER_SIZE);
158 if (configAttributes->
at(i+1) == 16) {
159 configAttributes->
remove(i,2);
164 i = configAttributes->
indexOf(EGL_SAMPLE_BUFFERS);
166 configAttributes->
remove(i,2);
167 i = configAttributes->
indexOf(EGL_SAMPLES);
169 configAttributes->
remove(i,2);
174 i = configAttributes->
indexOf(EGL_ALPHA_SIZE);
176 configAttributes->
remove(i,2);
177 #if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB) 178 i = configAttributes->
indexOf(EGL_BIND_TO_TEXTURE_RGBA);
180 configAttributes->
replace(i,EGL_BIND_TO_TEXTURE_RGB);
188 i = configAttributes->
indexOf(EGL_STENCIL_SIZE);
190 configAttributes->
remove(i,2);
193 i = configAttributes->
indexOf(EGL_DEPTH_SIZE);
195 configAttributes->
remove(i,2);
198 #ifdef EGL_BIND_TO_TEXTURE_RGB 199 i = configAttributes->
indexOf(EGL_BIND_TO_TEXTURE_RGB);
201 configAttributes->
remove(i,2);
213 configureAttributes.
append(EGL_SURFACE_TYPE);
214 configureAttributes.
append(surfaceType);
216 configureAttributes.
append(EGL_RENDERABLE_TYPE);
218 configureAttributes.
append(EGL_OPENVG_BIT);
220 configureAttributes.
append(EGL_OPENGL_ES2_BIT);
222 configureAttributes.
append(EGL_NONE);
227 if (!eglChooseConfig(display, configureAttributes.
constData(), 0, 0, &matching) || !matching)
232 if (highestPixelFormat) {
233 eglChooseConfig(display, configureAttributes.
constData(), &cfg, 1, &matching);
241 int i = configureAttributes.
indexOf(EGL_RED_SIZE);
242 int confAttrRed = configureAttributes.
at(i+1);
243 i = configureAttributes.
indexOf(EGL_GREEN_SIZE);
244 int confAttrGreen = configureAttributes.
at(i+1);
245 i = configureAttributes.
indexOf(EGL_BLUE_SIZE);
246 int confAttrBlue = configureAttributes.
at(i+1);
247 i = configureAttributes.
indexOf(EGL_ALPHA_SIZE);
248 int confAttrAlpha = configureAttributes.
at(i+1);
250 EGLint size = matching;
251 EGLConfig *configs =
new EGLConfig [size];
252 eglChooseConfig(display, configureAttributes.
constData(), configs, size, &matching);
255 eglGetConfigAttrib(display, configs[
index], EGL_RED_SIZE, &red);
256 eglGetConfigAttrib(display, configs[index], EGL_GREEN_SIZE, &green);
257 eglGetConfigAttrib(display, configs[index], EGL_BLUE_SIZE, &blue);
258 eglGetConfigAttrib(display, configs[index], EGL_ALPHA_SIZE, &alpha);
259 if (red == confAttrRed &&
260 green == confAttrGreen &&
261 blue == confAttrBlue &&
262 (confAttrAlpha == 0 ||
263 alpha == confAttrAlpha)) {
264 cfg = configs[
index];
271 qWarning(
"Cant find EGLConfig, returning null config");
279 EGLint greenSize = 0;
281 EGLint alphaSize = 0;
282 EGLint depthSize = 0;
283 EGLint stencilSize = 0;
284 EGLint sampleCount = 0;
287 eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize);
288 eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize);
289 eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize);
290 eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize);
291 eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize);
292 eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize);
293 eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount);
294 eglGetConfigAttrib(display, config, EGL_LEVEL, &level);
320 (eglQueryString(display, EGL_EXTENSIONS))).
split(
' ');
321 return extensions.
contains(extensionName);
bool q_reduceConfigAttributes(QVector< EGLint > *configAttributes)
#define QT_END_NAMESPACE
This macro expands to.
void replace(int i, const T &t)
Replaces the item at index position i with value.
void remove(int i)
Removes the element at index position i.
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
The QByteArray class provides an array of bytes.
Q_GUI_EXPORT QString extensions()
#define QT_BEGIN_NAMESPACE
This macro expands to.
Q_GUI_EXPORT EGLDisplay display()
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
void append(const T &t)
Inserts value at the end of the vector.
Q_CORE_EXPORT void qWarning(const char *,...)
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the vector, searching forward from ind...
const T & at(int i) const
Returns the item at index position i in the vector.
#define TRUE
Synonym for true.
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...
QVector< EGLint > q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format)
QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config)
const T * constData() const
Returns a const pointer to the data stored in the vector.
bool q_hasEglExtension(EGLDisplay display, const char *extensionName)