Hi to all,
I don’t know if this is the correct forum to post this question so first of all sorry if it isn’t.
I’m making a glx application which shows the image captured with a webcam as a texture over a quad.
I want the glx window to be translucent so the desktop and other windows that are behind it are blended with the glx’s window content.
I’ve actually managed to create a traslucent glx window (the window borders are traslucent) and a traslucent texture that displays the webcam image, but the background of the glx window remains black.
I’m really a noob in OpenGL / GLX so my question if this can be achieved (I suppose so as Compiz is able to do it) and if so, where could I find some example / tutorial to achieve this.
I’ve already checked those links, as they are almost the only related links I’ve found during google searching. Maybe my first post isn’t clear enough, so let me reformulate it.
As far as I’ve been able to search and read, I think I have all the neccessary elements to make my GLX ap. translucent (well, sure I haven’t as it doesn’t work )
My card Is an ATI Radeon X1300, and I’ve installed the latest drivers provided by ATI, and checked “xorg.conf” so the composite extension is available.
I’ve selected a visual that supports “GLX_RGBA_BIT”.
I’ve made the GLX window translucent changing it’s attributes with Xlib.
I’ve made the texture I’m displaying also translucent.
But the GL scene background is always opaque. I’ve tried with different values of R,G,B and alpha with the glClearColor function but I only obtain a black / gray / white background but with no translucent effect.
What I would like to know is if managing a translucent GLX background is related to openGL programming or if it should be related to maybe any other issue such as a bad display selection, bad configuration of the ATI drivers or so on.
No experience on this (using xinerama so no Composite) but according to the nvidia page, all you need is the boilerplate code they provide.
Do you get alpha ? ie does (i < numfbconfigs) ?
Do you render premultiplied graphics ? black +alpha=0 should be transparent.
should “convert” it’s values to premultiplied alpha values? That’s what I’ve got in my code and texture displays with translucency.
I’m affraid this is going to be a silly question but, are there other means of setting premultiplied alpha to the GLX scene background as well?
Yes, i < numfbconfigs, so the selected FBConfig has alpha. I’ve added some more checks to my code and I’ve noticed that the visual that is selected which supports alpha does not support direct rendering. That means that even if I manage to get translucency in my window it won’t be hardware accelerated or that I won’t be able to achieve translucency at all?
I’m really lost here, I’m running Compiz with translucent windows with relatively low CPU usage. How do they do it :(?
No worry, premultiplied alpha still confuses a lot of people
2 things :
in this case, it is the window compositor that does the blending of your window, so what you set as your blending mode is not directly relevant. Only that you have to make sure that what you draw has alpha multiplied to rgb, some examples :
fully transparent is black rgba=0,0,0,0=0R,0G,0B,0
full red half transparent rgba= 10.5,0,0,0.5=0.5,0,0,0.5
correct blendfunc for premultiplied alpha is glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
For tests, just glClear with semi-transparent grey rgba=0.5,0.5,0.5,0.5 if composite works you should see a bit trough the window.
Not sure about the DRI thing, it may even be irrelevant. Sorry I can not help more.
Well it looks your code is correct, maybe some added magic is needed on the glx initialisation, or more probably the driver/compositing manager do not play well together.
Can you provide exact version of your drivers, linux distribution, desktop manager (gnome or kde), etc ? Somebody more knowledgable may help.
Is the texture created as premultiplied alpha ? Ie. transparent parts are black ? This is kind of moot anyway if the window alpha is not taken in account.
I’m using Slax with kde, I’m now finishing some work in Windows, as soon as I’ve finished I’ll restart my machine in Linux and try to be more precise.
Texture data is obtained from the webcam using “V4L2_PIX_FMT_BGR24” color palette. I create the openGL texture just as Nehe’s lesson 35 example for displaying avi files does.
What I don’t quite get is why does the texture appear with translucency and blended with the scene background but the scene background isn’t blended with the windows behind it. If I drag the window border to make it bigger than the quad and let the background visible I can see this issue perfectly clear.
It seems you’re right and it has more to do with glx initialisation. In that case, is this forum the correct place to post this question or should I move this to another more especific on glx (which I haven’t found yet )?