PDA

View Full Version : StretchDraw= Poor Quality, DrawAdd = Too Slow.



theWaver
01-02-2004, 11:42 PM
Hi.

I've been working with a TImageList and drawing some of it's pictures with various effects. I wan't to draw a ball that once hit by another one, will grow and grow till it fits the screen, slowlly getting less opaque till it disappears.

My problem is that i want to use a good quality plasma ball with coronas and other light effects. I can rotate it without slowing the game much using DrawRotateAdd (rotation makes it look even nicer) but when i stretch the image (give it a bigger TRect size) it gets slow as hell. If i use StretchDraw, then it's byebye transparency and good looking coronas.

As anione got any ideas on how i can solve my problem? :shock:

Clootie
02-02-2004, 07:18 PM
Use Direct3D :twisted:

theWaver
02-02-2004, 07:23 PM
Gee... thanks... :roll:

I'm using the instructions from DelphiX, as far as i know Delphi doesn't have 'DrawRotateAdd' built in as an instruction...

Clootie
02-02-2004, 07:38 PM
Delphi doesn't have 'DrawRotateAdd' built in as an instruction???

theWaver
02-02-2004, 08:45 PM
DrawRotateAdd is a DelphiX function, not a Delphi one. So, if you paid enougth attention to my previous post you'd probbbly notice that i was already using foreign instructions that do not come with Delphi.

BTW, how do you draw a circle on a DXDraw.Surface.Canvas? When i call the Elipse nothing is drawed on the screen (and yes, i'm fliping the buffer)

holybyte
02-02-2004, 09:22 PM
You could rotate first, then stretch and finally drawadd the ball to surface.

But If drawadd is soo slow it's a good idea to use some kind of 3d accelleration.

Useless Hacker
03-02-2004, 12:21 AM
DrawRotateAdd is a DelphiX function, not a Delphi one. So, if you paid enougth attention to my previous post you'd probbbly notice that i was already using foreign instructions that do not come with Delphi.

BTW, how do you draw a circle on a DXDraw.Surface.Canvas? When i call the Elipse nothing is drawed on the screen (and yes, i'm fliping the buffer)You will need to set the properties of the DXDraw.Surface.Pen and .Brush first. Also you should call DXDraw.Surface.Release after you have finished using the canvas. Generally, it is best to use something like this:
with DXDraw.Surface.Canvas do try
Pen.Color := clRed;
// more stuff
finally
Release;
end;

theWaver
03-02-2004, 08:25 PM
thanks, that helped a lot!

It's working almost like the way i wanted it to. Is there any way to draw the Elipse using semi-transparency?

Useless Hacker
03-02-2004, 11:59 PM
Is there any way to draw the Elipse using semi-transparency?Not directly. However, you could create a new TDirectDrawSurface, draw the Elipse to that using the canvas, then DrawAlpha the surface onto the screen.

theWaver
04-02-2004, 12:05 AM
Is there any way to draw the Elipse using semi-transparency?Not directly. However, you could create a new TDirectDrawSurface, draw the Elipse to that using the canvas, then DrawAlpha the surface onto the screen.

And would that be any faster that simply drawing a bitmap from a TImageList using DrawAdd in the same DXDraw?

Useless Hacker
04-02-2004, 08:20 AM
No, although if your ellipse was always the same size you could just draw that once at the beginning of your program (or whenever it changed size/colour, assuming that was infrequently), since using the canvas is slower than a normal draw.

Alimonster
04-02-2004, 09:42 AM
This is slightly off-topic, but it explains Clootie's initial reply ("Use Direct3D"). Any alpha blending (translucency) you do in DirectDraw is not hardware accelerated -- it's done on the CPU instead, which is the reason why it's such a hit (the CPU goes over the images pixel-by-pixel and can't do much else until this is done). You do get transparency (colour keying) in DDraw, which is just an on/off toggle of image colours. However, do not get lulled into thinking that every function call you make to DelphiX will be done on hardware, because a lot of them aren't.

The only ways to speed up translucency are to optimise the DelphiX translucency routines using hardcore code (e.g. hand-crafted assembly, MMX, SSE1 and/or 2, depending on the needs -- MMX is usually good here) or to use 3D hardware to your advantage. However, the speed-up-DelphiX option is likely to be more than a little pain in the butt.

Direct3D and OpenGL can be configured to display 2D images (I have a slightly long-winded framework that demonstrates this in a recent thread for OpenGL). With 3D APIs, rotation, scaling and translucency are all on hardware, which means they get chewed up and spat out by the graphics card without any hassle. The net result is that these special effects are very much faster.

Don't go thinking that DelphiX is a magic bullet. If a function seems to cause an unlikely speed hit, it's possible it could be getting done the hard way on the CPU, rather than hardware-accelerated as with a 3d API.

But I don't want you to take this message as me trying to force you off DelphiX. I'd advise you to wean yourself off it, however, for upcoming projects (maybe by slowing building up your own framework, like everyone and their dog have done for Delphi so far ;), or by using something else a bit newer -- most of component sets that have their own forums on the front page, for example).

