Results 1 to 5 of 5

Thread: flickering

  1. #1

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    Unhappy 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)
    Don't pay attention to this signature, it's contradictory.

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    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.
    Involved in: Sentience

  3. #3
    Lively Member slx47's Avatar
    Join Date
    Apr 2002
    Location
    US
    Posts
    127

    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

  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    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...
    Involved in: Sentience

  5. #5
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    I'm with Gaming. Move him onto bitblt before charging into DX. Bitblt is more than powerful enough for most peoples needs...
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width