stoneCold.net
18-01-2006 00:36:58
Hi, I'm glad to be registered in the addons forum now as well as in the normal ogre forum
.
Now to the reason why I'm here...
The last days I installed MS Vstudio8 Express and played a little bit with it and I really like C# with the .NET framework 2.0 (everyone who has seen it will agree
toolstrip rocks
).
I even like it that much that I'd consider to write my game editors with C# now instead of good old MFC.
My first approach is that I created a Win32 DLL which holds the Ogre rendering code, and with C# I try to access this DLL.
This is the way I did it before with MFC and it should? work with C# too?
This is the code I used to dllimport in C#:
...and MFC:
As you see I need to give the DLL a HWND when using MFC, which is? called IntPtr in C#.
But when I do
I often! get memory errors and so on, but sometimes it works.
Furthermore I don't use Ogre Root to update the renderwindow, because therefore I have the function "o4D_render" in both cases (MFC and C#).
Which is declared in the DLL as follows:
Everything works simply great in MFC but in C# it's more coincidence if the "o4D_create" function completes without errors and the "o4D_render" function never worked, not even by chance.
My first thought is that in C# I do DllImport the classes functions seperately which I do not in MFC, but I found no other solution to DllImport a whole class into C#.
[EDIT]: Here's the runtime error I get:
I would be very pleased if someone can give me some information or even a clear solution, many thanks in advance.
stoneCold.net

Now to the reason why I'm here...
The last days I installed MS Vstudio8 Express and played a little bit with it and I really like C# with the .NET framework 2.0 (everyone who has seen it will agree


I even like it that much that I'd consider to write my game editors with C# now instead of good old MFC.
My first approach is that I created a Win32 DLL which holds the Ogre rendering code, and with C# I try to access this DLL.
This is the way I did it before with MFC and it should? work with C# too?
This is the code I used to dllimport in C#:
public class o4D_core
{
[DllImport("o4D_core.dll")]
public static extern void o4D_create(IntPtr hwnd);
[DllImport("o4D_core.dll")]
public static extern void o4D_render();
[DllImport("o4D_core.dll")]
public static extern void o4D_rotate();
};
...and MFC:
#define DllImport __declspec(dllimport)
class DllImport o4D_core
{
public:
o4D_core(void);
~o4D_core(void);
// Accessors
static o4D_core* GetInstance();
void o4D_create(HWND hwnd);
void o4D_render();
void o4D_rotate();
};
As you see I need to give the DLL a HWND when using MFC, which is? called IntPtr in C#.
But when I do
o4D_core.o4D_create(pictureBox1.Handle); //for example
I often! get memory errors and so on, but sometimes it works.
Furthermore I don't use Ogre Root to update the renderwindow, because therefore I have the function "o4D_render" in both cases (MFC and C#).
Which is declared in the DLL as follows:
void o4D_core::o4D_render()
{
mWindow->update();
}
Everything works simply great in MFC but in C# it's more coincidence if the "o4D_create" function completes without errors and the "o4D_render" function never worked, not even by chance.
My first thought is that in C# I do DllImport the classes functions seperately which I do not in MFC, but I found no other solution to DllImport a whole class into C#.
[EDIT]: Here's the runtime error I get:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I would be very pleased if someone can give me some information or even a clear solution, many thanks in advance.
stoneCold.net
