A Little Help

new topic     » topic index » view thread      » older message » newer message

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.

NOTE: The example program is based off the simple tutorial included in the Newton Dynamics pacakage.

//C example program 
#include <stdio.h> 
#include "Newton.h" 
 
 
int main (int argc, const char * argv[]) 
{ 
  // Print the library version. 
  printf("Hello, this is Newton version %d\n", NewtonWorldGetVersion()); 
 
  // Create the Newton world. 
  NewtonWorld* const world = NewtonCreate(); 
 
  // Step the (empty) world 60 times in increments of 1/60 second. 
  const float timestep = 1.0f / 60; 
  for(int i=0; i<60; i++) { 
    NewtonUpdate(world, timestep); 
  } 
	 
  // Clean up. 
  NewtonDestroyAllBodies(world); 
  NewtonDestroy(world); 
 
  return 0; 
} 
 

--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 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu