INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

newbie problem with DirectX

newbie problem with DirectX

(OP)
I am taking my first foray into DirectX and trying the simple triangle tutorial program, however whenever i run the program i am getting the windows form with a large red X throughout it, below is the code i am using copied straight from the website tutorial so it should work just fine, any ideas as to what i need to do to fix this?

Using the latest DirectX SDK in VS2008 on Windows 7 and have all reference to directx included in my project

CODE

Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D

Public Class Form1
    Private device As Direct3D.Device

    Public Sub Initialize()
        Dim present As PresentParameters = New PresentParameters
        present.Windowed = True
        present.SwapEffect = SwapEffect.Discard
        device = New Direct3D.Device(0, DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, present)
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque, True)
        Me.Height = 500
        Me.Width = 500
        Me.Text = "DirectX Tutorial using Visual Basic"

        Initialize()
    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim vertices As CustomVertex.TransformedColored() = New CustomVertex.TransformedColored(0 To 2) {} 'create an array of vertices
        vertices(0).Position = New Vector4(150, 100, 0, 1)
        vertices(0).Color = Color.Red.ToArgb
        vertices(1).Position = New Vector4(Me.Width / 2 + 100, 100, 0, 1)
        vertices(1).Color = Color.Green.ToArgb
        vertices(2).Position = New Vector4(250, 300, 0, 1)
        vertices(2).Color = Color.Yellow.ToArgb

        device.Clear(ClearFlags.Target, Color.Black, 1.0, 0)

        device.BeginScene()
        device.VertexFormat = CustomVertex.TransformedColored.Format
        device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertices)
        device.EndScene()

        device.Present()

        Me.Invalidate()
    End Sub
End Class

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close