Re: Wrapper Help Again

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

I'd figure I'd have to wrap them like that. I had to wrap some event commands like that. It's a pain, but at least its fairly easy to wrap.

EDIT: Ok so I wrapped it like this.

Wrapper

 
public constant xirrEKeyCodeKeyEscape = define_c_func(irr,"irr_EKEY_CODE_KEY_ESCAPE",{},C_POINTER) 
 
public function irrEKeyCodeKeyEscape() 
 
 return c_func(xirrEKeyCodeKeyEscape,{}) 
	 
end function 

Example

atom evt 
	 
	evt = irrSEventNew() 
	 
	while irrSEventIsKeyboardInputEvent(evt) do 
		if irrSEventIsKeyboardInputEvent(evt) then 
			atom keyInput = irrSEventGetKeyInput(evt) 
			atom keyCode = irrSKeyInputGetKey(keyInput) 
			 
			if irrEKeyCodeKeyEscape() then 
				irrIrrlichtDeviceClose() 
			end if 
		end if 
	end while 

When I try to run the example, the window closes right away. Maybe I have certain vars messed up?

This freezes the program when I try to run it.

atom evt 
 
evt = irrSEventNew() 
	 
	while irrSEventIsKeyboardInputEvent(evt) do 
		if irrSEventIsKeyboardInputEvent(evt) then 
			atom keyInput = irrSEventGetKeyInput(evt) 
			atom keyCode = irrSKeyInputGetKey(keyInput) 
			 
			if irrSKeyInputIsPressed(keyInput) = irrEKeyCodeKeyEscape() then 
				irrIrrlichtDeviceClose() 
			end if 
		end if 
	end while 

New Test, this is closer to how the C example is, but the Euphoria program still freezes.

include std/machine.e 
include std/get.e 
 
include EuIrr.ew 
 
constant TRUE = 1, FALSE = 0 
 
integer EscapePressed 
 
procedure handleInput() 
 
	atom evt 
 
	evt = irrSEventNew() 
	 
	while irrSEventIsKeyboardInputEvent(evt) do 
		if irrSEventIsKeyboardInputEvent(evt) then 
			atom keyInput = irrSEventGetKeyInput(evt) 
			atom keyCode = irrSKeyInputGetKey(keyInput) 
			 
			if irrEKeyCodeEqual(keyCode,irrEKeyCodeKeyEscape()) then 
				EscapePressed = irrSKeyInputIsPressed(keyInput) 
			end if 
		end if 
	end while 
	 
	if (EscapePressed) then 
		irrIrrlichtDeviceClose() 
	end if 
	 
	irrSEventDelete(evt) 
	 
end procedure 
 
atom dim = irrDimension2duNew(600,600) 
atom backColor = irrSColorNew(255,100,100,100) 
atom driver,smgr,env 
atom fs 
atom cur 
atom timer,last 
 
irrCreateDevice(dim,FALSE,TRUE,TRUE) 
 
smgr = irrIrrlichtDeviceGetSceneManager() 
driver = irrIrrlichtDeviceGetVideoDriver() 
env = irrIrrlichtDeviceGetGUIEnviroment() 
 
timer = irrIrrlichtDeviceGetTimer() 
last = irrITimerGetTime(timer) 
 
while irrIrrlichtDeviceRun() do 
 
	atom now = irrITimerGetTime(timer) 
	deltaTime = now - last / 1000.0 
	last = now 
	 
	irrIVideoDriverBeginScene(driver,TRUE,TRUE,backColor) 
	irrISceneManagerDrawAll(smgr) 
	irrIGUIEnviromentDrawAll(env) 
	 
	irrIVideoDriverEndScene(driver) 
	 
	handleInput() 
	 
end while 
 
irrDimension2duDelete(dim) 
irrSColorDelete(backColor) 
irrIrrlichtDeviceDrop() 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu