IonicWind Software

Aurora Compiler => 2D Graphics => Topic started by: Zen on June 27, 2006, 03:41:11 AM

Title: Alpha Blending
Post by: Zen on June 27, 2006, 03:41:11 AM
Ok so i get how i can make a sprite semi transparent but how can i make a say a black filled rectangle then make it so its semi-transparent? I've looked through the 2D include file and i cant see anything within any of the classes.

Any pointers ;) anyone!

Lewis
Title: Re: Alpha Blending
Post by: Ionic Wind Support Team on June 27, 2006, 07:22:49 AM
Create a sprite, draw a rectangle to it, and use it's alpha blending render mode.  The breakout example should help...specifically see the SetupPaddle funciton.

You could use PutAlphaPixel from C2DSurface but it would be a bit slow for a large rectangle.

Title: Re: Alpha Blending
Post by: Zen on June 27, 2006, 08:21:56 AM
Ok how do i draw a rectangle to a sprite? I know how to draw to a surface because there is a DrawRect method on the surface class. Couldnt see anything like that in the Sprice class though.

Lewis
Title: Re: Alpha Blending
Post by: Ionic Wind Support Team on June 27, 2006, 08:25:26 AM
See the example/funciton I specified ;)

m_Tile is a member of C2DSprite and m_Tile is derived from C2DSurface. 

sprite->m_Tile->DrawFilledRect(...


Title: Re: Alpha Blending
Post by: Zen on June 27, 2006, 08:35:24 AM
Ahhh, seems a long way around but its good enough for me.

Thanks a lot Paul

Lewis
Title: Re: Alpha Blending
Post by: Zen on July 03, 2006, 02:59:25 PM
Hi.

I still seem to be having a problem with Alpha blending. Although i am not trying to do it on a large scale now, Some things (small sprites) still need to be semi transparent. I cant seem to do it. Anyone give me an example?

Lewis
Title: Re: Alpha Blending
Post by: Protected on July 03, 2006, 04:29:21 PM
Actual sprites or black rectangles?
Title: Re: Alpha Blending
Post by: Zen on July 04, 2006, 03:24:17 AM
Actual Sprites. I have drawn some graphics and i want them to be semi transparent, not like how the SHADOW render mode does it, but so it is still visible but the background shows through.

Lewis
Title: Re: Alpha Blending
Post by: Protected on July 04, 2006, 06:24:10 AM
I think it should work if you used:

      SetRenderMode(RENDER_TRANSALPHA);
      SetAlpha(25);

But I'm getting weird results ~_~ It looks like it's showing whatever crap was in the buffer (it's ignoring the fact that the background is set to black) :-S
Title: Re: Alpha Blending
Post by: Zen on July 04, 2006, 07:09:06 AM
Yeah thats what i thought it was but all i have been getting is that crap too. Glad its not just me then :D

Lewis
Title: Re: Alpha Blending
Post by: Ionic Wind Support Team on July 04, 2006, 09:43:07 AM
I'll look but it did work the last time I tried it ;)

Rendering order is important and if your using RENDER_TRANSALPHA then the mask color has to be correct to.
Title: Re: Alpha Blending
Post by: Ionic Wind Support Team on July 04, 2006, 09:54:23 AM
Well it looks like a bug crept in during one of the updates.

I'll fix it after the holiday.

EDIT:  Bug is only with 32 bit modes.  Works with 16 bit fullscreen.
Title: Re: Alpha Blending
Post by: Zen on July 04, 2006, 10:11:21 AM
Ohh good, i thought it was me. Thanks a lot Paul. At least i know it will work after.

Also another quick question. What if i want to use RENDER_TRANSSTRETCHED and RENDER_TRANSALPHA can i | them or will it not work?

Lewis
Title: Re: Alpha Blending
Post by: Ionic Wind Support Team on July 04, 2006, 10:34:13 AM
No there aren't combined modes currently. 
Title: Re: Alpha Blending
Post by: Zen on July 04, 2006, 11:16:59 AM
Ohh no! lol. I assume by currently, that you mean there will be eventually. Its just i have a few sprites that are 1x10px and is sized at runtime but also needs to be transparent.

Lewis
Title: Re: Alpha Blending
Post by: Ionic Wind Support Team on July 04, 2006, 11:37:32 AM
It's not an easy thing to accomplish but can be done.  Which is why I said eventually.

The alpha blending is done through software since DX7 never supported it through hardware.  The TRANSSTRETCHED is done with a hardware blit.  So a temporary buffer would need to be set up to apply the alpha first.

The alpha problem is fixed for Rev 6 BTW.   A simple matter of a signed/unsigned oversight on my part.
Title: Re: Alpha Blending
Post by: Zen on July 04, 2006, 01:11:54 PM
Ohh so when we use TRANSSTRETCHED it is actually telling the hardware to do something i guess through directX's com interface rather than something you have done like the alpha problem.

There is no rush as the project is quite large and it can be added later.

Yeah its always the simple little things that cause the problems in life.

Thanks
Lewis
Title: Re: Alpha Blending
Post by: Barney on July 04, 2006, 01:54:11 PM
Once 3D is added it's best to use what's called "2D in 3D" i.e. use 3D quads as sprites. That way one can still program 2D games but with all the bells and whistles available with modern 3D hardware. Blitz3D combined with Sprite Candy is an excellent example of such system.

Barney
Title: Re: Alpha Blending
Post by: Zen on July 04, 2006, 05:50:03 PM
Thanks barney, i will take note of your wise words. For now i will still carry on as its good practice about how graphical programming works. Its not a game im making though, its my GUI controls project i am working on.

Thanks
Lewis