pizzazhang
01-10-2011 18:46:21
Hi, everyone,
I'm working on a game editor using c# now and I use swig to wrap c++ code to c#. I used to create render texture in MOgre and copy the pixel content to memory. Now the same code is written in c++, and I want to use it in c# and create a image from the pixel buffer. Let me explain better by showing code:
this is my c++ code that method passes a char[]
then I create a render texture and copy the content
my c# code is like this:
the RenderUtil.createTexFromMaterial(material, ???) method expects a byte[] parameters but I don't know how to do this,
swig just automatically wrap my char* to string...
appreciate for any advice!
I'm working on a game editor using c# now and I use swig to wrap c++ code to c#. I used to create render texture in MOgre and copy the pixel content to memory. Now the same code is written in c++, and I want to use it in c# and create a image from the pixel buffer. Let me explain better by showing code:
this is my c++ code that method passes a char[]
static void createTexFromMaterial(const std::string& matName, char* databuf);
then I create a render texture and copy the content
ASSERT(databuf && "data buff is null");
Ogre::PixelBox pb(256, 256, 1, Ogre::PF_A8R8G8B8, databuf);
// Tells the target to update it's contents.
rttTex->update();
rttTex->copyContentsToMemory(pb, Ogre::RenderTarget::FB_FRONT);
my c# code is like this:
byte[] buff = new byte[300 * 300 * 6];
// RenderUtil.createTexFromMaterial(material, ???);
MemoryStream ms = new MemoryStream(buff);
Image img = Image.FromStream(ms);
this.pictureBox1.Image = img;
the RenderUtil.createTexFromMaterial(material, ???) method expects a byte[] parameters but I don't know how to do this,
swig just automatically wrap my char* to string...
appreciate for any advice!