172 contextProps = *properties; |
173 contextProps = *properties; |
173 #if defined(QT_OPENGL_ES_2) |
174 #if defined(QT_OPENGL_ES_2) |
174 if (apiType == QEgl::OpenGL) |
175 if (apiType == QEgl::OpenGL) |
175 contextProps.setValue(EGL_CONTEXT_CLIENT_VERSION, 2); |
176 contextProps.setValue(EGL_CONTEXT_CLIENT_VERSION, 2); |
176 #endif |
177 #endif |
|
178 sharing = false; |
177 if (shareContext && shareContext->ctx == EGL_NO_CONTEXT) |
179 if (shareContext && shareContext->ctx == EGL_NO_CONTEXT) |
178 shareContext = 0; |
180 shareContext = 0; |
179 if (shareContext) { |
181 if (shareContext) { |
180 ctx = eglCreateContext(dpy, cfg, shareContext->ctx, contextProps.properties()); |
182 ctx = eglCreateContext(dpy, cfg, shareContext->ctx, contextProps.properties()); |
181 if (ctx == EGL_NO_CONTEXT) { |
183 if (ctx == EGL_NO_CONTEXT) { |
182 qWarning() << "QEglContext::createContext(): Could not share context:" << errorString(eglGetError()); |
184 qWarning() << "QEglContext::createContext(): Could not share context:" << errorString(eglGetError()); |
183 shareContext = 0; |
185 shareContext = 0; |
|
186 } else { |
|
187 sharing = true; |
184 } |
188 } |
185 } |
189 } |
186 if (ctx == EGL_NO_CONTEXT) { |
190 if (ctx == EGL_NO_CONTEXT) { |
187 ctx = eglCreateContext(dpy, cfg, 0, contextProps.properties()); |
191 ctx = eglCreateContext(dpy, cfg, 0, contextProps.properties()); |
188 if (ctx == EGL_NO_CONTEXT) { |
192 if (ctx == EGL_NO_CONTEXT) { |
229 } |
233 } |
230 |
234 |
231 current = true; |
235 current = true; |
232 currentSurface = surface; |
236 currentSurface = surface; |
233 setCurrentContext(apiType, this); |
237 setCurrentContext(apiType, this); |
|
238 |
|
239 // Force the right API to be bound before making the context current. |
|
240 // The EGL implementation should be able to figure this out from ctx, |
|
241 // but some systems require the API to be explicitly set anyway. |
|
242 #ifdef EGL_OPENGL_ES_API |
|
243 if (apiType == QEgl::OpenGL) |
|
244 eglBindAPI(EGL_OPENGL_ES_API); |
|
245 #endif |
|
246 #ifdef EGL_OPENVG_API |
|
247 if (apiType == QEgl::OpenVG) |
|
248 eglBindAPI(EGL_OPENVG_API); |
|
249 #endif |
234 |
250 |
235 bool ok = eglMakeCurrent(dpy, surface, surface, ctx); |
251 bool ok = eglMakeCurrent(dpy, surface, surface, ctx); |
236 if (!ok) |
252 if (!ok) |
237 qWarning() << "QEglContext::makeCurrent():" << errorString(eglGetError()); |
253 qWarning() << "QEglContext::makeCurrent():" << errorString(eglGetError()); |
238 return ok; |
254 return ok; |
411 return QString(QLatin1String(exts)); |
427 return QString(QLatin1String(exts)); |
412 } |
428 } |
413 |
429 |
414 bool QEglContext::hasExtension(const char* extensionName) |
430 bool QEglContext::hasExtension(const char* extensionName) |
415 { |
431 { |
416 return extensions().contains(QLatin1String(extensionName)); |
432 QList<QByteArray> extensions = |
|
433 QByteArray(reinterpret_cast<const char *> |
|
434 (eglQueryString(QEglContext::defaultDisplay(0), EGL_EXTENSIONS))).split(' '); |
|
435 return extensions.contains(extensionName); |
417 } |
436 } |
418 |
437 |
419 QEglContext *QEglContext::currentContext(QEgl::API api) |
438 QEglContext *QEglContext::currentContext(QEgl::API api) |
420 { |
439 { |
421 if (api == QEgl::OpenGL) |
440 if (api == QEgl::OpenGL) |