SDL "Transparent" Window

Started by
7 comments, last by adt7 11 years, 2 months ago

Alright, I've got a basic program that renders a rotating sphere of Earth. I've disabled window borders, but I have no idea how I would make the background transparent. The background being the typical black background that you start off with. I'm using SDL 1.2 with OpenGL and I couldn't figure out how to do it either with SDL's functions or OpenGL's.

Here's what I see:

Screenshotfrom2013-01-21075318_zpsfdd8e7

Essentially, how do I make it appear as though the Earth is the only thing showing? Is this possible using the SDL_SetVideoMode() or is it something I have to do through OpenGL?

Advertisement

Have you tried setting the clear buffer color to say, 0, 0, 0, 0?

In opengl that is: http://www.opengl.org/sdk/docs/man/xhtml/glClearColor.xml

Douglas Eugene Reisinger II
Projects/Profile Site

Yep. Doesn't work.

Are you trying to make the whole window transparent, so that you can see the desktop and other applications beneath? If so, that's unlikely to be something SDL can offer you directly.

Most likely you will need to get a handle to the platform specific window object, and change its opacity, using something like Win32's SetLayeredWindowAttributes function. This may only work on windows that were created in a specific way (see the notes at that link) which means you may have to create the window manually and tell SDL to use it via the SDL_WINDOWID 'hack'.

Are you trying to make the whole window transparent, so that you can see the desktop and other applications beneath? If so, that's unlikely to be something SDL can offer you directly.

Yep, but if you look at the picture you may notice I'm using Ubuntu, not Windows. I'm looking for something cross platform, is this possible in SDL 2.0?

Aha, sorry for my assumption. No, I don't know anything that is cross-platform compatible.

Aha, sorry for my assumption. No, I don't know anything that is cross-platform compatible.

It's okay, I probably would be under Windows, but I can't get the freaking SDL library to build properly with MinGW | MSYS and I got no help at the SDL forums. Say what you want about Linux, it's great for development. But that's off topic, do you know what this concept is called? Maybe I could get a better search if I knew the right term to search.

Generally you just want to look for 'opacity' rather than 'transparency' (because technically transparency is the special case of 0% opacity).

Under X11, apparently the window managers in use must support the _NET_WM_WINDOW_OPACITY atom. I think you can query for its presence and then set it to a value that reflects the level of opacity you want. Sorry I can't be more help.

Off the main topic, but what problems were you having build SDL(2?) with MINGW?

The following should build it fine, replacing the prefix/host variables with the correct ones for your environment.

autogen.sh

mkdir build

cd build

./configure --prefix=/path_to_mingw_install/i586-mingw32msvc --host=i586-mingw32msvc

make

make install

This topic is closed to new replies.

Advertisement