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

Author Topic: [SOLVED] Window Transparency  (Read 3516 times)

0 Members and 1 Guest are viewing this topic.

Domingo Diego

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Diego Software
[SOLVED] Window Transparency
« on: June 25, 2009, 06:38:50 am »
Hello

I think I might be doing this wrong as nobody has had this problem so far.
(Or maybe it's just not possible)

I'm trying to set the window's background color to be 0% Opaque.

However, when the window runs it runs at 100% Opacity regardless of what number I put in the 4th argument of the sf::Color's constructor.

Here's the code:
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600), "Test", sf::Style::None);
App.SetFramerateLimit(600);

while (App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
}

App.Clear(sf::Color(0,0,0,0));

App.Display();
}

    return 0;
}


That creates a 800 x 600 frameless window that is, unfortunatly, black and completely opaque.

Am I doing this wrong? Is it not possible? (I did search, I couldn't find anyone asking this question...)

Edit:
I am using SFML 1.5
Domingo Diego

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SOLVED] Window Transparency
« Reply #1 on: June 25, 2009, 08:21:41 am »
You can't set the window's opacity like this. The fact that the OpenGL back buffer is transparent won't tell Windows to make the window transparent as well ;)

Setting the window opacity would requires a new function, and is very OS-specific. It's not even supported by every OS.
Laurent Gomila - SFML developer

Domingo Diego

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Diego Software
[SOLVED] Window Transparency
« Reply #2 on: June 25, 2009, 02:29:56 pm »
Ah, I see.

Yeah, I worked up an ugly Windows API call to make the window transparent only to figure out I really didn't want it transparent after all.

I'll mark the post as [SOLVED] because you can set the window's transparency, but it's OS-Specific and it's sort of useless.

The solution is out there though if a person really wants a semi-transparent window that only works on Windows (There may be a Mac way, but that's still OS specific).

Thanks for the help!
Btw: Nice library
Domingo Diego