Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


DirectX 9 DrawUserPrimitives Issue[VB.NET]


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 addy914   Members   -  Reputation: 158

Like
0Likes
Like

Posted 29 May 2012 - 09:02 PM

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, 29 May 2012 - 09:03 PM.


Sponsor:

#2 DJTN   Members   -  Reputation: 207

Like
0Likes
Like

Posted 30 May 2012 - 09:12 AM

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, 30 May 2012 - 09:13 AM.


#3 addy914   Members   -  Reputation: 158

Like
0Likes
Like

Posted 30 May 2012 - 09:46 AM

That was the issue at hand. Thank you for that, I would have never guessed.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS