Results 1 to 20 of 20

Thread: Simple DX8 - Why won't it work?

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417

    Simple DX8 - Why won't it work?

    I am...pretty new to DX in VB. But I'm trying. So I would like anyone to help me figuring out why this won't work.. I'm trying to render a triangle in Full-Screen mode..:P
    VB Code:
    1. Dim DX As New DirectX8
    2. Dim D3D As Direct3D8
    3. Dim D3DDevice As Direct3DDevice8
    4.  
    5. Private Const MyFVF = D3DFVF_XYZ Or D3DFVF_DIFFUSE
    6. Private Type VERTEX
    7.     X As Single
    8.     Y As Single
    9.     Z As Single
    10.     Color As Long
    11. End Type
    12.  
    13. Dim Trekant(0 To 2) As VERTEX
    14. Dim bStop As Boolean
    15.  
    16. Private Sub Form_Click()
    17. bStop = True
    18. End Sub
    19.  
    20. Private Sub Form_Load()
    21. Set DX = New DirectX8
    22. Set D3D = DX.Direct3DCreate
    23.  
    24. Call Initialize
    25. Call CreateGeometry
    26.  
    27. Do Until bStop = True
    28. Render
    29. DoEvents
    30. Loop
    31.  
    32. Unload Me
    33. End
    34. End Sub
    35.  
    36. Sub Initialize()
    37.  
    38. Dim DisplayMode As D3DDISPLAYMODE
    39. Dim D3DPP As D3DPRESENT_PARAMETERS
    40.  
    41. DisplayMode.Format = D3DFMT_R5G6B5
    42. DisplayMode.Width = 640
    43. DisplayMode.Height = 480
    44.  
    45. D3DPP.SwapEffect = D3DSWAPEFFECT_FLIP
    46. D3DPP.BackBufferCount = 1
    47. D3DPP.BackBufferWidth = 640
    48. D3DPP.BackBufferHeight = 480
    49. D3DPP.BackBufferFormat = DisplayMode.Format
    50. D3DPP.hDeviceWindow = Form1.hWnd
    51.  
    52. Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Form1.hWnd, _
    53.                                 D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DPP)
    54.                                
    55. D3DDevice.SetRenderState D3DRS_LIGHTING Or D3DRS_CULLMODE, False Or D3DCULL_NONE
    56. D3DDevice.SetVertexShader MyFVF
    57. End Sub
    58.  
    59. Sub Render()
    60. D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, 0, 1#, 0
    61.  
    62. D3DDevice.BeginScene
    63.  
    64. D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLELIST, 1, Trekant(0), Len(Trekant(0))
    65.  
    66. D3DDevice.EndScene
    67. D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
    68. End Sub
    69. Sub CreateGeometry()
    70. Trekant(0) = CrtVertex(10, 10, 0, RGB(255, 0, 0))
    71. Trekant(1) = CrtVertex(10, 200, 0, RGB(255, 0, 0))
    72. Trekant(2) = CrtVertex(200, 10, 0, RGB(255, 0, 0))
    73. End Sub
    74.  
    75. Private Function CrtVertex(X As Single, Y As Single, Z As Single, Color As Long) As VERTEX
    76. CrtVertex.X = X
    77. CrtVertex.Y = Y
    78. CrtVertex.Z = Z
    79. CrtVertex.Color = Color
    80. End Function

    In advance, thank you
    -Lars Espen Rosness
    Last edited by rEaL iGoR; May 11th, 2002 at 02:11 PM.
    VB, ADO, SQL, 3DSMAX, DHTML, VBscript, Javascript, CSS

    -Lars Espen Rosness

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