PDA

View Full Version : DDraw tutorial



Alimonster
05-02-2003, 11:47 PM
I've finally finished the DirectDraw tutorial. This one shows you how to use DirectDraw w/out using the VCL - i.e., the underlying setting-up-and-wrapping-around DDraw. The result is a pretty darned small exe - the example code ended up at 19K with no thoughts about size optimisation at all!

It's a big two-parter and it's over here (http://www.alistairkeys.co.uk/ddraw1.shtml).

Next, I'll finish off the timing tutorial, then completely rewrite the tiles one.

Sly
06-02-2003, 03:23 AM
Dang! Can't get to your site at the moment. It's not responding. Will try again later.

Alimonster
06-02-2003, 12:12 PM
The site seems to have recovered from that hiccup. Sorry about that!

savage
07-02-2003, 01:45 AM
The tutorials looks great!
Do you give me permission to mirror the tutorials on DelphiGamer.com?


Dom.

Sly
07-02-2003, 03:46 AM
Just a comment on the tutorial. Clippers are only required if running in windowed mode.

An alternative on using clippers is the following code. This is taken straight from my own DirectDraw7 component. { Create and attach clipper to the primary surface. }
FDirectDraw.CreateClipper(0, FClipper, nil);
FClipper.SetHWnd(0, FWindowHandle);
FPrimarySurface.Surface.SetClipper(FClipper);
This just creates a clipper for the entire window in three easy steps. Of course, you should check return values of those calls. To remove the clipper, the following code does the trick. FBackSurface.ReleaseSurface;
{ Release the clipper if it exists. }
if Assigned(FClipper) then
begin
FPrimarySurface.Surface.SetClipper(nil);
FClipper := nil;
end;
FPrimarySurface.ReleaseSurface;

Alimonster
07-02-2003, 09:30 AM
Are you sure about only needing clippers for windowed mode? If you get rid of the clipper and display a pic that's falls even a little off the screen in fullscreen, none the pic is displayed (IME). With a clipper, the pic is displayed clipped to the screen edge :?. I tried changing the example code so that the monster pic is displayed with a right of "SCREEN_WIDTH + 25 instead of SCREEN_WIDTH - 25 - i.e., a little off the screen. It only displayed when I attached a clipper. Hmm.

Thanks for the simpler method of adding clippers - I'll add that to the tutorial when I get home.

Sly
07-02-2003, 12:28 PM
I think I'm certain. It has been a while since I have played with DirectDraw7, so I've forgotten some of the details. I know from my code that I only added a clipper if it was not in fullscreen mode. I might have to give it another test over the weekend.

Just spent a few minutes looking over my old code. It seems that I always clipped the rects myself before using BltFast. The clipper was just to handle overlapping windows.

10:20pm on a Friday night and I'm still at work. One week to go till the next milestone and four levels to complete. Such is the life of a games developer... :(

savage
07-02-2003, 12:54 PM
Shouldn't that :( be a :D. Or is it really too much hassle?

Alimonster
07-02-2003, 12:58 PM
I think I'm certain. It has been a while since I have played with DirectDraw7, so I've forgotten some of the details. I know from my code that I only added a clipper if it was not in fullscreen mode. I might have to give it another test over the weekend.

Just spent a few minutes looking over my old code. It seems that I always clipped the rects myself before using BltFast. The clipper was just to handle overlapping windows.

10:20pm on a Friday night and I'm still at work. One week to go till the next milestone and four levels to complete. Such is the life of a games developer... :(
Ah, I'm not doing clipping manually - I let the clipper keep everything on screen, rather than checking the areas myself per-blit. I'll have to do some tests to see which is faster. I only ever used the clipper because it's the path of least resistance. I'll get back with the results later.

Sorry to hear that you're still working so late. My job might be boring, but at least it's only 9-5. Btw, being nosy, what game is it you're doing at the moment?

savage
09-02-2003, 05:59 PM
Hi Ali,
I have been trying to access your website all week-end with very little success

Alimonster
09-02-2003, 06:05 PM
Sigh. I'm not sure what's going on with the site, but it's to do with the hosting company rather than mine specifically - I've tried other sites hosted by them and the hosting company themselves and they've all gone too. It should hopefully be a temporary thing.

I've sent you a mail with the tutorial zip attached. Looks like a mirror is going to come in handy if this keeps up! :(

BlueCat
09-02-2003, 06:14 PM
If you want me to mirror it here that's no problem 8)

Alimonster
09-02-2003, 06:43 PM
If you want me to mirror it here that's no problem 8)
Ta for the offer but savage offered a mirror first. I'll let you fight him in a rocket launcher duel for the honour, if you're desperate. (Guess what I've been doing on my PC on Saturday ;))

BlueCat
09-02-2003, 08:25 PM
(Guess what I've been doing on my PC on Saturday ;))

I hope you mean what I think you mean :toothy:

Alimonster
09-02-2003, 09:51 PM
(Guess what I've been doing on my PC on Saturday ;))

I hope you mean what I think you mean :toothy:
I meant that I was playing UT 2003! What are you implying? :shock:

Looks like my site is back up again. I should really find out what's going on but I find that problems fix themselves if left alone. I'm not sure why that is. :scratch:

Sly
09-02-2003, 11:12 PM
Shouldn't that :( be a :D. Or is it really too much hassle?Most of the time it's a great job. The long hours and pressure get to you sometimes though.


Btw, being nosy, what game is it you're doing at the moment?The sequel to Ty the Tasmanian Tiger. I can mention that because it has been revealed in other press items already. :)