77 if (shareContext) { |
73 if (shareContext) { |
78 // Use the same configuration as the widget we are sharing with. |
74 // Use the same configuration as the widget we are sharing with. |
79 ctx->setConfig(shareContext->config()); |
75 ctx->setConfig(shareContext->config()); |
80 #if QGL_RENDER_TEXTURE |
76 #if QGL_RENDER_TEXTURE |
81 EGLint value = EGL_FALSE; |
77 EGLint value = EGL_FALSE; |
82 if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGBA, &value) && value) |
78 if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGBA) == EGL_TRUE) |
83 textureFormat = EGL_TEXTURE_RGBA; |
79 textureFormat = EGL_TEXTURE_RGBA; |
84 else if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGB, &value) && value) |
80 else if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGB) == EGL_TRUE) |
85 textureFormat = EGL_TEXTURE_RGB; |
81 textureFormat = EGL_TEXTURE_RGB; |
86 #endif |
82 #endif |
87 } else { |
83 } else { |
88 QEglProperties configProps; |
84 QEglProperties configProps; |
89 qt_egl_set_format(configProps, QInternal::Pbuffer, f); |
85 qt_eglproperties_set_glformat(configProps, f); |
|
86 configProps.setDeviceType(QInternal::Pbuffer); |
90 configProps.setRenderableType(ctx->api()); |
87 configProps.setRenderableType(ctx->api()); |
91 bool ok = false; |
88 bool ok = false; |
92 #if QGL_RENDER_TEXTURE |
89 #if QGL_RENDER_TEXTURE |
93 textureFormat = EGL_TEXTURE_RGBA; |
90 textureFormat = EGL_TEXTURE_RGBA; |
94 configProps.setValue(EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE); |
91 configProps.setValue(EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE); |
114 } |
111 } |
115 } |
112 } |
116 } |
113 } |
117 |
114 |
118 // Retrieve the actual format properties. |
115 // Retrieve the actual format properties. |
119 qt_egl_update_format(*ctx, format); |
116 qt_glformat_from_eglconfig(format, ctx->config()); |
120 |
117 |
121 // Create the attributes needed for the pbuffer. |
118 // Create the attributes needed for the pbuffer. |
122 QEglProperties attribs; |
119 QEglProperties attribs; |
123 attribs.setValue(EGL_WIDTH, size.width()); |
120 attribs.setValue(EGL_WIDTH, size.width()); |
124 attribs.setValue(EGL_HEIGHT, size.height()); |
121 attribs.setValue(EGL_HEIGHT, size.height()); |
139 attribs.removeValue(EGL_TEXTURE_TARGET); |
136 attribs.removeValue(EGL_TEXTURE_TARGET); |
140 pbuf = eglCreatePbufferSurface(ctx->display(), ctx->config(), attribs.properties()); |
137 pbuf = eglCreatePbufferSurface(ctx->display(), ctx->config(), attribs.properties()); |
141 } |
138 } |
142 #endif |
139 #endif |
143 if (pbuf == EGL_NO_SURFACE) { |
140 if (pbuf == EGL_NO_SURFACE) { |
144 qWarning() << "QGLPixelBufferPrivate::init(): Unable to create EGL pbuffer surface:" << QEglContext::errorString(eglGetError()); |
141 qWarning() << "QGLPixelBufferPrivate::init(): Unable to create EGL pbuffer surface:" << QEgl::errorString(); |
145 return false; |
142 return false; |
146 } |
143 } |
147 |
144 |
148 // Create a new context for the configuration. |
145 // Create a new context for the configuration. |
149 if (!ctx->createContext(shareContext)) { |
146 if (!ctx->createContext(shareContext)) { |
206 } |
203 } |
207 |
204 |
208 bool QGLPixelBuffer::hasOpenGLPbuffers() |
205 bool QGLPixelBuffer::hasOpenGLPbuffers() |
209 { |
206 { |
210 // See if we have at least 1 configuration that matches the default format. |
207 // See if we have at least 1 configuration that matches the default format. |
211 EGLDisplay dpy = QEglContext::display(); |
208 EGLDisplay dpy = QEgl::display(); |
212 if (dpy == EGL_NO_DISPLAY) |
209 if (dpy == EGL_NO_DISPLAY) |
213 return false; |
210 return false; |
214 QEglProperties configProps; |
211 QEglProperties configProps; |
215 qt_egl_set_format(configProps, QInternal::Pbuffer, QGLFormat::defaultFormat()); |
212 qt_eglproperties_set_glformat(configProps, QGLFormat::defaultFormat()); |
|
213 configProps.setDeviceType(QInternal::Pbuffer); |
216 configProps.setRenderableType(QEgl::OpenGL); |
214 configProps.setRenderableType(QEgl::OpenGL); |
217 do { |
215 do { |
218 EGLConfig cfg = 0; |
216 EGLConfig cfg = 0; |
219 EGLint matching = 0; |
217 EGLint matching = 0; |
220 if (eglChooseConfig(dpy, configProps.properties(), |
218 if (eglChooseConfig(dpy, configProps.properties(), |