Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Transparent windows.  (Read 7217 times)

0 Members and 2 Guests are viewing this topic.

xylr117z4

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Transparent windows.
« 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...

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...
« Last Edit: October 23, 2012, 01:06:37 am by xylr117z4 »

masskiller

  • Sr. Member
  • ****
  • Posts: 284
  • Pointers to Functions rock!
    • MSN Messenger - kyogre_jb@hotmail.com
    • View Profile
    • Email
Re: Transparent windows.
« Reply #1 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...
Programmer, Artist, Composer and Storyline/Script Writer of "Origin of Magic". If all goes well this could turn into a commercial project!

Finally back into the programming world!

xylr117z4

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Re: Transparent windows.
« Reply #2 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)?

masskiller

  • Sr. Member
  • ****
  • Posts: 284
  • Pointers to Functions rock!
    • MSN Messenger - kyogre_jb@hotmail.com
    • View Profile
    • Email
Re: Transparent windows.
« Reply #3 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.
Programmer, Artist, Composer and Storyline/Script Writer of "Origin of Magic". If all goes well this could turn into a commercial project!

Finally back into the programming world!

xylr117z4

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Re: Transparent windows.
« Reply #4 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 I talk a little about it.

masskiller

  • Sr. Member
  • ****
  • Posts: 284
  • Pointers to Functions rock!
    • MSN Messenger - kyogre_jb@hotmail.com
    • View Profile
    • Email
Re: Transparent windows.
« Reply #5 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
Programmer, Artist, Composer and Storyline/Script Writer of "Origin of Magic". If all goes well this could turn into a commercial project!

Finally back into the programming world!

xylr117z4

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Re: Transparent windows.
« Reply #6 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

yeah that's what I was thinking about if I couldn't get this to work.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Transparent windows.
« Reply #7 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Transparent windows.
« Reply #8 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
Laurent Gomila - SFML developer

xylr117z4

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Re: Transparent windows.
« Reply #9 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.
« Last Edit: October 22, 2012, 05:00:51 pm by xylr117z4 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Transparent windows.
« Reply #10 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.
Laurent Gomila - SFML developer

xylr117z4

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Re: Transparent windows.
« Reply #11 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...
« Last Edit: October 23, 2012, 01:05:57 am by xylr117z4 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Transparent windows.
« Reply #12 on: October 23, 2012, 06:34:27 am »
Have you tried to search "SetLayeredWindowAttributes + OpenGL" on Google? It seems to have many interesting answers.
Laurent Gomila - SFML developer

xylr117z4

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Re: Transparent windows.
« Reply #13 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.