PDA

View Full Version : DX or GDI?



Padu
14-01-2003, 06:38 PM
I know that directX is a zillion times faster than GDI and I think there will be no other option for me than directX, but let me share with you what I'm doing and then you tell me if I'm in the right path.

I'm creating a game very similar to pool. Basically I need the table surface and round objects that will slide/roll over this surface.
As a test, I've created the table using a canvas, but when I created the balls and made them slide on my table, I had a horrible flicker (I'm not erasing the background and I'm using double buffering already).

Here it is my rethorical question: should I keep using GDI or should I go to directX? I kind of like GDI because I don't have to worry about the directX version inferno, neither I have to worry about what OS my user is using, and I don't know how much more difficult directX is compared to drawing on a canvas.

Any suggestions?

Thanks

Xorcist
14-01-2003, 06:48 PM
try SDL, it should work fine, and it's completely crossplatform. Not to mention it includes other aspects on top of graphics like input and sound.

Momor
14-01-2003, 07:14 PM
Hmm I'm not sure SDL will be of any help here, since this application seems to be VCL-based (???)

The flicker you talk about is not normal. How do you make your double-buffering ? Do you draw to an offscreen canvas and then blit the whole offscreen canvas to the visible one ?

If you could extract the core paint loop of your app, we might help you further.

Padu
14-01-2003, 07:50 PM
Basically I'm using a second TBitmap to draw offscreen and then I use CopyRect. I tried to use BitLlt but I run into some problems. I've read somewhere that CopyRect and BitBlt have minimal or no performance difference.

Right now it is VCL based (TGraphicControl inherited), but it doesn't need to be. My goal is to have a really smoth sliding effect, just like a pool ball.

I also need to implement some sort of colision detection algorithm, but I realize that it has nothing to do with what display architecture I will use.

Alimonster
14-01-2003, 08:18 PM
I'd strongly recommend that you avoid GDI. It's really not very good. If you're worried about the learning curve, you could do worse than taking a look at Graphics32 (http://www.g32.org/graphics32/index.html). It's much more fully featured than the VCL stuff (check out the demo programs at that URL, showing off anti-aliasing, blending, layers, rotation, etc.). Most importantly, it's flicker free!

For the best speed, you should take a look at one of the many component sets out there wrapping up Direct3D, DirectDraw or OpenGL. There are plenty - for some names, just a have a look around the forum ;) [DelphiX, PowerDraw, Omega Project, SDL, GLScene, GLXTreem, GameVision, and so on!].

Don't let unfamiliarity stop you from trying out different libraries. The GDI is really rather inadequate the moment you need to do something interesting. You will be surprised by how much better the alternatives are in speed and quality once you are used to them.

About the collision detection: check out a couple of articles over at gamasutra (http://www.gamasutra.com), Physics on the back of a cocktail napkin (http://www.gamasutra.com/features/20000516/lander_01.htm) and a later one, Pool hall lessons: fast, accurate collision detection between circles or spheres (http://www.gamasutra.com/features/20020118/vandenhuevel_01.htm) -- free registration required before you can see the articles.

Padu
14-01-2003, 08:21 PM
I'm reading the last one, looks very appropriate to what I'm trying to do. I think you guys convinced me to try something else.

Clootie
15-01-2003, 09:42 PM
Flickering is probably caused by your usage of TGraphicsControl - try change it to TCustomControl or even just to TPanel and enjoy the difference!

Padu
15-01-2003, 11:06 PM
You know what... yesterday I've donwloaded delphiX and played with it a little bit. I made up my mind. It's sooo easy to work with, and the results are explendid for my application.

I think I'll just forget about the VCL and go directX

Clootie
16-01-2003, 12:05 AM
Don't forget what original DelphiX uses DirectX 5 only. But there is UnDelphiX port (don't know is it supports DirectX 6 or DirectX 7).

Padu
16-01-2003, 12:11 AM
So, which library is the best one for directX, what version of directX is everybody using these days?

Sly
16-01-2003, 04:10 AM
UnDelphiX was simply an update for DelphiX to use the JEDI DirectX headers instead of the headers provided with DelphiX.

TheLion
16-01-2003, 09:35 PM
I've written a tutorial (both featured in the tutorials forum) on both the Windows Canvas (GDI) and the TDXDraw component. I used the canvas on many occasions for games flickerfree, however in your case I would recommend to go with a library like DirectX / DelphiX or something similar!

I'm not familiar (yet) with any of the other libraries except DelphiX and I know a little of SDL and I think they are both very good. In my personal games I always use DelphiX, since I prefer using DirectX over SDL but that's just a preference and most likely a case of habit and ease since I know DelphiX way better than I know SDL! :)

EDIT : Oh in remark to Clooties comment on DelphiX using DirectX 5 only, If I'm not mistaken then the DelphiX 2000.07.17 uses DirectX 7 headers!