I was trying to save a .tga image using GetFrontBufferData method,but alpha value is lost.They are totally one.I could get right alpha value from RenderTarget or BackBuffer,but not rgb value is not correct.Even the scene present to show immediately,backbuffer still seems darker than frontbuffer.
Now I get 2 questions:
Q1:Do FrontBuffer have alpha value?
Q2:What is the difference between the data of back buffer and front buffer when you try to render transparent things?

- 11
- 3
1 Answers
When you render a transparent object, its alpha value is used to perform alpha blending. Once the blending is completed, new value is written to the back buffer. If you want to preserve the alpha value, the format of the back buffer should be D3DFMT_A8R8G8B8
. You should also remember about clearing the alpha channel while calling IDirect3DDevice9::Clear()
. Once the rendering is completed, the back buffer and the front buffer pointers are simply flipped (read more). Thus, both buffers have the same format (so if you created the back buffer with RGBA format, the front buffer would also be RGBA). By the way, you can get the back buffer and lock it instead of getting the front buffer.
By default, alpha blending performs the same operations on R, G, B and A channels, but you can specify a separate operation for the alpha channel only - see this.

- 1,635
- 15
- 21
– April Jul 03 '12 at 07:01