Results 1 to 2 of 2

Thread: Pointer Problem

  1. #1

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Pointer Problem

    I'm having a hard time figuring out how to get the first element of an array converted into a pointer for an argument in a function. Here's the function's arguments I'm working with:

    VB Code:
    1. <System.Runtime.InteropServices.DllImport("DX8VB.DLL", _
    2.     EntryPoint:="D3DVertexBuffer8SetData", _
    3.     SetLastError:=True, _
    4.     CharSet:=System.Runtime.InteropServices.CharSet.Unicode, _
    5.     ExactSpelling:=True, _
    6.     CallingConvention:=System.Runtime.InteropServices.CallingConvention.StdCall)> _
    7.     Public Shared Function D3DVertexBuffer8SetData(ByRef VBuffer As DxVBLibA.Direct3DVertexBuffer8, ByRef Offset As Long, ByRef Size As Long, ByRef Flags As Long, ByRef Data As System.IntPtr) As Long
    8.  
    9.     End Function

    Where I'm receiving an error at is in the ByRef Data As System.IntPtr argument.

    Here are the values I put in

    VB Code:
    1. D3DAUX.D3DVertexBuffer8SetData(VBuffer, 0, Len(Cube2(0)) * 36, 0, System.IntPtr(Cube2(0)))

    System.IntPtr(Cube2(0)) is where I get the error. It says IntPtr is a type in 'System' and cannot be used as an expression. Any ideas of how I can solve this?!!
    Last edited by Jacob Roman; Nov 21st, 2004 at 04:58 PM.

  2. #2

    Thread Starter
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349
    Sorry. I failed to mention that Cube2(0) was a structure. No wonder it messed up. So I used the Marshal.StructureToPtr() function. But for some reason, even though I didn't receive an error during IDE mode, it messed up during runtime. I'll upload the source code tommorow when I can and see if anyone can get it working. What I'm trying to do is get one of the DirectX8 tutorials from DirectX4VB working through VB.NET. Right now I'm really really close.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width