;; ----------------------------------------------------------------------------
;; Irrlicht Wrapper For Imperative Languages - Purebasic Examples
;; Previous IrrlichtWrapper and FreeBasic-Example by Frank Dodd (2006)
;; Improved IrrlichtWrapper and PureBasic-Example by Michael Taupitz (2006)
;; ----------------------------------------------------------------------------
;; Example 30: Using the Image-GUI
;; This example show some features of Irrlicht. It uses a 'own' EventReceiver,
;; to capture the Events directly. It also uses the XML-Interface to REad a XML-File,
;; and you can see how to use the Image-Gui.
;; ----------------------------------------------------------------------------

;; ////////////////////////////////////////////////////////////////////////////
;; Include the Irr3D-Requester
                                
;; ----------------------------------------------------------------------------
;; Irrlicht Wrapper For Imperative Languages - Purebasic Examples
;; IrrlichtWrapper and FreeBasic-Example by Frank Dodd (2006)
;; Improved IrrlichtWrapper and PureBasic-Example by Michael Taupitz (2006)
;; ----------------------------------------------------------------------------
;; Example 17 : Selecting Nodes With the Mouse
;; This example allows you To move the mouse around the display And To Select
;; nodes on the screen by hovering over them.
;; ----------------------------------------------------------------------------

;

XIncludeFile #PB_Compiler_Home + "Includes\IrrlichtWrapper_Include.pbi"

Structure videomodeStruct
mode.l
dimension.IRR_DIM2D
depth.l
EndStructure


Structure vmodeSettingsStruct
videomode.videomodeStruct
device.l
Fullscreen.l
stencilshadows.l
antialiasing.l
vSync.l
useFpu.l
EndStructure

Enumeration
#IRR3DREQ_LAUNCH
#IRR3DREQ_CANCEL
#IRR3DREQ_NONE
EndEnumeration


Define irr3DRequesterSetting.vmodeSettingsStruct

UseJPEGImageDecoder()

Procedure.l Irr3DRequester(doStart.l = #True)
Shared irr3DRequesterSetting

Define MainWindow.l   ; Id of the Window
Define comboDriver.l   ; Id of the ComboBox for Drivers
Define comboMode.l   ; Id of the combobox for ScreenModes

;Ids of the Checkboxes
Define cbFullscreen.l, cbSize.l, cbAnitialias.l, cbStencilshadows.l, cbVSync.l, cbFPU.l

;Ids of the Buttons
Define btnCancel.l, btnOk.l

Define drivercount.l, DriverId.l, DriverName.s    ; Infos about the Drivers...

Define irr.l  ; Pointer to the Irrlicht-Engine

Define vcount.l   ; Counter for the Videomode-List

Define i.l  ; simple Variable for For-Loops

Define Quit.l = #IRR3DREQ_NONE    ; Quit-Flag


Define event.l  ; Window-Event

NewList videomodes.videomodeStruct()


; #### Here Starts the Requester !

OpenPreferences("Irr3D.prefs")
irr3DRequesterSetting\videomode\mode = ReadPreferenceLong  ("ScreenMode"        , -1)
irr3DRequesterSetting\device = ReadPreferenceLong  ("Device"        , 4)
irr3DRequesterSetting\Fullscreen = ReadPreferenceLong  ("FullScreen"        , #False)
irr3DRequesterSetting\stencilshadows = ReadPreferenceLong  ("StencilShadows", #False)
irr3DRequesterSetting\antialiasing = ReadPreferenceLong  ("AntiAlias", #False)
irr3DRequesterSetting\vSync = ReadPreferenceLong  ("VSync", #False)
irr3DRequesterSetting\useFpu = ReadPreferenceLong  ("useFpu", #False)
ClosePreferences()

MainWindow.l = OpenWindow(#PB_Any, 503, 382, 380, 236, "Irr3DRequester",  #PB_Window_SystemMenu  | #PB_Window_TitleBar )
If MainWindow
If CreateGadgetList(WindowID(MainWindow))
ImageGadget(#PB_Any, 0, 0, 70, 40, ImageID(CatchImage(#PB_Any,?logo)))  ; TODO
comboDriver.l = ComboBoxGadget(#PB_Any, 120, 90, 240, 200)
comboMode.l = ComboBoxGadget(#PB_Any, 120, 120, 240, 200)
TextGadget(#PB_Any, 10, 90, 90, 20, "Driver")
TextGadget(#PB_Any, 10, 120, 100, 20, "Videomode")

cbFullscreen.l = CheckBoxGadget(#PB_Any,10,150,120,20,"Fullscreen")
SetGadgetState(cbFullscreen,irr3DRequesterSetting\Fullscreen)

cbStencilshadows.l = CheckBoxGadget(#PB_Any,140,150,120,20,"Stencilshadows")
SetGadgetState(cbStencilshadows,irr3DRequesterSetting\stencilshadows)

cbAnitialias.l = CheckBoxGadget(#PB_Any,250,150,120,20,"AntiAlias")
SetGadgetState(cbAnitialias,irr3DRequesterSetting\antialiasing)

cbVSync.l = CheckBoxGadget(#PB_Any,140,170,120,20,"VSync")
SetGadgetState(cbVSync,irr3DRequesterSetting\vSync)

cbFPU.l = CheckBoxGadget(#PB_Any,10,170,120,20,"use FPU")
SetGadgetState(cbFPU,irr3DRequesterSetting\useFpu)


btnOk.l = ButtonGadget(#PB_Any, 280, 200, 90, 30, "OK")
btnCancel.l = ButtonGadget(#PB_Any, 10, 200, 100, 30, "Cancel")
EndIf

; Now we use the Irrlicht-Device NULL to get all possible Screenmodes
irr.l = IrrStart(#IRR_EDT_NULL, 0, 0, #IRR_WINDOWED, #IRR_NO_SHADOWS, #IRR_IGNORE_EVENTS);
If irr
vcount.l = IrrGetVideoModeCount()
For i = 0 To vcount
AddElement(videomodes())
videomodes()\mode = i
videomodes()\depth = IrrGetVideoModeDepth(i)
IrrGetVideoModeResolution(i, @videomodes()\dimension)
Next

;With the Screenmodes, we can populate the Comob-Boxes
ForEach videomodes()
AddGadgetItem(comboMode,videomodes()\mode, Str(videomodes()\dimension\width)+"x"+Str(videomodes()\dimension\height)+" "+Str(videomodes()\depth)+" bit")
Next
; Select previous mode
SetGadgetState(comboMode,irr3DRequesterSetting\videomode\mode)

Restore drivers
Read DriverId.l
drivercount.l =0
While DriverId <> -1
Read DriverName.s
AddGadgetItem(comboDriver,drivercount,DriverName)
If DriverId = irr3DRequesterSetting\device
SetGadgetState(comboDriver,drivercount);
EndIf

Read DriverId.l
drivercount+1
Wend
IrrStop()
Else
MessageRequester("Problem !","Not able to create the NULL-Device with Irrlicht !",#PB_MessageRequester_Ok)
ProcedureReturn #False; Not Sucessfull
EndIf


SetActiveWindow(MainWindow)
Repeat
event = WaitWindowEvent()

Select event

Case #PB_Event_Gadget

Select EventGadget()
Case btnOk
Quit = #IRR3DREQ_LAUNCH

Case btnCancel
Quit = #IRR3DREQ_CANCEL

EndSelect

Case #PB_Event_CloseWindow
Quit = #IRR3DREQ_CANCEL
EndSelect
Until Quit <> #IRR3DREQ_NONE
Else
MessageRequester("Problem !","Not able to create the Irr3DRequester-Window !",#PB_MessageRequester_Ok)
ProcedureReturn #False; Not Sucessfull
EndIf

If Quit = #IRR3DREQ_LAUNCH
;find Videomode
irr3DRequesterSetting\videomode\mode = GetGadgetState(comboMode);
ForEach videomodes()
If videomodes()\mode = irr3DRequesterSetting\videomode\mode
irr3DRequesterSetting\videomode\dimension\width = videomodes()\dimension\width
irr3DRequesterSetting\videomode\dimension\height = videomodes()\dimension\height
irr3DRequesterSetting\videomode\depth = videomodes()\depth
Break;
EndIf
Next
; find drive-ID
Restore drivers
Read DriverId.l
While DriverId <> -1
Read DriverName.s
If DriverName = GetGadgetText(comboDriver)
irr3DRequesterSetting\device = DriverId
Break;
EndIf
Read DriverId.l
Wend

irr3DRequesterSetting\Fullscreen = GetGadgetState(cbFullscreen)
irr3DRequesterSetting\stencilshadows = GetGadgetState(cbStencilshadows)
irr3DRequesterSetting\antialiasing = GetGadgetState(cbAnitialias)
irr3DRequesterSetting\vSync = GetGadgetState(cbVSync)
irr3DRequesterSetting\useFpu = GetGadgetState(cbFPU)


CreatePreferences("Irr3D.prefs")
WritePreferenceLong("ScreenMode",irr3DRequesterSetting\videomode\mode)
WritePreferenceLong("Device",irr3DRequesterSetting\device)
WritePreferenceLong("FullScreen",irr3DRequesterSetting\Fullscreen)
WritePreferenceLong("StencilShadows",irr3DRequesterSetting\stencilshadows)
WritePreferenceLong("AntiAlias",irr3DRequesterSetting\antialiasing)
WritePreferenceLong("VSync",irr3DRequesterSetting\vSync)
WritePreferenceLong("useFpu",irr3DRequesterSetting\useFpu)
ClosePreferences()

CloseWindow(MainWindow)
;Should we start the correct device ?
If doStart = #True

ProcedureReturn IrrStartEx(irr3DRequesterSetting\device,irr3DRequesterSetting\videomode\dimension\width,irr3DRequesterSetting\videomode\dimension\height,irr3DRequesterSetting\Fullscreen, irr3DRequesterSetting\stencilshadows,#True, irr3DRequesterSetting\videomode\depth, irr3DRequesterSetting\antialiasing, irr3DRequesterSetting\useFpu,irr3DRequesterSetting\vSync,0)

EndIf

ProcedureReturn #True ; Successfull, but not started the Irrlicht-Device
EndIf

CloseWindow(MainWindow)
ProcedureReturn #False; Not Sucessfull or Canceled

EndProcedure


DataSection
drivers:
Data.l #IRR_EDT_DIRECT3D8
Data.s "DirectX 8"

Data.l #IRR_EDT_DIRECT3D9
Data.s "DirectX 9"

Data.l #IRR_EDT_OPENGL
Data.s "OpenGl"

Data.l #IRR_EDT_SOFTWARE
Data.s "Software"

Data.l #IRR_EDT_SOFTWARE2
Data.s "Software 2"

Data.l -1

logo: IncludeBinary "media\WrapperLogo.jpg"

EndDataSection
; IDE Options = PureBasic v4.02 (Windows - x86)
; CursorPosition = 87
; FirstLine = 68

;; ////////////////////////////////////////////////////////////////////////////
;; Global variables

Global MessageText.s
Global Caption.s
Global StartUpModelFile.s
Global *Model.l
Global *SkyBox.l
Global g_Quit.l = #False
Global *skin.l = #Null

Procedure showAboutText()
	; create modal message box With the text
	; loaded from the xml file.
IrrGuiAddMessageBox(Caption,MessageText,#True,#IRR_EMBF_OK,0,-1)

EndProcedure


Procedure loadSkin(*skin.l, skinNum.l)

	If(skinNum < 0 Or skinNum > 2 Or *skin = #Null)
		ProcedureReturn;
EndIf
	;Bubbly blue
	If skinNum =  0
		;Here we load a nice glass button image To use when drawing all 3D button faces
		;he skin supports animated images, so we specify * 1 indicating there is only one frame
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_BUTTON_PANE_STANDARD, "media/skins/bb1.tga", 0,0,114*1,114,114,114,#False);
		
		;Here we load an image used For animating the button when it's pressed
		;The animation has 8 frames laid out horizontally, so we specify that As *8 in the Ax parameter
		;If the animation was laid out vertically, you would specify *8 in the Ay parameter
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_BUTTON_PANE_PRESSED, "media/skins/bbp2.tga", 0,0,114*8,114,114,114,#False);

		;There are 8 frames, so we want them To animate pretty quickly on a button press
		IrrGuiImageSkinSetAnimSpeed(*skin,#IRR_EGEIT_BUTTON_PANE_PRESSED, 10);

		;We only want the animation To happen once, so we turn looping off.
		;To make the animation happen again, skin->resetAnimation() must be called when the
		;mouse button is clicked. Check the event receiver For info on how To do that.
		IrrGuiImageSkinSetLoop(*skin,#IRR_EGEIT_BUTTON_PANE_PRESSED, #False);

		;Here we load an animated image For the window titles
		;4 frames, laid out horizontally.
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_WINDOW_BACKGROUND_TITLEBAR, "media/skins/fireline_e0.tga", 0,0,600*4,50,600,50,#False);
IrrGuiImageSkinSetAnimSpeed(*skin,#IRR_EGEIT_WINDOW_BACKGROUND_TITLEBAR, 70);	
		
		;Finally, load the image To be used For window backgrounds.
		;It's a simple 2 frame animation of some lighting flickering
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_WINDOW_BACKGROUND, "media/skins/bg4.tga", 0,0,232*1,232,232,232,#False);

		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_TAB_BODY, "media/skins/bg4.tga", 0,0,232*1,232,232,232,#False);
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_TAB_BUTTON, "media/skins/bb1.tga", 0,0,114*1,114,114,114,#False);
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_MENU_PANE, "media/skins/bg4.tga", 0,0,232*1,232,232,232,#False);
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_TOOLBAR, "media/skins/bg4.tga", 0,0,232*1,232,232,232,#False);
	ElseIf skinNum = 1

		;Aero Glass
		;Here we load a nice glass button image To use when drawing all 3D button faces
		;The skin supports animated images, so we specify * 1 indicating there is only one frame
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_BUTTON_PANE_STANDARD, "media/skins/blackbsq.tga", 0,0,145*1,145,145,145,#False);
		

		;Here we load an image used For animating the button when it's pressed
		;The animation has 8 frames laid out horizontally, so we specify that As *8 in the Ax parameter
		;If the animation was laid out vertically, you would specify *8 in the Ay parameter
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_BUTTON_PANE_PRESSED, "media/skins/blackbsqpush.tga", 0,0,145*8,145,145,145,#False);

		;There are 8 frames, so we want them To animate pretty quickly on a button press
		IrrGuiImageSkinSetAnimSpeed(*skin,#IRR_EGEIT_BUTTON_PANE_PRESSED, 10);

		;We only want the animation To happen once, so we turn looping off.
		;To make the animation happen again, skin->resetAnimation() must be called when the
		;mouse button is clicked. Check the event receiver For info on how To do that.
		IrrGuiImageSkinSetLoop(*skin,#IRR_EGEIT_BUTTON_PANE_PRESSED, #False);

		;Here we load a 'blank' image so we don't have titles
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_WINDOW_BACKGROUND_TITLEBAR, "media/skins/blank.tga", 0,0,32*1,32,32,32,#False);
		
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_WINDOW_BACKGROUND, "media/skins/bg5.tga", 0,0,399*1,399,399,399,#False);
		
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_TAB_BODY, "media/skins/bg5.tga", 0,0,399*1,399,399,399,#False);
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_TAB_BUTTON, "media/skins/blackbsq.tga", 0,0,145*1,145,145,145,#False);
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_MENU_PANE, "media/skins/bg5.tga", 0,0,399*1,399,399,399,#False);
		IrrGuiImageSkinLoad(*skin,#IRR_EGEIT_TOOLBAR, "media/skins/bg5.tga", 0,0,399*1,399,399,399,#False);
EndIf

EndProcedure

; 	Finally, the third function creates a toolbox window. In this simple mesh viewer,
; 	this toolbox only contains a tab control With three edit boxes For changing
; 	the scale of the displayed model.
Procedure createToolBox()
;
;
*rooElm.l = IrrGuiGetRootGUIElement();
	; remove tool box if already there
*tbox.l = IrrGuiGetElementFromId(*rooElm,5000,#True);
If *tbox <> #Null
IrrGuiRemoveElement(*tbox)
EndIf
;
; 	// create the toolbox window
*wnd.l = IrrGuiAddWindow(450,25,640,480,#False, "Toolset", 0, 5000)

; 	// create tab control And tabs
*tab.l = IrrGuiAddTabControl(2,20,640-452,480-7,*wnd,#True,#True,9999)
*t1.l = IrrGuiTabControlAddTab(*tab,"Scale")
*t2.l = IrrGuiTabControlAddTab(*tab,"Empty Tab")

; 	// add some edit boxes And a button To tab one
IrrGuiAddEditBox("1.0",40,50,130,70,#True,*t1,901)
IrrGuiAddEditBox("1.0",40,80,130,100,#True,*t1,902)
IrrGuiAddEditBox("1.0",40,110,130,130,#True,*t1,903)

IrrGuiAddButton("set",10,150,100,190,*t1,1101)

; 	// add senseless checkbox
IrrGuiAddCheckBox(#True,10,220,200,240,*t1,-1,"Senseless Checkbox");

; 	// add undocumentated transparent control
IrrGuiAddStaticText("Transparent Control:", 10,240,150,260, #True, #False, #False, *t1);

*scrollbar.l = IrrGuiAddScrollBar(#True,10,260,150,275, *t1, 104)
IrrGuiScrollBarSetMax(*scrollbar,255)
;
; 	// bring irrlicht engine logo To front, because it
; 	// now may be below the newly created toolbox
*elm.l = IrrGuiGetElementFromId(*rooElm,666)
IrrGuiBringToFront(*rooElm,*elm)
; 	root->bringToFront(root->getElementFromId(666, true));
; }
EndProcedure

ProcedureCDLL.l eventCallback(*event.SEvent)
Debug("EventCB")
If *event\EventType = #IRR_EET_GUI_EVENT
id.l = IrrGuiGetId(*event\GuiEvent\Caller)
Debug("ID="+Str(id))
Select *event\GuiEvent\EventType
Case #IRR_EGET_MENU_ITEM_SELECTED
item.l = IrrGuiContextMenuGetSelectedItem(*event\GuiEvent\Caller)
id.l = IrrGuiContextMenuGetItemCommandId(*event\GuiEvent\Caller,item);
Select id
Case 100:  ;// File -> Open Model
IrrGuiAddFileOpenDialog("Please select a model file to open",#True,0,0)
Case 200:  ;// File -> Quit
g_Quit = #True;
					Case 300: ;// View -> Skybox
					  IrrSetNodeVisibility(*SkyBox,1!IrrGetNodeVisibility(*SkyBox))
; 						SkyBox->setVisible(!SkyBox->isVisible());
; 						Break;
					Case 400: ;// View -> Debug Information
						If *Model <> 0
;   						  IrrSetNodeDebugData(*Model,1)
; 							Model->setDebugDataVisible(!Model->isDebugDataVisible());
EndIf
					Case 500: ;// Help->About
						showAboutText();
					Case 610: ;// View -> Material -> Solid
						If *Model<>0
						  IrrSetNodeMaterialType(*Model,#IRR_EMT_SOLID)
						EndIf
					Case 620: ;// View -> Material -> Transparent
						If *Model<>0
						  IrrSetNodeMaterialType(*Model,#IRR_EMT_TRANSPARENT_ADD_COLOR)
						EndIf
					Case 630: ;// View -> Material -> Reflection
						If *Model<>0
						  IrrSetNodeMaterialType(*Model,#IRR_EMT_SPHERE_MAP)
						EndIf
EndSelect
Case #IRR_EGET_FILE_SELECTED:
*adress.l =      IrrGuiFileOpenDialogGetFilename(*event\GuiEvent\Caller);
fname.s = PeekS(*adress,-1,#PB_Unicode)
Debug(fname)

			Case #IRR_EGET_SCROLL_BAR_CHANGED:;
; 				// control skin transparency
				If (id = 104)
pos.l = IrrGuiScrollBarGetPos(*event\GuiEvent\Caller)
IrrGuiSetAlpha(pos);
EndIf

			  Case #IRR_EGET_COMBO_BOX_CHANGED:
				  If(id = 456)
				    selected.l = IrrGuiComboBoxGetSelected(*event\GuiEvent\Caller)
				    Debug("Selcetd SkiN="+Str(selected))
					  loadSkin(*skin, selected );
					EndIf
			  Case #IRR_EGET_BUTTON_CLICKED:
				  Select (id)

Case 1101:
; 						// set scale
; 						gui::IGUIElement* root = env->getRootGUIElement();
; 						core::vector3df scale;
; 						core::stringc s;
*rooElm.l = IrrGuiGetRootGUIElement();

*elm.l = IrrGuiGetElementFromId(*rooElm,901,#True)
Debug("*elm="+Str(*elm))
si.s = PeekS(IrrGuiGetText(*elm),-1,#PB_Unicode)
x.f = ValF(si)
*elm.l = IrrGuiGetElementFromId(*rooElm,902,#True)
Debug("*elm="+Str(*elm))
si.s = PeekS(IrrGuiGetText(*elm),-1,#PB_Unicode)
y.f = ValF(si)
*elm.l = IrrGuiGetElementFromId(*rooElm,903,#True)
Debug("*elm="+Str(*elm))
si.s = PeekS(IrrGuiGetText(*elm),-1,#PB_Unicode)
z.f = ValF(si)

Debug("Scaling="+StrF(x)+","+StrF(y)+","+StrF(z))
If *Model <> 0
IrrSetNodeScale(*Model,x,y,z)
EndIf
				Case 1102:
				  IrrGuiAddFileOpenDialog("Please select a model file to open",#True,0,0)
				Case 1103:
					showAboutText();
				Case 1104:
					createToolBox();

EndSelect

EndSelect

EndIf
ProcedureReturn #False
EndProcedure



; -----------------------------------------------------------------------------
; To Start the Irrlicht-Device we use the Irr3DRequester, to make it more comfortable
; for the Users, and also easier to test different resolutions and devices.
If Irr3DRequester()

IrrSetResizeAble(#True)

*er = IrrCreateEventReceiver(@eventCallback())
IrrSetEventReceiver(*er)


; Set the title of the display
IrrSetWindowCaption( "Example 30: Using the Image-GUI" )



IrrSetTextureCreationFlag(#IRR_ETCF_ALWAYS_32_BIT,#True)
IrrSetTextureCreationFlag(#IRR_ETCF_CREATE_MIP_MAPS, #False);
*skin.l = IrrGuiCreateImageSkin()
	loadSkin(*skin, 0); //load bubbly blue as default
IrrGuiSetSkin(*skin)


;Read configuration from xml file

*xml.l = IrrXmlCreateReader("media/config.xml")

	While *xml And IrrXmlRead(*xml)
	  Select IrrXmlGetNodeType(*xml)
	    Case #IRR_EXN_TEXT
			  ;in this xml file, the only text which occurs is the messageText
			  MessageText = PeekS(IrrXmlGetNodeData(*xml),-1,#PB_Unicode)
			  Debug(MessageText)
Case #IRR_EXN_ELEMENT
		    *nodename.l = IrrXmlGetNodeName(*xml)
		    If *nodename <> 0
			  If PeekS(IrrXmlGetNodeName(*xml),-1,#PB_Unicode) = "startUpModel"
	  		    StartUpModelFile = PeekS(IrrXmlGetAttributeValueByName(*xml,"file"),-1,#PB_Unicode);
	  		    Debug(StartUpModelFile)
		  		Else
			  	  If PeekS(IrrXmlGetNodeName(*xml),-1,#PB_Unicode) = "messageText"
				  	  Caption = PeekS(IrrXmlGetAttributeValueByName(*xml,"caption"),-1,#PB_Unicode);
				  	  Debug(Caption)
EndIf
EndIf
EndIf
Case #IRR_EXN_ELEMENT_END
		    *nodename.l = IrrXmlGetNodeName(*xml)
		    If *nodename <> 0
			  If PeekS(IrrXmlGetNodeName(*xml),-1,#PB_Unicode) = "config"
Break;
EndIf
EndIf


EndSelect
Wend
IrrXmlFreeReader(*xml)




*font.l = IrrGetFont("media/fonthaettenschweiler.bmp");
	If *font
	  IrrGuiSetSkinFont(*font)
	EndIf

	; create menu

*menu.l = IrrGuiAddMenu(0,-1);
IrrGuiContextMenuAddItem(*menu, "File", -1, #True, #True)
IrrGuiContextMenuAddItem(*menu, "View", -1, #True, #True)
IrrGuiContextMenuAddItem(*menu, "Help", -1, #True, #True)

*submenu.l = IrrGuiContextMenuGetSubMenu(*menu,0)
IrrGuiContextMenuAddItem(*submenu,"Open Model File...", 100,#True,#False);
IrrGuiContextMenuAddSeparator(*submenu)
IrrGuiContextMenuAddItem(*submenu,"Quit", 200,#True,#False);

*submenu.l = IrrGuiContextMenuGetSubMenu(*menu,1)
IrrGuiContextMenuAddItem(*submenu,"toggle sky box visibility", 300,#True,#False);
IrrGuiContextMenuAddItem(*submenu,"toggle model debug information", 400,#True,#False);

*submenu.l = IrrGuiContextMenuGetSubMenu(*menu,2)
IrrGuiContextMenuAddItem(*submenu,"Solid", 610,#True,#False););
IrrGuiContextMenuAddItem(*submenu,"Transparent", 620,#True,#False););
IrrGuiContextMenuAddItem(*submenu,"Reflection", 630,#True,#False););
IrrGuiContextMenuAddItem(*submenu,"About", 500,#True,#False););


	; create toolbar

*bar.l = IrrGuiAddToolBar(0,0);

	*Image.l = IrrGetTexture("media/open.bmp");	
IrrColorKeyTextureFromPoint(*Image.l,0,0) 	
IrrGuiToolBarAddButton(*bar,1102, "", *Image, 0, #False, #True);

	*Image.l = IrrGetTexture("media/help.bmp");	
IrrColorKeyTextureFromPoint(*Image.l,0,0) 	
IrrGuiToolBarAddButton(*bar,1103, "", *Image, 0, #False, #True);

	*Image.l = IrrGetTexture("media/tools.bmp");	
IrrColorKeyTextureFromPoint(*Image.l,0,0) 	
IrrGuiToolBarAddButton(*bar,1104, "", *Image, 0, #False, #True);


	*box.l = IrrGuiAddComboBox( 100,5,200,25, *bar,0);
	IrrGuiComboBoxAddItem(*box,"Bilinear")
	IrrGuiComboBoxAddItem(*box,"Trilinear");
	IrrGuiComboBoxAddItem(*box,"Anisotropic");
	IrrGuiComboBoxAddItem(*box,"Isotropic");
	IrrGuiComboBoxAddItem(*box,"Psychedelic");
	IrrGuiComboBoxAddItem(*box,"No filtering");

	; create a combobox To allow user To change skin
	IrrGuiAddStaticText("Skin",290,5,315,25,#False,#False,#False,*bar)

	
	*skinbox.l = IrrGuiAddComboBox( 320,5,420,25, *bar,456);
	IrrGuiComboBoxAddItem(*skinbox,"Bubbly Blue");
	IrrGuiComboBoxAddItem(*skinbox,"Aero Glass");

IrrSetTextureCreationFlag(#IRR_ETCF_CREATE_MIP_MAPS, #False);
*SkyBox = IrrAddSkyBoxToScene( IrrGetTexture("./media/irrlicht2_up.jpg"),IrrGetTexture("./media/irrlicht2_dn.jpg"),IrrGetTexture("./media/irrlicht2_lf.jpg"),      IrrGetTexture("./media/irrlicht2_rt.jpg"),        IrrGetTexture("./media/irrlicht2_ft.jpg"),        IrrGetTexture("./media/irrlicht2_bk.jpg"))
IrrSetTextureCreationFlag(#IRR_ETCF_CREATE_MIP_MAPS, #True);


createToolBox()


	;// add a camera scene node
	*OurCamera = IrrAddCameraMaya(0)


;	// load the irrlicht engine logo
*irrLogo.l = IrrGetTexture("./media/irrlichtlogoaligned.jpg");

; while the scene is still running
While g_Quit= #False And IrrRunning()
; begin the scene, erasing the canvas to white before rendering

IrrBeginScene( 255,255,255 )

IrrDrawScene()
; draw the Graphical User Interface
IrrDrawGUI()

IrrDraw2DImageElement(*irrLogo, 10, (480-50), 0,0,108-20,460-429, #True)

; end drawing the scene and render it
IrrEndScene()
Wend

; -----------------------------------------------------------------------------
; Stop the irrlicht engine and release resources
IrrStop()

EndIf

End

; jaPBe Version=3.7.5.643
; Build=0
; Language=0x0000 Language Neutral
; FirstLine=0
; CursorPosition=16
; ExecutableFormat=Windows
; DontSaveDeclare
; EOF