Terrible Flickering with DirectDraw

JonasE

Member
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 shouldnt be using "Draw Fast". Try using BltFast().
 
Flickers in weird colors?? pink light yellow etc?? Try running the app with release and not debug DirectX... Worked for some friend..

--Loffen
 
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 theres a BackSurface.Clear somewhere

-The Pentium Guy
 
: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
 
Back
Top