Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: monkey0506 on Fri 16/01/2009 18:57:24

Title: [SOLVED] BUG: GUI background graphic switch between alpha/non-alpha sprites?
Post by: monkey0506 on Fri 16/01/2009 18:57:24
I'm using AGS 3.1.2, but IIRC this used to cause me grief on prior versions of AGS as well. I'm working with the Flashlight module, and I think I've discovered a bug...I've managed to replicate the problem several times...

In the module I'm using the DrawingSurface functions to build a Dynamic sprite based on this pattern:

Flashlight.ScreenSprite = DynamicSprite.CreateFromExisting(Flashlight.BeamSprite.Graphic, true);
Flashlight.ScreenSprite.Resize(FloatToInt(Flashlight.Radius * 2.0), FloatToInt(Flashlight.Radius * 2.0));
Flashlight.ScreenSprite.ChangeCanvasSize(System.ViewportWidth, System.ViewportHeight, Flashlight.X, Flashlight.Y);
DrawingSurface *surface = Flashlight.ScreenSprite.GetDrawingSurface();
// draw rectangles on each side of the sprite
surface.Release();


The problem is this, if the module is set to GUI mode:

Flashlight.AGSGUI.BackgroundGraphic = Flashlight.ScreenSprite.Graphic;

And then in my updating method which is called from repeatedly_execute, the GUI is turned off (whether it was on or not):

Flashlight.AGSGUI.Visible = Flashlight.Enabled;

Then it goes all weird.

What it's doing is this:

Title: Re: BUG: GUI background graphic switch between alpha/non-alpha sprites?
Post by: Pumaman on Fri 16/01/2009 19:03:54
I'm not really sure where you're saying the problem is, or what exactly is and shouldn't be happening... would you be able to upload a game source that demonstrates the problem?
Title: Re: BUG: GUI background graphic switch between alpha/non-alpha sprites?
Post by: monkey0506 on Fri 16/01/2009 19:31:16
What is happening is this:

If I draw a sprite with no alpha channel onto a DrawingSurface of a DynamicSprite and then set that DynamicSprite to the BackgroundGraphic of a GUI, the sprite itself disappears entirely. Or if I'm drawing one with an alpha channel, the sprite is flattened. Depending upon whether the GUI has previously been explicitly turned off. Apparently.

The source is here (http://meleepta.x10hosting.com/Flashlight.rar).

The offending line is apparently line 139 of Flashlight.asc which reads:

if (this.IsGUIMode) this.AGSGUI.Visible = false;

Which turns the GUI off if the effect is disabled and was using a GUI. Uncommented it allows only alpha sprites (non-alpha disappear). Commented it allows non-alpha sprites, but any alpha sprites are flattened.
Title: Re: BUG: GUI background graphic switch between alpha/non-alpha sprites?
Post by: Pumaman on Sat 17/01/2009 22:58:37
Thanks for uploading it, but can you provide some instructions on how to reproduce the problem? When running the game, what do you press/click, what do you see, and what should you see instead?
Title: Re: BUG: GUI background graphic switch between alpha/non-alpha sprites?
Post by: monkey0506 on Sun 18/01/2009 09:59:28
Oh sorry. :P

Numbers 1-4 cycle between different beam-sprites:

1. "flashlight.bmp", no alpha
2. crappy attempt at alpha dithering
3. alpha smoothed circle
4. red alpha smoothed circle

The problem is that either #1 works properly and #2-4 become flattened, or #2-4 work properly and #1 the entire sprite disappears (see screenshot above). As I said this is apparently controlled by whether the GUI is allowed to be turned off. Thanks for looking into this...
Title: Re: BUG: GUI background graphic switch between alpha/non-alpha sprites?
Post by: Pumaman on Sun 18/01/2009 14:31:21
Thanks for reporting this. I've investigated and there is indeed a bug with the DX5 driver switching a GUI background graphic from one with to one without an alpha channel, and vice versa.

I'll get it fixed, but in the meantime a workaround to see it working properly would be to use the D3D driver.
Title: Re: BUG: GUI background graphic switch between alpha/non-alpha sprites?
Post by: monkey0506 on Sun 18/01/2009 16:43:57
Ah good to know. Thanks Chris! ;D