Skip to main content
gamedev.net
🔒 Locked

C#, IntPtr to array?

Started by nagromo 3 replies 1.9k views
Original Post
nagromo
nagromo
A function from SDL.Net exposes data as IntPtr, while Tao.OpenGL wants a byte[] for texture data. How can I convert an IntPtr to a byte[]? I would like to do this in safe code, if possible.
Zipster
Zipster
Have you tried the raw cast from one type to another, i.e (byte[])someIntPtrType? I don''t think you''d need unsafe code at all, because everything is already in terms of the managed types. You might need to tweak it a bit, maybe turn IntPtr into a Int32 using ToInt32... I''d just play around with it a bit.
Ridge
Ridge
Note we''re in the process of getting SDL moved over into Tao. Out of curiosity which methods are you referring to?
--Ridge
nagromo
nagromo
I was talking about SDLImage.Surface.Pixels and Gl.glTexImage2D, but I saw that Systems.Drawing.Imaging is easier. I looked at Tao.SimpleDirectmediaLayer, but it was alpha and I like the higher level approach to the library taken in SDLDotNet.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.