View Single Post
 
Old 03-01-2012, 01:38 AM
andreasjo andreasjo is offline
Newcomer
 
Join Date: Mar 2012
Posts: 1
Default simple DirectX program using VB 2008

Hello guys ?
Could anyone help me please ?
I managed to build simple DirectX program using VB 2008, but it returns to an error
"BadImageFormatException was unhandled"
"is not a valid Win32 application.(Exception from HRESULT: 0x800700C1)"
Where the mistake ?
Here is my code : (I rewrite it from another's)

please help :



Code:
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D

Public Class Form1

    Dim DEVICE As Direct3D.Device
    Dim BUFFER As VertexBuffer

    Sub INITIALIZDX()
        Dim PRESENT As New PresentParameters
        PRESENT.BackBufferCount = 1
        PRESENT.BackBufferFormat = Manager.Adapters(0).CurrentDisplayMode.Format
        PRESENT.BackBufferHeight = Me.Height
        PRESENT.BackBufferWidth = Me.Width
        PRESENT.Windowed = True
        DEVICE = New Device(0, DeviceType.Hardware, Me.Handle, CreateFlags.SoftwareVertexProcessing, PRESENT)
        DEVICE.RenderState.CullMode = Cull.None
    End Sub

    Sub CREATE_VERTEXBUFFER()
        BUFFER = New VertexBuffer(GetType(CustomVertex.TransformedColored), 3, DEVICE, Usage.None, CustomVertex.TransformedColored.Format, Pool.Managed)
        Dim VER(2) As CustomVertex.TransformedColored
        VER(0) = New CustomVertex.TransformedColored(50, 10, 0, 1, Color.Red.ToArgb)
        VER(1) = New CustomVertex.TransformedColored(200, 15, 0, 1, Color.Green.ToArgb)
        VER(2) = New CustomVertex.TransformedColored(10, 200, 0, 1, Color.Red.ToArgb)
        BUFFER.SetData(VER, 0, LockFlags.None)
    End Sub

    Sub DRAW_ME()
        DEVICE.Clear(ClearFlags.Target, Color.Black, 0, 0)
        DEVICE.BeginScene()
        DEVICE.VertexFormat = CustomVertex.TransformedColored.Format
        DEVICE.SetStreamSource(0, BUFFER, 0)
        DEVICE.DrawPrimitives(PrimitiveType.TriangleList, 0, 1)
        DEVICE.EndScene()
        DEVICE.Present()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        INITIALIZDX()
        CREATE_VERTEXBUFFER()
        Me.Show()
        DRAW_ME()
    End Sub

End Class

Last edited by Flyguy; 03-01-2012 at 01:40 AM. Reason: Please start your own threads for asking questions!
Reply With Quote