1. Bad Routine Number Jolt Physics

Hello all,

While working my Jolt physics wrapper, I come across the Bad Routine Number error. It starts off with the first function called. Any JPC function called seems to bring out about this error. I know I used the mingw32 to make the DLL, so it is 32-bits DLL. The wrapper library is pretty big, so I'll put it in zip file. Perhaps someone can help me?

 
include std/ffi.e 
include std/machine.e 
include std/os.e 
 
public atom jolt = 0 
 
ifdef WINDOWS then 
	jolt = open_dll("joltc.dll") 
	elsifdef LINUX or FREEBSD then 
	jolt = open_dll("libjoltc.so") 
end ifdef 
 
--Added this in, the error didn't come up, so the DLL is being loaded 
if jolt = -1 then 
	puts(1,"Failed to load library!\n") 
	abort(0) 
end if 
 
public constant xJPC_RegisterDefaultAllocator = define_c_proc(jolt,"+JPC_RegisterDefaultAllocator",{}) 
 
public procedure JPC_RegisterDefaultAllocator() 
	c_proc(xJPC_RegisterDefaultAllocator,{}) 
end procedure 
 
public constant xJPC_RegisterTypes = define_c_proc(jolt,"+JPC_RegisterTypes",{}) 
 
public procedure JPC_RegisterTypes() 
	c_proc(xJPC_RegisterTypes,{}) 
end procedure 
include std/ffi.e 
 
include std/machine.e 
 
include joltc.e 
 
JPC_RegisterTypes() --Bad routine number starts here 

https://1fichier.com/?qt5fk2hrg29wua1odzll - JoltC Wrapper

new topic     » topic index » view message » categorize

2. Re: Bad Routine Number Jolt Physics

There's a lot going on here...

Icy_Viking said...

I know I used the mingw32 to make the DLL, so it is 32-bits DLL. The wrapper library is pretty big, so I'll put it in zip file. Perhaps someone can help me?

Looks like a 64-bit DLL to me, so that's probably your first problem:

$ file joltc.dll 
joltc.dll: PE32+ executable (DLL) (console) x86-64, for MS Windows 

If you're using TDM-GCC-64 running gcc --version would show gcc (tdm64-1) 10.3.0 and it will build 64-bit DLLs by default. The Makefile I made has options for this. Beyond that, I tested your 64-bit DLL on 64-bit Windows and it does seem to load most of the functions but there are some that are broken.


These functions were simply misspelled in your wrapper. Hopefully you're making good use of copy/paste and not writing out all of these function names by hand. Lord help you if you are.

JPC_Body_ApplyBuoyancyImpulse 
JPC_Body_IsActive 
JPC_CylinderShapeSettings_SetHalfHeight 
JPC_MotionProperties_SetGravityFactor 
JPC_PhysicsSystem_OptimizeBroadPhase 


These functions are missing because they require JPC_DEBUG_RENDERER to be defined. I've added that flag to my Makefile in the other thread.

JPC_BodyDrawFilter_Create 
JPC_BodyDrawFilter_Destroy 
JPC_BodyManager_DrawSettings_Create 
JPC_BodyManager_DrawSettings_Destroy 
JPC_DebugRenderer_TriangleBatch_AddRef 
JPC_DebugRenderer_TriangleBatch_Create 
JPC_DebugRenderer_TriangleBatch_GetPrimitive 
JPC_DebugRenderer_TriangleBatch_GetRefCount 
JPC_DebugRenderer_TriangleBatch_Release 
JPC_PhysicsSystem_DrawBodies 
JPC_PhysicsSystem_DrawConstraintLimits 
JPC_PhysicsSystem_DrawConstraintReferenceFrame 
JPC_PhysicsSystem_DrawConstraints 


These functions are missing because they're in JoltPhysicsC_Extensions.cpp, which I noted in the other thread should be excluded because it overrides the private keyword, which is Bad Practiceâ„¢. You should remove them altogether.

JPC_PhysicsSystem_GetActiveBodyIDs 
JPC_PhysicsSystem_GetBodiesUnsafe 
JPC_PhysicsSystem_GetBodyIDs 


This function is missing because it has an inconsistent signature in between JoltPhysicsC.h and JoltPhysicsC.cpp, which prevents it from being exported correctly. You need to edit JoltPhysicsC.h (line 1433) to add the missing parameter as shown here:

JPC_BodyInterface_SetPosition(JPC_BodyInterface *in_iface, 
			      JPC_BodyID in_body_id,         // <-- add this line 
			      const JPC_Real in_position[3], 
			      JPC_Activation in_activation); 


I could not locate these functions anywhere in JoltPhysicsC.cpp. I'm assuming these were a typo on your part.

JPC_Body_SetAngularVelocity 
JPC_Body_SetAngularVelocityClamped 


Hope that helps!

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: Bad Routine Number Jolt Physics

Thanks Greg. I rebuilt the DLL with the 32-bit parameters as you mentioned in the other thread. So now I have joltc32.dll

include std/ffi.e 
include std/machine.e 
include std/os.e 
 
public atom jolt = 0 
 
ifdef WINDOWS then 
	jolt = open_dll("joltc32.dll") 
	elsifdef LINUX or FREEBSD then 
	jolt = open_dll("libjoltc32.so") 
end ifdef 
 
if jolt = -1 then 
	puts(1,"Failed to load library!\n") 
	abort(0) 
end if 

I also fixed the typos. I'm still getting the bad routine number though. I checked with another 32-bit DLL and I know by default my Euphoria installtion is 32-bits. So I don't know why I'm still getting the error.

I did the (build a separate 32-bit library) > mingw32-make BITS32=1 TARGET=joltc32.dll > mingw32-make clean to make sure I get a 32-bit DLL built.

I even did the steps all over again from scratch. Still getting bad routine-number id (1).

include std/machine.e 
 
include joltc.e 
 
JPC_RegisterDefaultAllocator() 

Here's the error from the file.

ffi.e:1011 in function c_func()  
c_proc/c_func: bad routine number (1)  
    rid = 1 
    args = {} 
    fn = <no value> 
    cif = <no value> 
    name = <no value> 
    nargs = <no value> 
    parg_types = <no value> 
    rtype = <no value> 
    pargs = <no value> 
    pfree = <no value> 
    arg_types = <no value> 
    i = <no value> 
    parg = <no value> 
    rtype_size = <no value> 
    prvalue = <no value> 
    rvalue = <no value> 
    i = <no value> 
 
joltc.e:399 in procedure JPC_RegisterDefaultAllocator()   
    void (from inlined routine 'c_proc' at 2) = <no value> 

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu