Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have such Execution:

graphics.GraphicsDevice.Clear(new Color(255, 0, 0, 0));

Alpha is 0. So why it draws me Red color?

graphics.GraphicsDevice.Clear(new Color(255, 0, 0, 255));

Also draws the same red color. Changing alpha value doesn't affects the color on the screen. Why?

share|improve this question
    
I've reverted your edit - if you have a new question please create a new question :) –  Andrew Russell Apr 10 '13 at 5:58

1 Answer 1

The alpha value in the backbuffer does not affect what is scanned out to the screen.

However it does affect blending. For example, non-premultiplied alpha blending is:

output = source * sourceAlpha + destination * (1-sourceAlpha)

While the above uses the source alpha only (giving you the "transparency" effect you expect), you can also set up the blending stage to use the destination alpha. Most sane blend modes only use the source alpha - but using the destination alpha lets you do some fun special effects (example).

In XNA you can change the blend function by creating an instance of BlendState (MSDN).

The other reason to have an alpha value for the destination buffer is if it is a render target. When you go to use that render target as a texture, the alpha values stored in its buffer will behave as you would expect for a texture.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.