Crashes if

Archives Forums/Blitz3D SDK Programming/Crashes if

DStastny(Posted 2007) [#1]
Using this sample code from the help.

Import blitz3d.blitz3dsdk

Strict

Function BBEventHandler(hwnd,msg,wp,lp) "win32"
	bbSystemEmitOSEvent hwnd,msg,wp,lp,Null
	Return -1
End Function

bbSetBlitz3DEventCallback(BBEventHandler)

bbBeginBlitz3D()

bbGraphics3D 800,600,0,2

Local cube=bbCreateCube()
Local light=bbCreateLight()
Local camera=bbCreateCamera()

bbPositionEntity camera,0,0,-4

EnablePolledinput

While Not KeyDown(KEY_ESCAPE)
	bbTurnEntity cube,1,2,3
	bbRenderWorld
	bbText 20,20,"mouse:"+MouseX()+","+MouseY()
	bbFlip 
Wend


First it does not compile, since the bbSetBlitz3DEventCallback prototype does not match the .h header. If stick the prototype into a byte ptr and then cast it to in it crashes.

I am trying to work it out in my Delphi code as to how this hook actually works. ie. Am i responsible for handling all the messages. or if I return zero the dll will handle them?

Thanks
Doug


DStastny(Posted 2007) [#2]
Ok figured this out the example ndicate a stdcall but its a cdecl calling convention.

Changed "win32" in example to "C" and works fine.

If you can clarify if the call back is cdecl or stdcall in next release that would be cool. Calling convention seems inconsistent in documentation vs actuals in header

Doug


skidracer(Posted 2007) [#3]
Thanks Doug, that should indeed be "C".


skidracer(Posted 2007) [#4]
Fixed in next release.