'' ----------------------------------------------------------------------------
'' Irrlicht Wrapper For Imperative Languages - Freebasic Examples
'' Frank Dodd (2006-2010)
'' ----------------------------------------------------------------------------
'' Blitz-Irrlicht 1.8.3 Interface by Ed Musolino (AquaLung 2015)
'' ----------------------------------------------------------------------------
'' Example 02: 2D Images
'' This example uses a range of 2D image drawing operations To draw Graphics
'' on the display
'' ----------------------------------------------------------------------------

'' ////////////////////////////////////////////////////////////////////////////
'' Includes For extension libraries
Framework usr.birrlicht

'' ////////////////////////////////////////////////////////////////////////////
'' Global variables
' This wrapper uses a series of types To bring Type errors To your attention
' when passing variables into the wrapper
Global IrrlichtLogo:Int
Global BlitzLogo:Int
Global WrapperLogo:Int
Global screen_width:Int
Global screen_height:Int

'' ////////////////////////////////////////////////////////////////////////////
' start the irrlicht interface. The scene will be rendered using the Irrlicht,
' software renderer, the display will be a window 400 x 200 pixels in size, the
' display will Not support shadows And we will Not capture any keyboard And
' mouse events
screen_width = 640
screen_height = 480
iIrr3D( screen_width, screen_height, 32, False )

' Set the title of the display
iAppTitle( "Example 02: 2D Images" )

' Load bitmap images of important Open Source tools used in this development
' And store them in irrlicht texture objects
IrrlichtLogo = iLoadTexture( "./media/irrlichtlogo.png" )
BlitzLogo = iLoadTexture( "./media/Blitzlogo.bmp" )
WrapperLogo = iLoadTexture( "./media/BlitzIrrlichtLogoSM.png" )

' Create a mask For the Irrlicht logo that makes the white areas of the 
' logo transparent
iMaskTexture( IrrlichtLogo, 255, 255, 255, 0 )

' erase the canvas To Yellow Before rendering
iCameraCLSColor(255,255,0)

' While the scene is still running
While iRun() And (Not iKeyHit(KEY_ESCAPE))
    ' begin the scene
    iBeginScene()

    ' the basic 2D drawing operation copies the whole texture To the screen
    ' at the specified co-ordinates
    iDrawImage( IrrlichtLogo, 1, 4 )

    ' a more flexible Method For drawing To the screen this copies a rectangular
    ' area of the texture To the screen And can use a color keyed mask Or an
    ' alpha channel in the image To make parts of the image transparent.
    ' first supply the texture, Then the destination co-ordinates, Then the
    ' co-ordinates of the rectangular area To copy And finally a flag To
    ' specify whether To use the alpha channel For transparency
    iDrawImageElement( IrrlichtLogo, screen_width - 257,4,0,0,256,74, False )
    iDrawImageElement( BlitzLogo,4, screen_height - 32 - 4,0,0,80,24, False )
    iDrawImageElement( WrapperLogo,( screen_width - 110 ) / 2, screen_height - 32 - 4,0,0,100,32, True )
    iDrawImageElement( WrapperLogo,screen_width - 110 - 4, screen_height - 32 - 4,0,0,100,32, False )

    ' End drawing the scene And render it
    iEndScene()
Wend

' -----------------------------------------------------------------------------
' Stop the irrlicht engine And Release resources
iEndIrr3D()

End