Changeset 846 for trunk/src/opengl/qglpixelbuffer_win.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/opengl/qglpixelbuffer_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 168 168 #endif 169 169 170 #ifndef WGL_ARB_multisample 171 #define WGL_SAMPLE_BUFFERS_ARB 0x2041 172 #define WGL_SAMPLES_ARB 0x2042 173 #endif 174 175 #ifndef GL_SAMPLES_ARB 176 #define GL_SAMPLES_ARB 0x80A9 177 #endif 178 170 179 QGLFormat pfiToQGLFormat(HDC hdc, int pfi); 171 180 … … 227 236 attribs[i++] = TRUE; 228 237 } 229 // sample buffers doesn't work in conjunction with the render_texture extension 230 // so igonre that for now 231 // if (f.sampleBuffers()) { 232 // attribs[i++] = WGL_SAMPLE_BUFFERS_ARB; 233 // attribs[i++] = 1; 234 // attribs[i++] = WGL_SAMPLES_ARB; 235 // attribs[i++] = f.samples() == -1 ? 16 : f.samples(); 236 // } 238 if (f.sampleBuffers()) { 239 attribs[i++] = WGL_SAMPLE_BUFFERS_ARB; 240 attribs[i++] = 1; 241 attribs[i++] = WGL_SAMPLES_ARB; 242 attribs[i++] = f.samples() == -1 ? 16 : f.samples(); 243 } 237 244 attribs[i] = 0; 238 245 } … … 240 247 bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget) 241 248 { 242 QGLWidget dmy; 243 dmy.makeCurrent(); // needed for wglGetProcAddress() to succeed 249 QGLTemporaryContext tempContext; 244 250 245 251 PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB = … … 255 261 return false; 256 262 257 dc = GetDC(dmy.winId());263 dc = wglGetCurrentDC(); 258 264 Q_ASSERT(dc); 259 260 PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = 261 (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB"); 262 263 if (wglGetExtensionsStringARB) { 264 QString extensions(QLatin1String(wglGetExtensionsStringARB(dc))); 265 has_render_texture = extensions.contains(QLatin1String("WGL_ARB_render_texture")); 265 has_render_texture = false; 266 267 // sample buffers doesn't work in conjunction with the render_texture extension 268 if (!f.sampleBuffers()) { 269 PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = 270 (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB"); 271 272 if (wglGetExtensionsStringARB) { 273 QString extensions(QLatin1String(wglGetExtensionsStringARB(dc))); 274 has_render_texture = extensions.contains(QLatin1String("WGL_ARB_render_texture")); 275 } 266 276 } 267 277 … … 285 295 if (num_formats == 0) { 286 296 qWarning("QGLPixelBuffer: Unable to find a pixel format with pbuffer - giving up."); 287 ReleaseDC(dmy.winId(), dc);288 297 return false; 289 298 } … … 298 307 pbuf = wglCreatePbufferARB(dc, pixel_format, size.width(), size.height(), 299 308 has_render_texture ? pb_attribs : 0); 300 if (!pbuf) {309 if (!pbuf) { 301 310 // try again without the render_texture extension 302 311 pbuf = wglCreatePbufferARB(dc, pixel_format, size.width(), size.height(), 0); … … 304 313 if (!pbuf) { 305 314 qWarning("QGLPixelBuffer: Unable to create pbuffer [w=%d, h=%d] - giving up.", size.width(), size.height()); 306 ReleaseDC(dmy.winId(), dc);307 315 return false; 308 316 } 309 317 } 310 318 311 ReleaseDC(dmy.winId(), dc);312 319 dc = wglGetPbufferDCARB(pbuf); 313 320 ctx = wglCreateContext(dc); 314 315 321 if (!dc || !ctx) { 316 322 qWarning("QGLPixelBuffer: Unable to create pbuffer context - giving up."); 317 323 return false; 318 324 } 325 326 // Explicitly disable the render_texture extension if we have a 327 // multi-sampled pbuffer context. This seems to be a problem only with 328 // ATI cards if multi-sampling is forced globally in the driver. 329 wglMakeCurrent(dc, ctx); 330 GLint samples = 0; 331 glGetIntegerv(GL_SAMPLES_ARB, &samples); 332 if (has_render_texture && samples != 0) 333 has_render_texture = false; 319 334 320 335 HGLRC share_ctx = shareWidget ? shareWidget->d_func()->glcx->d_func()->rc : 0;
Note:
See TracChangeset
for help on using the changeset viewer.