开发者

QGLWidget::makecurrent(): GetDC() failed. Invalid Window handle

I have a requirement to get pictures saved off screen. I have used QGLwidget::grabframebuffer to get this done. While it works fine on MAC, it fails with an error "QGLWidget::makecurrent(): GetDC() failed. Invalid Window handle " on Windows 7. Only one opengl context gets created in the process. But i have observed that if I add QGLWidget to the Mainwindow, i am able to get the pictures saved. I need not do this on MAC to get the pictures. I am 开发者_如何学Pythonnot sure what could have gone wrong.

thanks!!


This is because on MacOS an OpenGL context is always attached to the root window of a multi window application. (this is not seeable with Cocoa, but it was with Agl/Cgl) On windows you can create the context with any window (that has the flag popup, child and one other i forgot) then bind it to any window with MakeCurrent. to expect it to work fine you only need to be sure you have only one thread and one context in your whole app. the spec says otherwise, but in practice it never works. (though you may not see it in a small app, and just see rares random crash)

also, I don't know in QT how the capture of the framebuffer works, with readpixels or with the horrible GDI copy hack, if it is the latest then it is normal that it doesn't work, it can only be done on screen surfaces.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