JonasE Posted October 21, 2004 Posted October 21, 2004 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: Quote
Aragorn7 Posted October 21, 2004 Posted October 21, 2004 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(). Quote
JonasE Posted October 22, 2004 Author Posted October 22, 2004 No, the same thing.. Flickering like hell.. :( Quote
ThePentiumGuy Posted October 22, 2004 Posted October 22, 2004 Try turning on Me.SetStyle(Controlstyles.Opaque,True) It's possible that the panel is "interfering" with your drawing (Not sure if there's a Panel1.SetStyle). -The Pentium Guy Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Loffen Posted October 23, 2004 Posted October 23, 2004 Flickers in weird colors?? pink light yellow etc?? Try running the app with release and not debug DirectX... Worked for some friend.. --Loffen Quote Erutangis a si tahw
ThePentiumGuy Posted October 23, 2004 Posted October 23, 2004 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 Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
JonasE Posted October 25, 2004 Author Posted October 25, 2004 (edited) 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).Kar.zip Edited October 27, 2004 by PlausiblyDamp Quote
ThePentiumGuy Posted October 25, 2004 Posted October 25, 2004 It works fine for me :). I see no flickering (I'm on a 9800 Pro oc'd to XT speeds btw) Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
JonasE Posted October 26, 2004 Author Posted October 26, 2004 :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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.