theWaver
04-02-2004, 07:44 PM
This is slightly off-topic, but it explains Clootie's initial reply ("Use Direct3D"). Any alpha blending (translucency) you do in DirectDraw is not hardware accelerated -- it's done on the CPU instead, which is the reason why it's such a hit (the CPU goes over the images pixel-by-pixel and can't do much else until this is done). You do get transparency (colour keying) in DDraw, which is just an on/off toggle of image colours. However, do not get lulled into thinking that every function call you make to DelphiX will be done on hardware, because a lot of them aren't.

The only ways to speed up translucency are to optimise the DelphiX translucency routines using hardcore code (e.g. hand-crafted assembly, MMX, SSE1 and/or 2, depending on the needs -- MMX is usually good here) or to use 3D hardware to your advantage. However, the speed-up-DelphiX option is likely to be more than a little pain in the butt.

Direct3D and OpenGL can be configured to display 2D images (I have a slightly long-winded framework that demonstrates this in a recent thread for OpenGL). With 3D APIs, rotation, scaling and translucency are all on hardware, which means they get chewed up and spat out by the graphics card without any hassle. The net result is that these special effects are very much faster.

Don't go thinking that DelphiX is a magic bullet. If a function seems to cause an unlikely speed hit, it's possible it could be getting done the hard way on the CPU, rather than hardware-accelerated as with a 3d API.

But I don't want you to take this message as me trying to force you off DelphiX. I'd advise you to wean yourself off it, however, for upcoming projects (maybe by slowing building up your own framework, like everyone and their dog have done for Delphi so far ;), or by using something else a bit newer -- most of component sets that have their own forums on the front page, for example).

Ok, thanks.

Look, here's the deal, i'm using Delphi7 and WinXP, plus DirectX, so, what other component set do you propose me? I need to know where to get both the suite and the manuals to learn how to use it. If you can help me out with this one i'd be very gratefull. :D

Bobby
08-02-2004, 05:08 PM
Hi, there are lots of ones out there, take a look at the front page of the forums and you will see a list of some of the more popular ones that our out there. Just post in those forums to get information about each one.

Thanks

Bobby
Omega Components

theWaver
08-02-2004, 07:12 PM
Hi, there are lots of ones out there, take a look at the front page of the forums and you will see a list of some of the more popular ones that our out there. Just post in those forums to get information about each one.

Thanks

Bobby
Omega Components

thanks again, but aniwayz, i'd like to know wich one do you suggest me for 2D games with alpha blendings and rotations, zooms, blurs etc? Going to the front page in search for something isn't the ideal solution, since i don't know what a compunent palette is designed for only based on it's name.

Bobby
09-02-2004, 04:33 AM
Well my opinion is obviously biased, but try the components me and my team are working on , www.delphisanctuary.com It's called the omega components, and its a nice set of components. There are lots of component sets out there though :)

Bobby

theWaver
09-02-2004, 07:37 PM
Well my opinion is obviously biased, but try the components me and my team are working on , www.delphisanctuary.com It's called the omega components, and its a nice set of components. There are lots of component sets out there though :)

Bobby

will do, thanks :D