C Board  

Go Back   C Board > General Programming Boards > Game Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-23-2006, 02:44 AM   #1
Confused
 
Magos's Avatar
 
Join Date: Sep 2001
Location: Sweden
Posts: 3,122
D3DXSprite and alpha blend

When rendering alpha-blended sprites you send D3DXSPRITE_ALPHABLEND in the call to D3DXSprite->Begin(), sounds easy yes? So I thought that omitting this flag (using 0) would prevent alpha-blend from being used. Not as easy, if alpha blending has been enabled by some previous rendering the sprite will still render it as alphablended. Is this really the desired behaviour, having to manually disable alpha blend before the sprite Begin-End calls?
__________________
MagosX.com

Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Magos is offline   Reply With Quote
Old 05-23-2006, 04:55 AM   #2
Super Moderator
 
Bubba's Avatar
 
Join Date: Aug 2001
Posts: 7,472
Yes, since alpha blending is set using SetRenderState().

If you set alpha blending prior to D3DXSprite render calls, it is possible, although improbable that D3DXSprite will turn it off after the call.

Direct3D is a pure state machine in that any state you set lasts until you 'un-set' it.

This is why you should turn alpha on, render all alpha objects, and then turn it off. This guarantees that render states won't be 'left over' in future calls.

You can also use state blocks to control render states. You think alpha blending is bad wait until you try using SetTextureStageState(). Those states are also left as-is in the next render so you must reset them to what you want prior to rendering your next object.

DirectX 10's non-FFP will solve most of this issue and shader's for DX9 already address this.

For now look into Direct3D render state blocks and effects.

Last edited by Bubba; 05-23-2006 at 04:57 AM.
Bubba is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump


All times are GMT -6. The time now is 05:41 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22