Jump to content
  • Advertisement
Sign in to follow this  
snk_kid

[.net] Is this safe? (C#)

This topic is 4160 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all is this safe to do:
fixed(Vector3F* vptr = &batch.vertices[0])
{
   Gl.glBufferData(Gl.GL_ARRAY_BUFFER, sizeof(Vector3F) * batch.vertices.Length, (IntPtr)vptr, Gl.GL_STATIC_DRAW);
}
Basically i want to pass an array of structs to Tao without copying/flattening.

Share this post


Link to post
Share on other sites
Advertisement
Its not "Safe" in the .Net sense of the term since you can only use "fixed" in an unsafe context. But its the correct syntax and will work the way you expect it to.

If the library is going to actually hold onto that pointer after the call returns then its definately *NOT* safe in any sense. You'll have to allocate an array from unmanaged system memory using System.Runtime.InteropServices.Marshal

Share this post


Link to post
Share on other sites
Quote:
Original post by dalep
Its not "Safe" in the .Net sense of the term since you can only use "fixed" in an unsafe context.


Yes i know it was bad choice of words on my part but i thought it should have been obvious what i meant.

Quote:
Original post by dalep
If the library is going to actually hold onto that pointer after the call returns then its definately *NOT* safe in any sense. You'll have to allocate an array from unmanaged system memory using System.Runtime.InteropServices.Marshal


I am aware of that fact and no the call should not take control, glBufferData copies data into a vertex buffer object.

Anyways thats all i wanted to know so thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!