Results 1 to 2 of 2

Thread: Automation error

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    203

    Automation error

    This is the code tt I took frm a DirectX tutorial. The error it givz is simply " Automation Error"


    BTW, Im using a 100MHz M/c...and Win95 if tt cd b any of the probs.



    Option Explicit

    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
    D3DWindow.BackBufferFormat = DispMode.Format

    Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Form1.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)

    InitDX = True

    Exit Function

    ErrHandler:
    InitDX = False
    MsgBox Err.Description

    End Function

    Public Sub Render()

    On Error GoTo ErrHandler

    D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &HCCCCFF, 1#, ByVal 0

    D3DDevice.BeginScene

    D3DDevice.EndScene

    D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0

    Exit Sub

    ErrHandler:
    Running = False

    End Sub

    Private Sub Form_KeyPress(KeyAscii As Integer)
    BRunning = False
    End Sub

    Private Sub Form_Load()

    Me.Show
    Running = InitDX

    While Running
    Render

    DoEvents

    If GetTickCount - LastTimeCheckFPS >= 1000 Then
    LastTimeCheckFPS = GetTickCount
    FrameRate = FramesDrawn
    FramesDrawn = 0
    Me.Caption = "DirectX-Graphics: Lesson 01 {" & FrameRate & "fps}"
    End If

    FramesDrawn = FramesDrawn + 1

    Wend

    Set DX = Nothing
    Set D3D = Nothing
    Set D3DDevice = Nothing
    Unload Me
    End

    End Sub

  2. #2
    Zaei
    Guest
    Do you have a Hardware Accelerator installed in your computer? I am assuming the error occurs in InitDX(), because thats the only place you would get a message box. Try changing D3DDEVTYPE_HAL to D3DDEVTYPE_REF, and see if it works.

    Z.

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