forum-msg-id-133914-edit

Original date:2019-05-29 19:34:16 Edited by: Icy_Viking Subject: A Little Help

Hello all,

As some of you know, I am currently wrapping the Newton Game Dynamics physics library. While I haven't wrapped all of it yet, I decided I'd make a small test program to make sure all is well. Anyways, the problem I'm having is I can't get the window to stay open after the physics init function is called. Any help would be appericated.

--Wrapper Code 
public constant xNewtonCreate = define_c_func(nd,"NewtonCreate",{},C_POINTER) 
 
public function NewtonCreate() 
 
 return c_func(xNewtonCreate,{}) 
	 
end function 
 
xNewtonUpdate = define_c_proc(nd,"NewtonUpdate",{C_POINTER,C_FLOAT}) 
 
public procedure NewtonUpdate(atom world,atom timeStep) 
 
 c_proc(xNewtonUpdate,{world,timeStep}) 
	 
end procedure 
 
public constant xNewtonDestroy = define_c_proc(nd,"NewtonDestroy",{C_POINTER}) 
 
public procedure NewtonDestroy(atom world) 
 
 c_proc(xNewtonDestroy,{world}) 
	 
end procedure 
 
constant xNewtonDestroyAllBodies = define_c_proc(nd,"NewtonDestroyAllBodies",{C_POINTER}) 
 
public procedure NewtonDestroyAllBodies(atom world) 
 
 c_proc(xNewtonDestroyAllBodies,{world}) 
	 
end procedure 
--Example 
include std/machine.e 
include std/get.e 
 
include NGD.ew 
 
atom key 
 
position(1,1) 
puts(1,"Press ESC to close\n") 
 
atom ver = NewtonWorldGetVersion() --this works 
public atom world 
atom timeStep = 1.0 / 60 
 
position(2,1) 
printf(1,"Newton Game Dynamics Version: %d",{ver}) --this works 
 
procedure Init() 
 
    world = NewtonCreate() 
	 
end procedure 
 
while 1 do 
 
	Init()   --as soon as this is called, the window closes rapidly 
 
	key = get_key() 
	 
	if key = 27 then 
		exit 
	end if 
	 
 for i = 0 to 60 do 
 	NewtonUpdate(world,timeStep) 
 end for 
  
 NewtonDestroyAllBodies(world) 
 NewtonDestroy(world) 
 
end while 
Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu