.typeof debug = I;;
.
.struct StrTEST3D = [
. t_iState : I,
.
.
. t_oWinMother : ObjWin,
. t_iSize : [I I],
.
. t_oLogo : ObjBitmap,
.
. t_iErrMask : I,
.
. ] mkStrTEST3D;;
.
.
.fun checkDebug ()=
. debug;;
.
.fun printDbg (p)=
. let p -> [str3d message] in
. 0;;
.
.fun printDebug (p)=
.
std_if @checkDebug @printDbg p;;
.
.
.
.fun end (str3d)=
. _fooS if !res then
. "3d structures destroyed successfully"
. else
. strcat "Error during the 3d destruction : " itoa res;
. _DSbitmap str3d.t_oLogo;
. _closemachine;
. 0;;
.
.
.
.fun cbResize (win, str3d, neww, newh)=
. 0;;
.
.fun cbEnd (win, str3d)=
. end str3d;;
.
.
.fun createWin (str3d)=
. (
. printDebug [str3d "ERROR : Application unitialized !"];
. 1
. )
. else
. let str3d.t_iSize -> [w h] in
. (
. set str3d.t_oWinMother = _CRwindow _channel nil 0 0 w h WN_NORMAL "Test 3D";
.
. _CBwinSize str3d.t_oWinMother @cbResize str3d;
. _CBwinDestroy str3d.t_oWinMother @cbEnd str3d;
. 0
. );;
.
.fun createBgLogo (str3d)=
. let SO3BitmapWidgetCreateBackground
. "bgLogo"
. 6 viewH-70
. 64 64
. -> widget in
. if SO3BitmapWidgetBlit widget str3d.t_oLogo then 0 else 1;;
.
.fun cbPreRender (strView, p)=
. if !str3d.t_iState then
. let p -> [str3d logo] in
. let sprintf "Worst FPS %f\nBest FPS %f\nAverage FPS %f"
. [SO3BufferGetWorstFPS buffer SO3BufferGetBestFPS buffer SO3BufferGetAverageFPS buffer]
. -> s in
. (
.
. 0
. )
. else
. end str3d;;
.
.fun createDebug (str3d)=
. let 0xff0000 -> fcolor in
. let fcolor & 255 -> r in
. let (fcolor>>8) & 255 -> g in
. let (fcolor>>16) & 255 -> b in
. let make_rgba r g b 127 -> crgba in
.
. 0
. else
. set str3d.t_iState = 1
. else
. set str3d.t_iState = 1
. else
. set str3d.t_iState = 1;;
.
.fun cb3dViewInit (view, result, str3d)=
. if result!= 0 then
. (
. printDebug [str3d "Unable to initialize 3d view"];
. set str3d.t_iState = 1
. )
. else
. 0;;
.
.fun cb3dSessionInit (strSession, res, str3d)=
. set str3d.t_o3dsession = strSession;
. if res != 0 then
. (
. printDebug [str3d "Unable to initialize the 3d session"];
. set str3d.t_iState = 1
. )
. else
. let
b3d_lightAdd str3d.t_o3dsession
"light" SO3_DIRECTIONAL_LIGHT nil -> light in
. let SO3SceneLoadEntity
. "voyager_test_logo"
. _checkpack "locked/voyager/3d/logo.mesh"
. -> logo in
. (
. 2
. else
. set str3d.t_iState = if (!
b3d_lightSetColors light [make_rgba 250 250 250 0 make_rgba 255 255 255 0]) &&
.
.
.
.
. SO3SceneLoadResource
. _checkpack "locked/voyager/3d/logo.material" SO3_RESOURCE_MATERIAL
. ) &&
. SO3SceneLoadResource
. _checkpack "locked/voyager/3d/logo.mesh" SO3_RESOURCE_MESH
. ) &&
.
. (!
std_objIsNil SO3ObjectSetScale logo [0.01 0.01 0.01]) &&
.
. (!createBgLogo str3d)
. then
. 0
. else
. 1
. );;
.
.
.
.fun init3d (str3d)=
. set str3d.t_o3dview =
b3d_initView _channel str3d.t_oWinMother mkfun3 @cb3dViewInit str3d nil;
. if str3d.t_iState != 0 then
. (
. printDebug [str3d "Initialization aborted"];
. 1
. )
. else
. ) then
. set str3d.t_iState = 1
. else
. (
.
. 0
. );;
.
.fun init ()=
. mkStrTEST3D [
. 0
. nil nil
. nil [640 480]
. _LDbitmap _channel _checkpack "logo.bmp"
. ];;
.
.fun showConsole (state)=
. if state then
. (
. _showconsole;
. set debug = 1
. )
. else
. set debug = 0;;
.
.fun main ()=
. showConsole 1;
. let init -> str3d in
. (
.
b3d_initError "log/test3d.log" str3d.t_iErrMask iLIB3D_LOGHARDFILE;
. createWin str3d;
. init3d str3d;
. createDebug str3d;
. if str3d.t_iState != 0 then
. _fooS "ERROR !"
. else
. _fooS "OK !";
. 0
. );;