bbSetBlitz3DDebugCallback

Archives Forums/Blitz3D SDK Programming/bbSetBlitz3DDebugCallback

Pepsi(Posted 2007) [#1]
Solved! Thanks Simon

Need to terminate the application at the debug callback, not continue it with a return.

Ok, go to following post!




[Working EBasic code below]
$include "blitz3dsdk.inc"
DECLARE CDECL mydebugfunction(string errormessage)

bbSetBlitz3DDebugCallback(&mydebugfunction)
bbBeginBlitz3D()

	bbGraphics( 640,480,16,2)
	bbSetBuffer( bbBackBuffer())

	' trying to load a non-existing image to kickoff bbSetBlitz3DDebugCallback 
	image=bbLoadImage( "b3dlogo3.jpg" )
	If image=0 then image=bbLoadImage( "../b3dlogo3.jpg" )

	bbMidHandle( image)

	def run:int
	run=1
	do
		bbCls()		
		bbDrawBlock(image,320,144,0)

		bbText( 320,280,"[Escape] to exit",True,0)

		If bbKeyHit( 1 ) then run=0

		bbFlip(1)

	until run=0

bbEndBlitz3D()
end

sub mydebugfunction(string errormessage)
	MESSAGEBOX(NULL,errormessage,"Blitz3D SDK Error",@MB_ICONEXCLAMATION | @MB_OK)
	end
endsub



Pepsi(Posted 2007) [#2]
Ok, mabie it has something to do with how the callbacks are being called between Ebasic and the b3d.dll. I tried a little example with the bbSetBlitz3DEventCallback command too. It works, but again at the end, something strange happens. This, the window closes, but the application is still being runned in the background where i have to endproccess it through the task manager.

I dont wont to call this a sdk bug yet. I would like to hear if anybody else has a similuar problem with another language. thx

Here's the example code for testing the bbSetBlitz3DEventCallback command[ using EBasic ]:
' This demostrates bbSetBlitz3DEventCallback working, but it will
' make the application continue to run in the background even after
' the window closes. Thus, using taskmanager to end process it.
$include "blitz3dsdk.inc"

DECLARE CDECL BBEventHandler(int ehhwnd,int ehmsg,int ehwp,int ehlp),int

bbSetBlitz3DEventCallback(&BBEventHandler)
bbBeginBlitz3D()


bbGraphics3D( 800,600,0,2)

bbSetBuffer( bbBackBuffer())

def cube:BBEntity
def light:BBLight
def camera:BBCamera

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

bbPositionEntity( camera,0,0,-4)

def hwnd,msg,wp,lp:int
def run:int
run=1

do 
	bbCls()

	bbTurnEntity( cube,1,2,3)
	bbRenderWorld()
	bbText(20,20,"mouse:"+str$(MouseX())+","+str$(MouseY()))
	bbText(20,40,"hwnd"+str$(hwnd))
	bbText(20,60,"msg"+str$(msg))
	bbText(20,80,"wp"+str$(wp))
	bbText(20,100,"lp"+str$(lp))

	if bbkeydown(1)=true then run=0

	bbFlip(1)
until run=0

bbEndBlitz3D()
end

Sub BBEventHandler(int ehhwnd,int ehmsg,int ehwp,int ehlp),int
	hwnd=ehhwnd
	msg=ehmsg
	wp=ehwp
	lp=ehlp
	Return -1
End Sub



DStastny(Posted 2007) [#3]
Your whacking the stack...

Make sure the calling convention on the call backs is cdecl

Doug


Pepsi(Posted 2007) [#4]
[Above two code blocks updated]

All the imports are declared with CDECL as in specific above:

DECLARE CDECL IMPORT, bbSetBlitz3DDebugCallback(POINTER callback)
DECLARE CDECL IMPORT, bbSetBlitz3DEventCallback(POINTER callback)

With your suggestion, I went and declared the EBasic subroutines with CDECL also. But still get the same problems.

On another note: I noticed that the keydown command no longer works if I use bbSetBlitz3DEventCallback. When I remark out bbSetBlitz3DEventCallback(&BBEventHandler), the keydown command works again.

So is it intentional for bbSetBlitz3DEventCallback to somehow override the keyboard commands?

thx


DStastny(Posted 2007) [#5]
I see that behavior as well with the key command not working if you hook the window events. I think you are meant to handle them yourself.

Not sure exactly how the hook is intended to work.

If was standard wndproc or subclass type beavior if I returned zero it would mean I didnt handle it so the SDK should but not sure here what intent is.

Doug


Pepsi(Posted 2007) [#6]
Seeing the Max example for bbSetBlitz3DEventCallback in the docs would make me believe that the SDK should handle it because it uses a Keydown code there. I dunno yet if this keyboard problem should be thrown in the the sdk bug report forum yet...

What language are you using the SDK with if you dont mind me asking?

edit: nm... bmax, i just saw your post about it... hrmmmmm....


skidracer(Posted 2007) [#7]
The debugcallback expects the application to be terminated and not return (it closes the bbruntime before it calls it).

As illustrated by the bmx example this allows a debugger to take you to the line that caused the error.


Pepsi(Posted 2007) [#8]
Thanks Simon! The bbSetBlitz3DDebugCallback works perfectly now.


Pepsi(Posted 2007) [#9]
I'm looking at the BMax example... is this bbSystemEmitOSEvent important for being called in the Event Callback?

It's not in the blitz3dsdk.h file for me to use...


Barnabius(Posted 2007) [#10]
I've lost my hair trying to figure out that pesky bbSystemEmitOSEvent function. It's nowhere in the docs and it's obvious that it has to be there. Perhaps a word from Simon could explan it. ;)

Barney