[SOLVED] DataStream

Sinjaph

19-11-2005 18:53:03

I needed DataStream class for one of my projects. I've written a basic swig interface file for OgreDataStream.h


%{
#include "OgreDataStream.h"
%}

%template(DataStreamPtr) Ogre::SharedPtr<DataStream>;

%include "OgreDataStream.h"


and compiled it without any problem.
Here is a code from my c# project

DataStreamPtr Data = ResourceGroupManager.Instance.openResource(SceneFile);
string DataName = Data.getName();
string DataValue = Data.getAsString();


it gets DataName without a problem however it crashes on DataValue.
Is this something todo with threads? if it is how can i organise my own mutexes?? (I'm not familiar with mutexes :S)

Shabubu

20-11-2005 00:14:45

When it crashes - what does it say?

Sinjaph

20-11-2005 11:15:51

it says the standart error report of the windows. "[AppName] has encountered a problem and needs to close. We are sorry for the inconvenience.". When I try to debug, It breakes here:

public virtual string getAsString() {
string ret = OgreBindingsPINVOKE.DataStream_getAsString(swigCPtr);
return ret;
}

and I cannot step in to the OgreBindingsPINVOKE.DataStream_getAsString() function.

and this is the ogre.log after the crash:

12:58:57: Creating resource group General
12:58:57: Registering ResourceManager for type Material
12:58:57: Registering ResourceManager for type Mesh
12:58:57: Registering ResourceManager for type Skeleton
12:58:57: Loading library OgrePlatform_d.dll
12:58:58: OverlayElementFactory for type Panel registered.
12:58:58: OverlayElementFactory for type BorderPanel registered.
12:58:58: OverlayElementFactory for type TextArea registered.
12:58:58: Registering ResourceManager for type Font
12:58:58: ArchiveFactory for archive type FileSystem registered.
12:58:58: ArchiveFactory for archive type Zip registered.
12:58:58: DevIL version: Developer's Image Library (DevIL) 1.6.7 May 27 2004
12:58:58: DevIL image formats: bmp dib cut dcx dds gif ico cur jpg jpe jpeg lif mdl mng jng pcx pic pix png pbm pgm pnm ppm psd pdd psp pxr sgi bw rgb rgba tga vda icb vst tif tiff wal xpm raw
12:58:58: Registering ResourceManager for type HighLevelGpuProgram
12:58:58: Loading library .\RenderSystem_Direct3D9
12:58:58: D3D9 : Direct3D9 Rendering SubSystem created.
12:58:58: D3D9: Driver Detection Starts
12:58:58: D3D9: Driver Detection Ends
12:58:58: *-*-* OGRE Initialising
12:58:58: *-*-* Version 1.0.4 (Azathoth)
12:58:58: Added resource location '../media' of type 'FileSystem' to resource group 'General'
12:58:58: Added resource location '../media/gui' of type 'FileSystem' to resource group 'General'
12:58:58: Added resource location '../media/son' of type 'FileSystem' to resource group 'General'
12:58:58: Added resource location '../media/cubemap.zip' of type 'Zip' to resource group 'General'
12:58:58: D3D9 : RenderSystem Option: Anti aliasing = None
12:58:58: D3D9 : RenderSystem Option: Floating-point mode = Fastest
12:58:58: D3D9 : RenderSystem Option: Full Screen = No
12:58:58: D3D9 : RenderSystem Option: Rendering Device = ATI MOBILITY RADEON 7500
12:58:58: D3D9 : RenderSystem Option: VSync = No
12:58:58: D3D9 : RenderSystem Option: Video Mode = 800 x 600 @ 32-bit colour
12:58:58: D3D9 : Subsystem Initialising
12:58:58: D3D9RenderSystem::createRenderWindow "OGRE Render Window", 800x600 windowed miscParams: FSAA=0 FSAAQuality=0 colourDepth=32 vsync=false
12:58:58: D3D9 : Created D3D9 Rendering Window 'OGRE Render Window' : 800x600, 32bpp
12:58:59: Registering ResourceManager for type Texture
12:58:59: Registering ResourceManager for type GpuProgram
12:58:59: RenderSystem capabilities
12:58:59: -------------------------
12:58:59: * Hardware generation of mipmaps: yes
12:58:59: * Texture blending: yes
12:58:59: * Anisotropic texture filtering: yes
12:58:59: * Dot product texture operation: yes
12:58:59: * Cube mapping: yes
12:58:59: * Hardware stencil buffer: yes
12:58:59: - Stencil depth: 8
12:58:59: - Two sided stencil support: no
12:58:59: - Wrap stencil values: yes
12:58:59: * Hardware vertex / index buffers: yes
12:58:59: * Vertex programs: yes
12:58:59: - Max vertex program version: vs_1_1
12:58:59: * Fragment programs: no
12:58:59: * Texture Compression: yes
12:58:59: - DXT: yes
12:58:59: - VTC: no
12:58:59: * Scissor Rectangle: yes
12:58:59: * Hardware Occlusion Query: yes
12:58:59: * User clip planes: yes
12:58:59: * VET_UBYTE4 vertex element type: yes
12:58:59: * Infinite far plane projection: yes
12:58:59: * Hardware render-to-texture: yes
12:58:59: * Floating point textures: no
12:58:59: * Non-power-of-two textures: yes
12:58:59: * Volume textures: yes
12:58:59: ***************************************
12:58:59: *** D3D9 : Subsystem Initialised OK ***
12:58:59: ***************************************
12:58:59: ResourceBackgroundQueue - threading disabled
12:58:59: Particle Renderer Type 'billboard' registered
12:58:59: Parsing scripts for resource group General
12:58:59: Parsing script all.material
12:58:59: Parsing script son.material
12:58:59: Finished parsing scripts for resource group General
12:58:59: Creating viewport on target 'OGRE Render Window', rendering from camera 'MainCamera', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
12:58:59: Viewport for camera 'MainCamera', actual dimensions L: 0 T: 0 W: 800 H: 600
12:58:59: Win32Input8: DirectInput Activation Starts
12:59:00: Win32Input8: Establishing keyboard input.
12:59:00: Win32Input8: Keyboard input established.
12:59:00: Win32Input8: Establishing mouse input.
12:59:00: Win32Input8: Mouse input established.
12:59:00: Win32Input8: DirectInput OK.
12:59:00: Texture: WindowsLook.tga: Loading 1 faces(PF_A8R8G8B8,128x128x1) with 0 generated mipmaps from Image. Internal format is PF_A8R8G8B8,128x128x1.
12:59:01: Texture: _cegui_ogre_0: Loading 1 faces(PF_A8R8G8B8,32x32x1) with 0 generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
12:59:01: Texture: _cegui_ogre_1: Loading 1 faces(PF_A8R8G8B8,256x256x1) with 0 generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x256x1.
12:59:01: Texture: spot_shadow_fade.png: Loading 1 faces(PF_B8G8R8,128x128x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
12:59:02: Texture: early_morning_fr.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
12:59:02: Texture: early_morning_bk.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
12:59:03: Texture: early_morning_lf.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
12:59:03: Texture: early_morning_rt.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
12:59:03: Texture: early_morning_up.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
12:59:03: Texture: early_morning_dn.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.


And this is the function swig generated

SWIGEXPORT char * SWIGSTDCALL CSharp_DataStream_getAsString(void * jarg1) {
char * jresult ;
Ogre::DataStream *arg1 = (Ogre::DataStream *) 0 ;
Ogre::String result;

arg1 = (Ogre::DataStream *)jarg1;
result = (arg1)->getAsString();

jresult = SWIG_csharp_string_callback((&result)->c_str());
return jresult;
}

Shabubu

20-11-2005 12:10:11

Are you able to step into any SWIG function?

Sinjaph

20-11-2005 15:45:31

nope.

I couldnt step into this function:
string ret = OgreBindingsPINVOKE.DataStream_getAsString(swigCPtr);
I just wanted to see what it does because this is the one failing.

Shabubu

20-11-2005 15:50:02

I was playing around with this some - the function returns the whole stream.

from the api docs:
This is a convenience method for text streams only, allowing you to retrieve a String object containing all the data in the stream.

They're not doing good error handling on this - but, i was able to get it to work with that code in a c++ sample.

Try throwing it a small text file...

Sinjaph

20-11-2005 16:41:14

I've tried it with a material script but the result is same. Actually I'm trying to port one of my C++ projects to C# I've a working code in C++ but it doesnt work in C#

rastaman

20-11-2005 17:54:35

cool this works for me
created DataStream.i pasted what you had in it.
added DataStream.i to OgreBindings.i after OgreString.i somewhere
and added to DemoSkyBox
Log oLog = LogManager.Singleton.createLog("test.log", false, false );
oLog.LogMessage("My new Log. Hells yeah!");

DataStreamPtr Data = ResourceGroupManager.Instance.openResource("smoke.material");
string DataName = Data.getName();
string DataValue = Data.getAsString();
oLog.LogMessage( string.Format("smoke.material = \n{0}\nend", DataValue) );

this is on linux. still haven't had time to setup my winbox :/. Make sure that OgreBindings project is set to Multi-threaded [Debug] Dll /MTd in properties/CC++/Runtime library. I remeber I had a problem with getAsString in cpp cause of this.

I'v made alot of chanes to OgreNet I was gonna wait till EagleEye updated cvs so I could see if anyone else maybe had a better solution or my changes mest up somthing... maybe ill just send him what I got.

Sinjaph

20-11-2005 18:12:56

OgreBindings is already set to multithreaded Debug. but it still crashes :S

[edit]
I've changed it to multithreaded Debug DLL(/MDd) and it worked! thanx for your replies
[/edit]

rastaman

20-11-2005 18:35:49

lol I wrote the wrong one, well /MDd /MTD whatever :P