# DirectX 9 DrawUserPrimitives Issue[VB.NET]

This topic is 2187 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I am having a issue with Direct3D9 in VB.NET using SlimDX. I do know that SlimDX is just a wrapper of the C++ code into a library basically. I have looked at SlimDX's source, googled for hours, etc. I figured finally I would ask and see what the possibilities could be. I am also aware there is other methods than using DrawUserPrimitives like VertexBuffers, but I will be making a game, so it would be best to just supply the vertices of the primitive and texture. Right now, I am just trying to get an actual triangle to draw. The funny thing is, whenever I switch the primitive type to LineList PointList, then it works, but not when I use TriangleXXX. The return result is that the function completed successfully. I am quite puzzled and would be glad if someone could kindly help me. I will post the majority of my code to help you decipher my problem.

Initialization of Direct3D9 (This is most likely irrelevant to my problem, but just in case)
 direct3D = New Direct3D() Dim deviceSettings As New PresentParameters deviceSettings.BackBufferCount = 1 deviceSettings.DeviceWindowHandle = Me.Handle deviceSettings.Windowed = True deviceSettings.SwapEffect = SwapEffect.Discard deviceSettings.PresentationInterval = PresentInterval.Immediate device = New Device(direct3D, 0, DeviceType.Hardware, Me.Handle, CreateFlags.HardwareVertexProcessing, deviceSettings) 

Form1_Paint:
 device.Clear(ClearFlags.Target, Color.Yellow, 1, 0) device.BeginScene() Dim vertices(3) As CustomVertex vertices(0).position = New Vector3(-0.5!, -0.5!, 0.0!) vertices(1).position = New Vector3(200.0!, 100.0!, 0.0!) vertices(2).position = New Vector3(150.0!, 100.0!, 0.0!) device.VertexFormat = VertexFormat.Position Dim ret As SlimDX.Result = device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertices) device.EndScene() device.Present() 

For the record, CustomVertex is just a Vector3 for the position. I have also tried altering the CustomVertex to have a Integer for color and had that but that did not seem to affect it. Edited by addy914

##### Share on other sites
If culling is enabled, the order of the vertices will be important. Assuming the default counter-clockwise culling state is used, the visible triangles must be drawn in clockwise order. Edited by DJTN

##### Share on other sites
That was the issue at hand. Thank you for that, I would have never guessed.

• 9
• 16
• 9
• 13
• 41