Playing Catch-up

bri189a

Well-known member
Joined
Sep 11, 2003
Messages
1,004
Location
VA
As always Im playing catch-up; I didnt get .NET until last year, and that is when I switched from VB6 to C#.NET; I like C# better by the way - more intuitive. Anyway, graphics is always a fun thing to play with and Ive always be a self-teacher so I know Im doing somethings wrong (as far as best practices), but thats for a later post.

Looking around 30 fps for painting full screen seems to be standard (maybe not) with GDI+, regardless, my experiances playing with Flash 5 have taught me that things (objects) moving fast across the screen dont look (appear) smooth at this frame rate, you almost need triple that speed with your movement increments decreased (going 1 pixel per frame rather than 6) for it to appear both fast and smooth. My question is for you gurus... is 30 fps fast enough for action games where things are constantly moving or should GDI+ strictly be used for board-like/card games that arent graphic intensive? And if it is fast enough how do you get to not appear choppy because your moving objects 6+ pixels per frame for it to appear to me moving fast?

Also it would seem that if you could tell GDI+ to only repaint what needs repainting it would be able to run faster; is there a way to do this?

And one last thing; I read in a post about manually double buffering? How do you do that? Ive been doing:

this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);

Is this wrong? Maybe an alternative would increase the fps? Example please.

I played with BeginRegion() and EndRegion() just to see what it does, but is there a real-world use for it?

Sorry for the length, but Im trying to play catch-up with the rest of the programming world, Ill save the rest of my qs for later :)

Brian
 
Manual Double Buffing is done the way you did it in VB- BitBlt instead of DrawImage.

About repainting, do you mean repainting a rectangle withing the area that needs it? If so, just repaint the e.ClipRectangle of OnPaint or your Paint event.

When making the control repaint you can send just a rectangle of the area you want painted too, to speed things up. Although, with a game you are going to most likely want to repaint the whole screen anyway.

If you really want speed for a game, use DX9. Ive seen it, and its fast.
 
Obviously DX9 is the fastest; Im just trying to get the basics down in GDI+ then move up from there once I get a firm grasp (cause Im still a little edgy) on transformations, vectors, working with the things that as someone whos mostly done db apps hasnt had much experiance in.

Um, BitBlt was an API call if I remember right; guess the same here Im assuming?... Like I said, most db apps in the past. Thanks though, this gives me a good starting point to continue researching and practicing on.... Ill catch up with you guys eventually! :)
 
2 things I should mention:
1- For speed use DrawImageUnscaled
2- For more speed use what is called a CatchedBitmap
Note: I have not tried the CatchedBitmap yet. But I have heard it is alot faster.
 
Back
Top