SFML community forums

Help => Graphics => Topic started by: xylr117z4 on October 22, 2012, 04:39:00 am

Title: Transparent windows.
Post by: xylr117z4 on October 22, 2012, 04:39:00 am
so I'm trying to make my window transparent through the windows API while using sfml to display the graphics but this happens...
(http://i46.tinypic.com/inr1ue.jpg)
The functions I'm trying to use are:
SetWindowLong(HANDLE,GWL_EXSTYLE,GetWindowLong(HANDLE, GWL_EXSTYLE) | WS_EX_LAYERED);
and SetLayeredWindowAttributes(HANDLE, RGB(0,0,0), 200, LWA_ALPHA);

I'm not sure if SFML is just not compatable with these or if there's a better way to do this... I'm not that experience with the windows API it self is why I ask for help.

Edit: It seems to just be the SetLayeredWindowAttributes(); fuction that breaks things...
Title: Re: Transparent windows.
Post by: masskiller on October 22, 2012, 04:53:37 am
Why not just use the SFML renderwindow? It allows you all control from sfml as well as openGL and you can configure it as you like.

I don't really understand what you mean by transparent window, so I can't help there...
Title: Re: Transparent windows.
Post by: xylr117z4 on October 22, 2012, 04:56:20 am
I'm trying to make the entire window transparent including what's drawn by sfml, so that you can see what's under the window like in the image I've posted.

and is there a function with sfml to make the renderwindow transparent (see through)?
Title: Re: Transparent windows.
Post by: masskiller on October 22, 2012, 05:04:01 am
Quote
I'm trying to make the entire window transparent including what's drawn by sfml, so that you can see what's under the window like in the image I've posted.

Couldn't see the image, that's why I didn't understand at first.

Quote
and is there a function with sfml to make the renderwindow transparent (see through)?

That I don't know, it's the first time I hear of someone trying to make a window work like that, what do you want the effect for? Maybe there's something that could work for the same purpose.
Title: Re: Transparent windows.
Post by: xylr117z4 on October 22, 2012, 05:14:46 am
Well the reason I would like to have a transparent window is so that you could see behind it incase you are reading a webpage or something... The program it self allows you to type with a controller if you're in bed using your desktop or on a TV, in this thread (http://en.sfml-dev.org/forums/index.php?topic=9459.msg64193#new) I talk a little about it.
Title: Re: Transparent windows.
Post by: masskiller on October 22, 2012, 05:21:17 am
I see. There's the setVisible function of the renderWindow which could do what you want to do. I can't tell you how it works since I haven't used it before, but you could have the window become invisible by pressing an specific button and using the same to make it visible again.

http://www.sfml-dev.org/documentation/2.0/classsf_1_1RenderWindow.php (http://www.sfml-dev.org/documentation/2.0/classsf_1_1RenderWindow.php)
Title: Re: Transparent windows.
Post by: xylr117z4 on October 22, 2012, 05:23:02 am
I see. There's the setVisible function of the renderWindow which could do what you want to do. I can't tell you how it works since I haven't used it before, but you could have the window become invisible by pressing an specific button and using the same to make it visible again.

http://www.sfml-dev.org/documentation/2.0/classsf_1_1RenderWindow.php (http://www.sfml-dev.org/documentation/2.0/classsf_1_1RenderWindow.php)

yeah that's what I was thinking about if I couldn't get this to work.
Title: Re: Transparent windows.
Post by: eXpl0it3r on October 22, 2012, 08:08:15 am
A similar question has been asked not long ago. Maybe you find the discussion again...
SFML doesn't provide functionalities for transparent windows, but you might be able to get it with some OpenGL code.
Title: Re: Transparent windows.
Post by: Laurent on October 22, 2012, 08:56:35 am
Quote
but you might be able to get it with some OpenGL code.
OpenGL is totally unable to do that ;)
You must ask the windowing API if you want your window to be transparent. That's exactly what the OP does in its first post. And I don't know why it doesn't work ;D
Title: Re: Transparent windows.
Post by: xylr117z4 on October 22, 2012, 04:57:08 pm
Quote
but you might be able to get it with some OpenGL code.
OpenGL is totally unable to do that ;)
You must ask the windowing API if you want your window to be transparent. That's exactly what the OP does in its first post. And I don't know why it doesn't work ;D

I think it might have something to do with where I use the two functions.. After I declare the RenderWindow I use .getSystemHandle() to get the handle which I pass to the functions I pasted above.

I believe I'll need to declare the window with the Windows API then put a RenderWindow inside of that some how... but I have basically no experience with the Windows API so I'll just read up on that.

but as MassKiller said I could just hide the window.

BTW: Thanks for the quick response one of the many reasons SFML is better than a lot of other libraries.
Title: Re: Transparent windows.
Post by: Laurent on October 22, 2012, 05:04:57 pm
Quote
I believe I'll need to declare the window with the Windows API then put a RenderWindow inside of that some how...
That would probably not make any difference.
Title: Re: Transparent windows.
Post by: xylr117z4 on October 22, 2012, 05:23:25 pm
Quote
I believe I'll need to declare the window with the Windows API then put a RenderWindow inside of that some how...
That would probably not make any difference.

yeah it probably wouldn't since it's the function that changes the window's alpha that makes sfml no longer display.  I guess I'll just take the easy way out for now... but I'll keep reading about it.

Edit: It seems to just be the SetLayeredWindowAttributes(); fuction that breaks things...
Title: Re: Transparent windows.
Post by: Laurent on October 23, 2012, 06:34:27 am
Have you tried to search "SetLayeredWindowAttributes + OpenGL" on Google? It seems to have many interesting answers.
Title: Re: Transparent windows.
Post by: xylr117z4 on October 23, 2012, 08:16:21 pm
Have you tried to search "SetLayeredWindowAttributes + OpenGL" on Google? It seems to have many interesting answers.
Like I said earlier (I think...) I'll just have to do a bunch of reading.  Either way if I can't get this to work just hiding the window is probably better because even if you can see under the window you won't be able to click on anything.