[2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers [2005] DirectX Animation Flickers [2005] DirectX Animation Flickers [2005] DirectX Animation Flickers [2005] DirectX Animation Flickers [2005] DirectX Animation Flickers [2005] DirectX Animation Flickers [2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers [2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers
Go Back  Xtreme Visual Basic Talk > > > > [2005] DirectX Animation Flickers


Reply
 
Thread Tools Display Modes
  #1  
Old 07-07-2007, 01:30 PM
nicholson_greg nicholson_greg is offline
Newcomer
 
Join Date: Mar 2004
Posts: 3
Default [2005] DirectX Animation Flickers


Can someone tell me how to stop this flickering please?

Imports Microsoft.DirectX
Imports Microsoft.DirectX.DirectDraw
Public Class MainForm
Dim pacx, pacy As Integer
Dim primary As Surface = Nothing 'The primary surface will be attached to the device object
Dim secondary As Surface = Nothing
Dim pacLeft1 As Surface = Nothing
Dim pacBlack As Surface = Nothing
Private GraphicsClipper As Clipper
Dim dd_rect As Rectangle
Dim GraphicsCard As Device = Nothing
Public Sub InitializeGraphics()
GraphicsCard = New Device
GraphicsCard.SetCooperativeLevel(Me, CooperativeLevelFlags.Normal)
Dim description As SurfaceDescription = New SurfaceDescription
description.SurfaceCaps.PrimarySurface = True
primary = New Surface(description, GraphicsCard)
description.Clear()
With description
.Width = dd_rect.Width
.Height = dd_rect.Height
.SurfaceCaps.OffScreenPlain = True
End With
secondary = New Surface(MazeForm.MazePic.Image, description, GraphicsCard)
'-------------------------------------------------------------------------
description.Clear()
With description
.Width = SpritesForm.PacLeftPic1.Width
.Height = SpritesForm.PacLeftPic1.Height
.SurfaceCaps.OffScreenPlain = True
End With
pacLeft1 = New Surface(SpritesForm.PacLeftPic1.Image, description, GraphicsCard)
pacBlack = New Surface(SpritesForm.PacBlackPic.Image, description, GraphicsCard)
'-------------------------------------------------------------------------
'the clipper makes sure the surface is drawn over the window
GraphicsClipper = New Clipper(GraphicsCard)
GraphicsClipper.Window = Me
primary.Clipper = GraphicsClipper
description = Nothing
End Sub
Shared Sub Main()
Dim frm As New MainForm
frm.Show()
frm.dd_rect = New Rectangle(15, 64, 993, 639)
frm.InitializeGraphics()
frm.pacx = 474
frm.pacy = 464
Do While frm.Created = True
Try
'frm.secondary.ColorFill(Color.Blue)

Dim dest_rect = New Rectangle(frm.pacx, frm.pacy, SpritesForm.PacLeftPic1.Width, SpritesForm.PacLeftPic1.Height)
frm.secondary.DrawFast(frm.pacx, frm.pacy, frm.pacLeft1, DrawFastFlags.Wait)
frm.primary.Draw(frm.dd_rect, frm.secondary, DrawFlags.Async) 'flip backbuffer to the rect of window
Dim pause As Long
For pause = 1 To 500000
Next


frm.secondary.DrawFast(frm.pacx, frm.pacy, frm.pacBlack, DrawFastFlags.Wait)
frm.primary.Draw(frm.dd_rect, frm.secondary, DrawFlags.Wait)
Catch err As WasStillDrawingException
Catch err As SurfaceLostException
frm.RestoreSurfaces()
End Try
frm.pacx -= 1
If frm.pacx < 20 Then frm.pacx = 474
Application.DoEvents() 'allow Windows to continue its work
Loop
End Sub
Private Sub RestoreSurfaces()
Try
GraphicsCard.RestoreAllSurfaces()
Catch
Debug.WriteLine("Can't restore surfaces right now.")
Exit Sub
End Try
End Sub

Private Sub QuitBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitBtn.Click
Me.Close()
End Sub
End Class
Attached Files
File Type: zip DD_Pacman.zip (189.1 KB, 14 views)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
[2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers [2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers [2005] DirectX Animation Flickers [2005] DirectX Animation Flickers [2005] DirectX Animation Flickers [2005] DirectX Animation Flickers [2005] DirectX Animation Flickers [2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers
 
[2005] DirectX Animation Flickers
[2005] DirectX Animation Flickers
 
-->