In general, void*
would be converted to IntPtr
in C# code.
Edit with a bit more information: IntPtr
in .NET/C# often behaves like an opaque handle. You can't directly dereference it, obtain "size" information from it (e.g. the size of an array you're pointing at), and it doesn't try to tell you what data type it's pointing at - or even if it's a pointer at all. When you are translating C/C++ code to C# and you see void*
, the C# code should be written with IntPtr
until you have a better idea what exactly you're dealing with.
The pinvoke.net site has two entries for glTexImage2D
, depending on where the image data is stored. If the image data is stored in a managed byte[]
in .NET/C#, you call the version that passes a byte[]
. If the image data is stored in unmanaged memory and you only have an IntPtr
to the data in the C# code, you call the version that passes an IntPtr
.
Examples from pinvoke.net opengl32:
[DllImport(LIBRARY_OPENGL)] protected static extern void glTexImage2D (
uint target,
int level,
int internalformat,
int width,
int height,
int border,
uint format,
uint type,
byte[] pixels);
[DllImport(LIBRARY_OPENGL)] protected static extern void glTexImage2D (
uint target,
int level,
int internalformat,
int width,
int height,
int border,
uint format,
uint type,
IntPtr pixels);