Norris's picture

Vbo and MapBuffer with VB.Net. Problem with IntPtr

Hi !
I'm learning how to work with vbo and I can create one and draw it. Now, I want to use "MapBuffer" to access and modify data like in this tutorial

I work with VB.Net and have problem to convert this part to vb.Net as I don't know how to work with pointers.

  fixed ( ushort* SystemMemory = &Indices[0] )
    ushort* VideoMemory = (ushort*) VideoMemoryIntPtr.ToPointer();
    for ( int i = 0; i < Indices.Length; i++ ) 
      VideoMemory[ i ] = SystemMemory[ i ]; // simulate what GL.BufferData would do
GL.UnmapBuffer( BufferTarget.ElementArrayBuffer );

What could be a good conversion of this code please ?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
smiley80's picture

Since VB doesn't support pointers, you have to use Marshal.Copy:

Marshal.Copy(DirectCast(DirectCast(Indices, Object), Short()), 0, VideoMemoryIntPtr, Indices.Length)