PDA

Click to See Complete Forum and Search --> : Real-Time Graphics... ?


Dim A
Sep 14th, 2001, 03:23 PM
Anyone have a simple example of double buffering to eliminate the flashing you get with updating graphics too quickly?

- Dim A

Sastraxi
Sep 14th, 2001, 03:33 PM
With bitblt it's easy if this is what you use...

Bitblt everything to invisible picturebox, with autoredraw on the picturebox.
Bitblt unseen picturebox onto "seen" picturebox.
Clear the invisible picturebox.

With directdraw you create a surface, get a DDSCAPS object and set it's lCaps to ddscaps_backbuffer, and set the primary's lBackBuffer count to 1. Then you set another surface (your backbuffer) to Primary.GetAttachedSurface(DDSCAPS Object)

Jotaf98
Sep 16th, 2001, 06:38 PM
You can use the API Viewer to see how to declare BitBlt... there are lots of articles on that around the net so just search a bit ;)

Sastraxi
Sep 16th, 2001, 09:02 PM
And I've got a tutorial, if you're interested.

http://vbden.tripod.com/articles/invmask.htm

Zaknafein
Sep 17th, 2001, 11:47 AM
What you need is one picturebox to be the gameing field with the AutoRedraw set to true that way you don't need a backbuffered picture box.

What I use is one picture box containing the background for the game and then two for each sprite and mask that I want to move around (or you can read them from disk). You use the bit blit function to drop the background into the main game picturebox then the mask of the first sprite, then the sprite of the first sprite and continue like that for each additional sprite. You should note that the second sprite will be on top of the first one if they overlap at anypoint. then after drawing all the sprites refresh the picturebox (picture1.refresh) there will be no flashing. Also if you did what I did at first and draw both masks then both sprites (like some tutorials show) you will have a problem because they will become transparent when they overlap.

Sastraxi
Sep 17th, 2001, 02:52 PM
Actually I believe there is a noticeable flash if you do this on a slower computer...

Zaknafein
Sep 17th, 2001, 03:29 PM
Not that I know of. It will work flawlessly on a pentium 266. Any slower then that and why would you be designing software for it anyway?

Although I've heard it said that if your designing a game that has a very great number of sprites on the screen at once that this technique will execute slightly slower then if you were using a true backbuffer.

PsychoMark
Sep 18th, 2001, 05:04 AM
Works fine on a P133 too :)

(yeah yeah, I should upgrade, but hey, it still works and it's great for testing my programs and games speeds :))





(and the last one is just a bs excuse, I just don't have the money right now ;))