Jump to content
Xtreme .Net Talk

DX8 Problems with .Net


Recommended Posts

Guest ShahMat
Posted

I'm 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 wouldn't line up correctly with it) but I can't get it to work correctly. I keep implementing my vertices as an array of D3DTLVERTEX UDTs, as I've 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. I've tried and tried to create an IntPtr to the first element of the D3DTLVERTEX array and nothing seems to work. Is there something I'm 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 I'm 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.

Guest ShahMat
Posted

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 who's interested in DX8 programming with .Net...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...