Sign in to follow this  
el-enemigo

Clear Screen with a transparent color

Recommended Posts

el-enemigo    100
Hey all,
first of all I'm german so please excuse my grammar.
However, I want to Clear the Screen of my Direct3D9 Application with a transparent color and for that I use the following code:
[code]
hr = pD3DDevice->Clear(0,
NULL,
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_ARGB(0, 0, 0, 0),
1.0f,
0);
[/code]
But it looks like the Alphachannel is still being ignored.
The Backbuffer format is: D3DFMT_A8R8G8B8
Oh and I think it's worth mentioning that I render on the desktop instead in a window.

So my question is, how do I get the background of my Direct3D scene to be transparent?
I hope you can help me out...thanks in advance,

Regards
el-enemigo

P,S. [url="http://www.gamedev.net/gallery/image/1068-screenshot/"]Here's[/url] a screenshot of my program

Share this post


Link to post
Share on other sites
AFAIK Clear doesn't support alpha channels. It's best to switch to drawing using primitives or sprites (these cause no framedrop while regular lines and font objects will).

Take a look at the directx sample browser. I'm sure there's something about primitives!

EDIT: Looked it up and for me it's: "Tutorial 2: Vertices"

Share this post


Link to post
Share on other sites
el-enemigo    100
Thanks for the reply.

Are you sure about that?
'Cause [url="http://msdn.microsoft.com/en-us/library/bb174352%28v=vs.85%29.aspx"]MSDN[/url] says:[quote][i]Color[/i] [in] Type: [b][url="http://msdn.microsoft.com/en-us/library/bb172518%28v=vs.85%29.aspx"][b]D3DCOLOR[/b][/url][/b]

Clear a render target to this [b]ARGB[/b] color.

[/quote]

Share this post


Link to post
Share on other sites
kauna    2922
What kind of result you expect to get when clearing the screen with RGBA color value? You mean that the alpha values don't get written to the back buffer?

Color with alpha value doesn't make it transparent in every case. Alpha value is just 4th value attached to the RGB-color. Most of the time it is true that alpha values stand for transparency, but even then you have to define how the alpha values are used.

Simply put : clearing the screen with the a RGBA color value will fill/replace the entire (back)buffer with that RGBA color, regardless of the current content of the buffer.

Cheers!

Edit : I noticed that you want your program to blend to the desktop. I don't have answer to that question, but probably you'll need to blend your backbuffer to the window/desktop under it. AFAIK, Clear doesn't provide that kind of functionality.

Share this post


Link to post
Share on other sites
Beem    127
There is no such thing as an alpha channel in the back buffer. If you want to blend with the desktop, you'll probably need to render to a GDI surface, then use a Windows API call to blend it to the desktop. Here is something I found on the topic of alpha blending in the windows API http://blog.duck17.net/post/Per-pixel-Alpha-Blending-in-Native-Win32-API.aspx.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this