DX8 Problems with .Net

  • Thread starter Thread starter ShahMat
  • Start date Start date
S

ShahMat

Guest
Im working on a DX8 sprite engine using TriangleStrips as textured quads (somebody said that the MS implementation of DXSprite was screwed up and that tiles wouldnt line up correctly with it) but I cant get it to work correctly. I keep implementing my vertices as an array of D3DTLVERTEX UDTs, as Ive seen in several tutorials, but the type library keeps insisting that the first element in the array when calling DrawPrimitive (DrawPrimitiveUP) should be an IntPtr. Ive tried and tried to create an IntPtr to the first element of the D3DTLVERTEX array and nothing seems to work. Is there something Im missing that can do a type conversion in this case or should I just write a wrapper for this function (and a few others) in VB6 and import them as a COM dll?

PS Im not sure if this should go in the DirectX forum or the .Net forum, but as the problem is with the .Net type library, I figured this was the best place for it.
 
Okay, found it, but what a lot of work!

Alright, I found a way to convert the array to an IntPtr. Jeez, this was a whole lot easier in C++... :eek:

Dim ptrval As New IntPtr()
Dim handle As System.Runtime.InteropServices.GCHandle
handle = System.Runtime.InteropServices.GCHandle.Alloc(Sprites(SpriteNum).Verts, System.Runtime.InteropServices.GCHandleType.Pinned)
ptrval = handle.AddrOfPinnedObject
Call .DrawPrimitiveUP(DxVBLibA.CONST_D3DPRIMITIVETYPE.D3DPT_TRIANGLESTRIP, 2, ptrval, Len(Sprites(SpriteNum).Verts(0)))


Hope this helps anybody whos interested in DX8 programming with .Net...
 
Back
Top