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

Author Topic: Transparent window  (Read 3568 times)

0 Members and 1 Guest are viewing this topic.

ScArL3T

  • Newbie
  • *
  • Posts: 32
    • View Profile
Transparent window
« on: May 22, 2015, 01:13:03 pm »
Is there any way i could make a transparent splashscreen?

Transparent window with a rendered image, like the one photoshop uses.

http://www.optimiced.com/wp-uploads/2010/07/photoshop-cs5-white-rabbit-splash-screen.jpg

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Transparent window
« Reply #1 on: May 22, 2015, 01:29:11 pm »
Not directly with SFML. Please use the search function before posting, there are many threads about this.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

ScArL3T

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Transparent window
« Reply #2 on: May 22, 2015, 01:32:44 pm »
I found some solutions using OpenGL or Qt. I also found these 2 functions:

void SplashScreen::makeWindowTransparent()
{
        HWND hwnd = window.getSystemHandle();
        SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
}

void SplashScreen::setWindowAlpha(sf::Uint8 alpha)
{
        SetLayeredWindowAttributes(window.getSystemHandle(), (0, 255, 255), alpha, LWA_ALPHA);
}

But if I set the alpha to 0 then the whole window is transparent. All i want is just a transparent window background so i can draw sprites on it. I made this post because the solutions i found are too advanced for me at the moment and I'd rather not make my project any more complex.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Transparent window
« Reply #3 on: May 22, 2015, 05:46:32 pm »
There is no simple way to do this without reverting to platform specific code. On Win32 you must set some window flags (don't remember exact ones) and also set the 'transparency key' (in the window create params IIRC). Then wherever you draw that transparent color that area will be transparent. Note: I don't know if it is possible to do it with a window that has a OpenGL context associated with it - so you may end up having to create and manage the window yourself (and draw with GDI+).
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

ScArL3T

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Transparent window
« Reply #4 on: May 22, 2015, 09:38:58 pm »
Ok thank you! I will look into it.