Emil_halim
member
Posts
639
Threads
104
Location
Alex, Egypt
Post #1289
2012-12-26 18:18:00 UTC
yes you was correct .
here is the prototype of the function
BBDECL int BBCALL RenderWorld(float timeSinceLastFrame = 0.0);
I have update it but still crashed.
here is the new code.
//****************************************//
// ************ //
// ***MagicPro library*** //
// ************ //
//****************************************//
program WIN32GUI 'MagicPro Test #1';
#include 'console.zir';
#include 'ch.zir';
const KC_ESCAPE = 0x01;
imports('MagicPro.dll')
{
procedure z_init = ('_z_init@4')(char* Titel); cdecl;
procedure Graphics3D = ('_Graphics3D@20')(Dword Width,Height,depth; boolean fullScrn,VSync); cdecl;
procedure z_setAmbientLight = ('_z_setAmbientLight@12')(single red,green,blue); cdecl;
procedure setMediaDir = ('_setMediaDir@8')(char* name;boolean recursive); cdecl;
function OIS_isKeyDown = ('_OIS_isKeyDown@4')(int32 key): boolean; cdecl;
procedure RenderWorld = ('_RenderWorld@4')(single timeSinceLastFrame); cdecl;
procedure Sync(); cdecl;
procedure EndGraphics = ('_EndGraphics@0')(); cdecl;
}
z_init('MagicPro Test #1');
Graphics3D(800,600,32,false,false);
z_setAmbientLight(30,30,50);
setMediaDir('ZipMedia.zip',true);
setMediaDir('media',true);
while(!OIS_isKeyDown(KC_ESCAPE))
{
RenderWorld(0);
Sync();
}
EndGraphics();
ExitProcess(0);
http://www.freewebs.com/ogremagic/index.htm
Emil_halim
member
Posts
639
Threads
104
Location
Alex, Egypt
Post #1290
2012-12-26 19:11:17 UTC
i have modified the test program , to discover where it crashed.
here is the modification
//****************************************//
// ************ //
// ***MagicPro library*** //
// ************ //
//****************************************//
program WIN32CUI 'MagicPro Test #1';
#include 'console.zir';
#include 'ch.zir';
const KC_ESCAPE = 0x01;
imports('msvcrt.dll')
{
function printf(char* format[]): Int32; cdecl;
}
imports('MagicPro.dll')
{
procedure z_init = ('_z_init@4')(char* Titel); cdecl;
procedure Graphics3D = ('_Graphics3D@20')(Dword Width,Height,depth; boolean fullScrn,VSync); cdecl;
procedure z_setAmbientLight = ('_z_setAmbientLight@12')(single red,green,blue); cdecl;
procedure setMediaDir = ('_setMediaDir@8')(char* name;boolean recursive); cdecl;
function OIS_isKeyDown = ('_OIS_isKeyDown@4')(int32 key): boolean; cdecl;
procedure RenderWorld = ('_RenderWorld@4')(single timeSinceLastFrame); cdecl;
procedure Sync(); cdecl;
procedure EndGraphics = ('_EndGraphics@0')(); cdecl;
}
z_init('MagicPro Test #1');
Graphics3D(800,600,32,false,false);
z_setAmbientLight(30,30,50);
setMediaDir('ZipMedia.zip',true);
setMediaDir('media',true);
int32 k = 0;
while(!OIS_isKeyDown(KC_ESCAPE))
{
printf('%d\n', k);
RenderWorld(0);
printf('RenderWorld is ok\n');
Sync();
k++;
}
EndGraphics();
ExitProcess(0);
and found that it crashed after 7 iterations.
also the crashed was in Sync function and here is the prototype of it
BBDECL void Sync();
so what code be the reason of crashing?
http://www.freewebs.com/ogremagic/index.htm
Emil_halim
member
Posts
639
Threads
104
Location
Alex, Egypt
Post #1291
2012-12-26 22:05:16 UTC
BTW , here is the cmd line of MSVC++10
cl.exe /nologo /W3 /MD /EHs /O2 /DNDEBUG /I"C:\Program Files\Microsoft Visual Studio 10.0\VC\include" /I"C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include" /I..\..\..\..\OgreSDK_vc10_v1-8-0\boost /I..\..\..\include /I..\..\..\..\OgreSDK_vc10_v1-8-0\include /I"C:\Program Files\Microsoft Visual Studio 10.0\VC\include" /c DBTest2.cpp /Foobj\Release\DBTest2.obj does the compiler option "/MD" (multi threaded runtime library) itself is the reason of crashing?
http://www.freewebs.com/ogremagic/index.htm
Colin
admin
Posts
928
Threads
49
Location
Bulgaria
Post #1292
2012-12-26 22:21:44 UTC
There is not really much i can help with since i can't see the code for sync etc but it is possible you are doing something in sync that breaks.
You can try to compile your dll with /MT instead to see if it solves the issue, else if you can send me a setup of your test app, with your dll and the zir code i can take a look when i get a bit free time.
Emil_halim
member
Posts
639
Threads
104
Location
Alex, Egypt
Post #1293
2012-12-27 21:08:14 UTC
ok, finally the problem is solved.
any way , can ziron allow optional parameters with import library.
something like this
procedure RenderWorld = ('_RenderWorld@4')(single timeSinceLastFrame = 0.0); stdcall;
thanks.
http://www.freewebs.com/ogremagic/index.htm
Colin
admin
Posts
928
Threads
49
Location
Bulgaria
Post #1294
2012-12-27 21:43:51 UTC
I'm guessing the problem was the exported functions were stdcall?
actually i think cdecl funcs mangled do not end with param size "@4" etc since ste stackmis handled by the caller
As for default params, it does not already work? I will take a look when i get back in the office
Emil_halim
member
Posts
639
Threads
104
Location
Alex, Egypt
Post #1295
2012-12-28 12:11:38 UTC
yes , the problem wes Stdcall and cdecl.
MagicPro library has many stdcall functions and many c++ classes and c functions.
so i am thinking to make all functions stdcall but for the classes i will see if i can make
their public functions as a stdcall.
BTW , who can i create an instance of C++ class in ziron and call it's function.
http://www.freewebs.com/ogremagic/index.htm
Colin
admin
Posts
928
Threads
49
Location
Bulgaria
Post #1298
2012-12-28 15:50:45 UTC
Right now i have not looked much into this since c memory management is very different, this is a feature i plan to look into for Ziron 2, to be able to create c++ compatible classes.
The class would need to be created in ziron and then only the functions would be used from the c++ class, all memory management would need to be localside.
e.g.
me = new myClass; // ziron create me
me.mycppFunc(); // cpp interface class function which is passed the mem ptr
delete me; // ziron delete me
But i will first look into this for Ziron 2.