madmark
13-03-2007 17:03:03
I have run into a snag using the Ogre resource manager and data streaming.
I need to get the binary data into a buffer or MemoryStream, but the Read method of DataStream takes a (void *) and I can't seem to grok how to make that happen in C#.
Am I missing something?
For completeness, here is the test I ran...
The problem is that as soon as the data contains a zero byte, the string ends and an exception occurs (out of bounds)
I need to get the binary data into a buffer or MemoryStream, but the Read method of DataStream takes a (void *) and I can't seem to grok how to make that happen in C#.
Am I missing something?
For completeness, here is the test I ran...
public MemoryStream OgreResourseFetchStream(String name)
{
DataStreamPtr pStream = ResourceGroupManager.Singleton.OpenResource(name);
if (pStream.Size() != 0)
{
MemoryStream s = new MemoryStream((int) pStream.Size());
for (int i = 0; i < pStream.Size(); i++)
s.WriteByte((byte)pStream.AsString[i]);
return s;
}
return null;
}
The problem is that as soon as the data contains a zero byte, the string ends and an exception occurs (out of bounds)