-
flickering
Ok, in the last few programs I've made, I've noticed ALOT of flickering when I move things.
I use image boxes, but I've started to use paintpicture now and it had better performance but it still flickers.... how do I stop it?
(I already read the MSDN thing on it, didn't understand):mad:
-
Paint everything to 1) a hidden picture box with auto-redraw then copy to a visiable picture box with/out auto-redraw or 2) to a visable picture box with auto-redraw, then refresh the picture box.
I belive that bitblt will give you even better proformance.
If you wish to see some demos, find a post by Fox, then goto his website.
-
try this
'---DirectX ----
Dim DX As New DirectX8
Dim D3D As Direct3D8
Dim D3DDevice As Direct3DDevice8
Dim Running As Boolean
Private Declare Function GetTickCount Lib "kernel32" () As Long '//This is used to get the frame rate.
Dim LastTimeCheckFPS As Long
Dim FramesDrawn As Long
Dim FrameRate As Long
Public Function InitDX() As Boolean
On Error GoTo ErrHandler
Dim DispMode As D3DDISPLAYMODE
Dim D3DWindow As D3DPRESENT_PARAMETERS
Set DX = New DirectX8
Set D3D = DX.Direct3DCreate
D3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, DispMode
D3DWindow.Windowed = 1
D3DWindow.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC 'put in memory and then display it
D3DWindow.BackBufferFormat = DispMode.Format
Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, game.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)
InitDX = True
Exit Function
ErrHandler:
InitDX = False
End Function
On Error GoTo ErrHandler
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &H0&, 1#, ByVal 0
D3DDevice.BeginScene
'render stuff here
D3DDevice.EndScene
D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
Exit Sub
ErrHandler:
Running = False
End Sub
Me.Show
Running = InitDX
While Running
Render
DoEvents
If GetTickCount - LastTimeCheckFPS >= 1000 Then
LastTimeCheckFPS = GetTickCount
FrameRate = FramesDrawn
FramesDrawn = 0
Me.Caption = "Blok Headz {" & FrameRate & "fps}"
End If
FramesDrawn = FramesDrawn + 1
Wend
Set DX = Nothing
Set D3D = Nothing
Set D3DDevice = Nothing
Unload Me
End
Private Sub Form_KeyPress(KeyAscii As Integer)
Running = False
End Sub
-
I figured that sence he just moved from image boxes to paintpicture, he is barely ready for bitblt, let along direct x...
I may be wrong, but using image boxes don't excatly say that you have lots of knowladge in & graphics programming...
-
I'm with Gaming. Move him onto bitblt before charging into DX. Bitblt is more than powerful enough for most peoples needs...