PDA

View Full Version : Alpha draw not working



AthenaOfDelphi
18-05-2006, 01:09 PM
Hi all,

Heres a quick question for you....

I'm doing some work on our game engine and I want to add something to the main screen, but I want it to be alpha blended.

I create a surface and fill it with black (0) for transparency, then I draw on it. I want to draw a section of this on the main screen using alpha blend so the user can see whats underneath, but all I get is nothingness. No errors, just nothing.

As soon as I change the drawAlpha to draw, it works.

So my code goes something like this:-



....
// Create the surface 'mySurface'
....
// Draw on the surface 'mySurface'
....
// Draw a portion of 'mySurface' on the main surface
fDXDraw.surface.drawAlpha(dstRect,srcRect,mySurfac e,true,150);
....


Apologies if the syntax isn't quite right, and just figured I'd ask the question in case anyone else has encountered this problem and has found a solution.

That code doesn't work, but draw(left,top,srcRect,mySurface,true); (again, apologies if the syntax isn't quite right) does. Any ideas? Its not a show stopper, but alpha is just much nicer and it doesn't obscure the players view completely.

Traveler
18-05-2006, 01:33 PM
Could it be that you have a similar problem as dicussed in here (http://www.pascalgamedevelopment.com/forums/viewtopic.php?t=3123&postdays=0&postorder=asc&highlight=delphix&start=30)?

AthenaOfDelphi
18-05-2006, 01:54 PM
Hi Traveller,

I don't think so. I started off, by just trying to draw it with Alpha, without any transparency and that didn't work either.

Basically, I'm adding a minimap... so the minimap surface is around the 2000 x 2000 pixel mark. As each cell is uncovered, it is drawn onto the minimap surface. As the player moves, I simply draw a section of the minimap in the bottom left corner of the screen.

My original code didn't use transparency at all. It simply filled the minimap surface with black and the drew the cells onto the minimap and then tried to alphadraw it to the main surace, but I just get nothing. Its not that its being corrupted or anything like that, its simply not being drawn at all.

Huehnerschaender
18-05-2006, 02:49 PM
Hmmm.... if Draw is working, and DrawAlpha doesn't, then maybe your Rect-Calculations are not correct? I don't think that it really has to do something with the alpha property itself. Did you try to use DrawAlpha and set Alpha to "no transparency"? (Don't know if it is 0 or 255 in you case, for I don't use DelphiX).

AthenaOfDelphi
18-05-2006, 04:33 PM
Hi Dirk,

I've checked the rect boundary and its fine... topleft is less than bottomright and all coordinates are valid for both the source and destinations.

Alpha draw is working nicely when I draw a whole image (a tile for example), but I've never been able to get it to draw a portion of a surface (IIRC) which is obviously what I'm trying to do with the minimap.

Its no problem if I can't get it working, we'll just have to have the miniamp smaller, but it would have been nice to allow it to be bigger by way of the fact that the player can see through it.

User137
21-05-2006, 11:07 AM
I've never been able to get it to draw a portion of a surface
Here i see the problem. If you are using accelerated unDelphix, try the new 1.07 where it should be actually made :P All should work on software mode though in all versions.

AthenaOfDelphi
21-05-2006, 12:07 PM
I have just tried the latest version... see my feedback in the thread announcing its release.

ijcro
21-05-2006, 03:33 PM
Alphablending you can use in the way:

1/ make bitmap32 with alphachannel (8bit)
2/ load it int DXImageList
3/ turn on hardware acceleration (like prototype project)

when all is correct, blending works as well. (Exotic formats like R4G4B4A4 doesn't works).

When you make copy from DDS, I am not sure that is copy with alphachanel, I take that is in 24 bitcount only :(

Sincerely

AthenaOfDelphi
21-05-2006, 03:43 PM
Alpha blending works when I draw an item from TDXImageList in its entirety... it doesn't work when I try to draw a section of a surface onto the primary surface. But the latest version of unDelphiX doesn't compile straight from the archive on Delphi 5.

ijcro
21-05-2006, 04:05 PM
Please download lastest version 1.07a! Thank you.
Sincerely