Get the latest Education e-news

Go Back   Game Career Guide Forums > Programming
Forum Home Register Members List Mark Forums Read

Closed Thread
Thread Tools Display Modes
Old 12-21-2009, 02:33 AM   #1
Junior Member

Activity Longevity
0/20 15/20
Today Posts
0/11 ssssssss2
Default (slimdx)my first triangle, i need help

Hi everyone i am creating my first triangle in visual basic with slimdx, but i doesn´t work,PLease anyone could check my code and tell me what is wrong?

here is the link to download the visual basid project if you want to execute it:

and if you prefer here is all the code:

Imports SlimDX
Imports SlimDX.Direct3D9
Public Class Form1
Private device As Device
Public d3d9 As New SlimDX.Direct3D9.Direct3D

Public Structure CustomDiffuse
Public Position As Vector3
Public Color As Int32

End Structure

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

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.Text = "SlimDX Tutorial using Visual Basic"


End Sub

Private Sub form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

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

device.MultiplyTransform(TransformState.Projection , Matrix.PerspectiveFovLH(Math.PI / 4, _
Me.Width / Me.Height, 1.0F, 50.0F))
device.SetRenderState(RenderState.Lighting, False)

device.MultiplyTransform(TransformState.View, Matrix.LookAtLH(New Vector3(0, 0, 30), New Vector3(0, 0, 0), New Vector3(0, 1, 0)))
device.MultiplyTransform(TransformState.World, Matrix.Identity)

Dim vertices As CustomDiffuse() = New CustomDiffuse(0 To 2) {} 'create an array of vertices
vertices(0).Position = New Vector3(0, 0, 0)
vertices(0).Color = Color.Blue.ToArgb

vertices(1).Position = New Vector3(10, 0, 0)
vertices(1).Color = Color.Yellow.ToArgb

vertices(2).Position = New Vector3(5, 10, 0)
vertices(2).Color = Color.Green.ToArgb

Dim vertbuf As New VertexBuffer(device, vertices.Length * 16, Usage.WriteOnly, VertexFormat.Position / VertexFormat.Diffuse, Pool.Default)

Dim stream As DataStream = vertbuf.Lock(0, 20, LockFlags.None)

device.BeginScene() 'all drawings after this line
device.SetStreamSource(0, vertbuf, 0, 16)
device.VertexFormat = VertexFormat.Position / VertexFormat.Diffuse

device.DrawUserPrimitives(PrimitiveType.TriangleLi st, 0, 1, vertices)

device.EndScene() 'all drawings before this line

End Sub
End Class
jor1980 is offline  
Old 12-21-2009, 04:40 AM   #2
yaustar's Avatar

Activity Longevity
2/20 19/20
Today Posts
1/11 sssss2328
Location: UK

You already posted on where one of the programmers that works on slimdx normally hangs about so I am going to close this thread.
yaustar is offline  
Closed Thread

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

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

Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.
All times are GMT -8. The time now is 08:24 AM.

UBM Tech