J
Jason Bell
While I'm experienced with c# and regular c++, I'm very new to managed
c++ so please bare with me.
Here's the scenario:
I have a function that wraps a pointer to an unmanaged function. I want
the wrapping function to be CLS compliant.
Here's what I have now. It works perfectly, but isn't CLS compliant:
void gle::GenBuffersARB( int number, int * buffer )
{
glGenBuffersARB(number, buffer);
}
glGenBuffersARB is the pointer to the unmanaged function. The second
parameter must be a pointer to an unmanaged int. I tried using Int32s
in the function pointer declaration, but that causes
system.typeloadexception. And before you mention it, yes I do have to
use a function pointer to use this function, you can't do simple
external declarations for OpenGL extensions.
I would like something like this:
void gle::GenBuffersARB( Int32 number, Int32 * buffer )
This is CLS compliant: the second parameter is seen as ref int by c# and
byref by vb.net.
How would I convert a reference to a managed Int32 into a pointer to an
unmanaged int? I looked at __box, but that creates a copy. This won't
work because glGenBuffersARB must change the original "buffer" int
passed to the wrapping function. Even if I could do something like
this, that would help:
copy numbers from Int32 buffer to a new int
pass pointer to the new int to glGenBuffersARB
copy the modified numbers in the int back to the Int32
c++ so please bare with me.
Here's the scenario:
I have a function that wraps a pointer to an unmanaged function. I want
the wrapping function to be CLS compliant.
Here's what I have now. It works perfectly, but isn't CLS compliant:
void gle::GenBuffersARB( int number, int * buffer )
{
glGenBuffersARB(number, buffer);
}
glGenBuffersARB is the pointer to the unmanaged function. The second
parameter must be a pointer to an unmanaged int. I tried using Int32s
in the function pointer declaration, but that causes
system.typeloadexception. And before you mention it, yes I do have to
use a function pointer to use this function, you can't do simple
external declarations for OpenGL extensions.
I would like something like this:
void gle::GenBuffersARB( Int32 number, Int32 * buffer )
This is CLS compliant: the second parameter is seen as ref int by c# and
byref by vb.net.
How would I convert a reference to a managed Int32 into a pointer to an
unmanaged int? I looked at __box, but that creates a copy. This won't
work because glGenBuffersARB must change the original "buffer" int
passed to the wrapping function. Even if I could do something like
this, that would help:
copy numbers from Int32 buffer to a new int
pass pointer to the new int to glGenBuffersARB
copy the modified numbers in the int back to the Int32