Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET Game Programming > Managed DirectX > simple DirectX program using VB 2008


Reply
 
Thread Tools Display Modes
  #1  
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
  #2  
Old 03-01-2012, 01:54 AM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 1,908
Default

This can happen if you are running a .net executable that is built for either x64 or the AnyCpu architecture on a 64 bit machine as some versions of DirectX are 32 bit only. Try setting the build option of your application to target x86 and see if that helps.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->