Advertisement

Calling convention problem?

Started by March 14, 2011 08:06 AM
1 comment, last by arpeggiodragon 13 years, 11 months ago
Hi. I am really stumped by this one. This problem has come about from binding OpenGL API. Two of the registered functions:

r = engine->RegisterGlobalFunction( "void glTranslatef (float, float, float)", asFUNCTION(glTranslatef), asCALL_CDECL ); assert( r >= 0 );
r = engine->RegisterGlobalFunction( "void glEnd()", asFUNCTION(glTranslatef), asCALL_CDECL ); assert( r >= 0 );
//..etc


Calling a function like glEnd() or glLoadIdentity() seems to work , whereas glTranslatef(..) and others will fail with a VC++ runtime check:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
...With a crash to follow.

As far as I can tell glFunctions on MSVC9 are defined "__declspec(dllimport) ret __stdcall decl()"
Any help would be great.
"__declspec(dllimport) ret __stdcall decl()"[/quote]

If that's so.. they why do you have cdecl in your code?
cdecl is not the same as stdcall.
Advertisement
....

Oh my god, I'm blind. There is in fact an asCALL_STDCALL. Time for a good 'ol fashioned facepalm eh? :)
Thanks!

This topic is closed to new replies.

Advertisement