Terrible Flickering with DirectDraw

JonasE

Newcomer
Joined
Aug 18, 2004
Messages
5
Location
Sweden
I try to make a simple game, but when I create Graphics it flicker where bad. Even then I use a back buffer (double buffering). I draw to a Panel and not full screen.

First I create surface like this.

DDDevice = New Device(CreateFlags.Default)
DDDevice.SetCooperativeLevel(Panel, CooperativeLevelFlags.Normal)

CK.ColorSpaceHighValue = RGB(0, 0, 0)
CK.ColorSpaceLowValue = RGB(0, 0, 0)

SDesc.SurfaceCaps.PrimarySurface = True
FrontSurface = New Surface(SDesc, DDDevice)

SDesc.SurfaceCaps.PrimarySurface = False
SDesc.SurfaceCaps.OffScreenPlain = True
SDesc.SurfaceCaps.VideoMemory = True
SDesc.Height = Panel.Bottom - Panel.Top
SDesc.Width = Panel.Right - Panel.Left

BackSurface = New Surface(SDesc, DDDevice)
BackSurface.SetColorKey(ColorKeyFlags.SourceDraw, CK)

Clip = New Clipper(DDDevice)
Clip.Window = Panel
FrontSurface.Clipper = Clip

SDesc.Clear()
SDesc.SurfaceCaps.OffScreenPlain = True
SpriteSurface = New Surface("Sprite.bmp", SDesc, DDDevice)
SpriteSurface.SetColorKey(ColorKeyFlags.SourceDraw, CK)

SDesc.Clear()
SDesc.SurfaceCaps.OffScreenPlain = True
MapSurface = New Surface("BackGround.bmp", SDesc, DDDevice)



When I draw I do this.



Try
BackSurface.ColorFill(Color.Blue)
BackSurface.DrawFast(0, 0, MapSurface, Map.Rect, DrawFastFlags.DoNotWait)
BackSurface.DrawFast(0, 0, SpriteSurface, DrawFastFlags.SourceColorKey)
Catch ex As SurfaceLostException
InitializeSurface()
End Try

Dest = New Rectangle(PointToScreen(Panel.Location), Panel.ClientSize)
FrontSurface.Draw(Dest, BackSurface, DrawFlags.Wait)



Why does this program flicker so badly? :mad:
 
BackSurface.DrawFast(0, 0, MapSurface, Map.Rect, DrawFastFlags.DoNotWait)

Change that to DrawFastFlags.Wait

See if that helps. Also, you probably shouldn't be using "Draw Fast". Try using BltFast().
 
Flickers with weird colors? In Direct3D (note, not DirectDraw :)), you have to call dxDevice.Clear in order to fix that.

BackSurface.ColorFill(Color.Blue) <-- maybe there's a BackSurface.Clear somewhere

-The Pentium Guy
 
It doesn’t help. I post the program, maybe someone can figurate it out.

So far - it not doing so much, a red rectangle scroll from left to right, then you press right key. The background I very ugly, it base on tiles (32,32) and I have just pick three rectangles (pink, brown and light blue).
 

Attachments

Last edited by a moderator:
:confused:

Maybe it because I use Windows 2000, and try to run it on my Work computer. Licenses and other program creates conflicts.

I don’t know, i give up.. :(

Thanks anyway.
 
Back
Top