Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   Managed DirectX (http://www.xtremevbtalk.com/managed-directx/)
-   -   simple DirectX program using VB 2008 (http://www.xtremevbtalk.com/managed-directx/323501-simple-directx-program-using-vb-2008-a.html)

andreasjo 03-01-2012 01:38 AM

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


PlausiblyDamp 03-01-2012 01:54 AM

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.


All times are GMT -6. The time now is 07:14 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.