Jump to content
  • Advertisement
Sign in to follow this  

DirectX 9 DrawUserPrimitives Issue[VB.NET]

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

If you intended to correct an error in the post then please contact us.

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)


device.Clear(ClearFlags.Target, Color.Yellow, 1, 0)

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)

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 this post

Link to post
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 this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!