Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am unable to use DirectX.Direct3D for reference as it gets ignored

Status
Not open for further replies.

John Alexander

Programmer
Jun 26, 2018
7
0
0
US
thread761-1598689
I have installed Visual Studio 2017 and have tried to use that Triangle example with DirectX 9 in vb.net but unable to use DirectX.Direct3D for a reference. I have no idea on how to proceed. There is an error in code as it says it needs something from Visual C#. I am inserting my 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 'we?ll draw on a window
present.SwapEffect = SwapEffect.Discard 'discuss later
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) 'Do not draw form?s background 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 'encode color in Argb
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() 'all drawings after this line
device.VertexFormat = CustomVertex.TransformedColored.Format
'error for this line says:
'Describes custom vertex format structure that contains transformed vertices and color information.
'Reference required to assembly Microsoft.visualc,Version 7.0.5000.0 culture=neutral,publickey
'tokens= 'b03f5f711d50a3a' containing the type 'isconstmodifier'
'I realize that it needs Microsoft.DirectX.Direct3D but I am unable to get it to go into references.
device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertices)
device.EndScene() 'all drawings before this line
device.Present()
Me.Invalidate() 'redraw
End Sub
End Class
 
How do I remove my question? I have been succesful in creating directX 9 in vb.net,C# and C++. All I had to do was use Version 2 and use Visual C as reference.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top