How do you make dynamic textures

joopi

04-06-2006 09:43:09

Just wondering if there is a way I can load and or create a texture in ogredotnet. I have tried a few angles but I end up at a dead end each time.

I was hoping I can somehow use System.Drawing to create some images and load into a texture for use in an overlay etc.

pepote

04-06-2006 21:31:25

The proccess may be similar to make images on-fly for aspx pages. You create a dinamyc bmp from file and you will can load to it others images, write text, apply effetcs, write lines from algorithms, etc...

Avalon

04-06-2006 22:16:37

I would doubt that using GDI+ (system.drawing) is a good route to go down, GDI+ plus calls are simply too slow for real-time graphics. I’m not fully enough versed in ODN to give you a comprehensive answer but I would suggest you look at some of the "Render To Texture" articles are Wiki entries (as well as the included example) for some Ideas.

As I understand it this allows you to set a render target for the engine onto the texture and since 2D rendering is possible with ogre, that you generate the texture that way.

Thats about all the help I can give you at the moment, You will have to wait for Rastaman for a more definitive answer, however that said I'll have a play and I would suggest you do the same and see waht you come up with.

Sorry I can't be of more help.

rastaman

05-06-2006 23:27:51

here is a startting place
http://www.ogre3d.org/wiki/index.php/Creating_dynamic_textures

where it call lock on the pixelbuffer, in OND you will get an IntPtr. Just create a new MemoryDataStream with it, and use the MDS functions to set the buffer. something like this

MemoryDataStream mds = new MemoryDataStream(ptrPixBuff, sizeInBytes, false);
The last false is so that when the MDS Disposes it will not delete the buffer. Use MDS function SetBuffer with a Byte array. I don't really know how you could get a Byte array of the raw image, I haven't used GDI+ stuff that much.

joopi

07-06-2006 03:34:23

Thankyou Rastaman, that is exactly what was after.
I guess my query should have been titled confusion in the depths of interop.

I was hoping I could use dynamic textures to display sheild/damage levels as a bar level indicator. I am starting out simple just trying to populate a texture array with 255 using Marshal.Copy but I get a stack trace a mile long in mono.

I looked and looked but MDS doesn't seam to have a method SetBuffer perhaps my dlls are out of date but I am using the latest precompled versions.

here is a sample of my code so far.


OgreDotNet.TexturePtr tp= OgreDotNet.TextureManager.GetSingleton().CreateManual("test88",OgreDotNet.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
OgreDotNet.TextureType.TEX_TYPE_2D,256,256,0,OgreDotNet.PixelFormat.PF_BYTE_BGRA);


OgreDotNet.HardwarePixelBufferSharedPtr hpb= tp.Get().getBuffer();
hpb.Get().Lock(OgreDotNet.HardwareBuffer.LockOptions.HBL_NORMAL);

OgreDotNet.PixelBox pb= hpb.Get().getCurrentLock();

MemoryDataStream mds = new MemoryDataStream(pb.data, 256*256*4, false);


hh=new byte[265*256*4];
Marshal.Copy(hh,0,mds.getPtr(),hh.Length);