[Development] Qt Quick2 OpenGL or Raster translucent window

gunnar.sletta at nokia.com gunnar.sletta at nokia.com
Mon Mar 12 08:48:18 CET 2012


On Mar 12, 2012, at 5:31 AM, ext hailong geng wrote:

> Hi
>     	Yes, I have tried this before and only get black background. 
>     	I have reported a bug : https://bugreports.qt-project.org/browse/QTBUG-24707 (I am not sure whether this should be a bug or a task).
> 	I just want to make QQuickView with translucent bakcground work(with OpenGL as backend is the best but Raster is also ok). 

QQuickView's will only ever use OpenGL as the whole graphics stack for QML 2 is built on top of OpenGL. Raster is not an option.

>  	Because windows XP doesn't support pixel alpha blending with OpenGL so maybe we can't make QQuickView work translucently in Xp with OpenGL backend, but we can do that in Vista or win7 Using dwmapi.dll to support that. 
> 	I am not familiar with the new QQuickView structure, so I don't know what is the best way to make QQuickView with translucent background work in Win7 and Xp(with OpenGL the best), may you tell me what should I do or forward this question to some person who is in charge of QQuickView and Scene Graph?

There are several places the translucency can go wrong. 

- Does OpenGL with alpha work for Qt at all on Win7? Can be tested with a QWindow / QOpenGLContext with a minimal glClear() / swapBuffers(). If this does not work, then the problem is in the windows platform plugin.
- The scene graph renderer will clear the color buffer with QQuickCanvas::clearColor() which is opaque white by default.
- The QQuickView might put an opaque fullscreen rectangle into the scene, so even if you have alpha support on the QWindow / QOpenGLContext layer, you would still need to avoid opaque stuff in the scenegraph. 

To make the GL integration on windows as good as any DirectX integration, we wanted to try out layering our GL code on top of ANGLE (http://code.google.com/p/angleproject/) so we would be calling GL api but using DirectX under the hood. I don't think anybody tried this yet, but if you're up for it, I would be interested in hearing the outcome :)

Hope this helps you dig a bit further.

cheers,
Gunnar

> 	Thank you^_^
> 
> From: "sarah.j.smith at nokia.com" <sarah.j.smith at nokia.com>
> To: longlongh4 at yahoo.com 
> Cc: samuel.rodal at nokia.com; development at qt-project.org 
> Sent: Sunday, March 11, 2012 5:32 PM
> Subject: Re: [Development] Qt Quick2 OpenGL or Raster translucent window
> 
> Hi
> 
> Have you tried something like this:
> 
> int main(int argc, char *argv[])
> {
>     QGuiApplication app(argc, argv); 
>     QSurfaceFormat f;
>     f.setSamples(16);              // if you want AA as well
>     f.setAlphaBufferSize(8);   // turn on alpha
>     QQuickView view;
>     view.setFormat(f);
>     view.setSource(QUrl::fromLocalFile(QLatin1String("/path/to/my.qml"));
>     view.show();
>     return app.exec();
> }
> 
> I don't have a windows box handy to try this on, but give it a try.
> 
> As far as I know qmlscene doesnt know how to run with an alpha enabled GL context.
> 
> Regards
> 
> Sarah Smith
> Senior Engineer Team Lead Qt3D
> Nokia Qt Development Frameworks
> Mobile: +61 448 283 476
> Sarah.j.smith at nokia.com
> 
> 
> 
> On 11/03/2012, at 3:13 AM, ext hailong geng wrote:
> 
>> Hi
>> I have searched the Internet these two days and I find that it seems impossible to draw translucent window in Windows XP by OpenGL, because it doesn't support pixel alpha blending. So does Qt have found a way to do that for Windows XP? 
>> Or Qt Quick2 just ignore the translucent function for Window which use OpenGL as backend, or even with Raster backend, I tried to set alpha channel and  use  RasterSurface but QQuickView just crashed.(maybe  RasterSurface  backend is not finished?)
>> 
>> For Windows Vista and newer windows version, there is DWMAPI which will support translucent opengl on desktop, you can see this demo, http://www.youtube.com/watch?v=4qWKSYWIqdk, this is cool, isn't it ^_^
>> So shall Qt support translucent OpenGL window for Windows Vista and any newer version?
>> _______________________________________________
>> Development mailing list
>> Development at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/development
> 
> 
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development




More information about the Development mailing list