Imports XilonEngineII.NET

''' <summary>
''' Xilon Engine II .NET sample/test app
''' </summary>
''' <remarks>This code sample and engine design is still under development and can change over time creating incompatible issues.</remarks>
Module modMain

    Private Engine As Xilon_EngineII
    'XEII class

    Private WithEvents frmTarget As Form
    'the target (graphics display) to render to

    Public Sub Main()
        Engine = New Xilon_EngineII
        'create new XEII instance

        Engine.Initialize()
        'initalize engine (create DirectX 9 device);
        'Settings should be changed before initializing engine; Default:
        '    Engine.Adapter: XEII_Adapter.Primary
        '    Engine.Behavior: XEII_EnumDeviceBehavior.DeviceBehavior_HardwareVertexProcessing
        '    Engine.ColorDepth: XEII_EnumColorDepth.ColorDepth_Adapterbpp
        '    Engine.Fullscreen: False
        '    Engine.RefreshRate: 60
        '    Engine.Size: Size(800, 600)
        '    Engine.Target: Form (Engine Creates Form) 
        '    Engine.Type: XEII_EnumDeviceType.DeviceType_Hardware
        '    Engine.VSync: False

        frmTarget = CType(Engine.Target, Form)
        'get the form the engine created
        frmTarget.BackColor = Color.Black
        'the backbuffer is black so make the form match

        Dim myCube As XEII_3DModel = XEII_3DModel.Cube(Engine.Scene3D.Props, "myCube", Color.Red)
        'this is a simple 3D model; it creates a 3D model shaped as a 1x1x1 cube with vertexes marked the color red into the "Props" model pool

        'more about the the XEII_3DModel class:
        '    A XEII_3DModel object inherits the XEII_PoolItem to be able to be added to a pool with already needed properties/functions; and also implents the XEII_IPoolItem interface to show it accepts the PoolItem functionality standard
        '    This helps in creating custom classes to have more properties; making a more 'OO' game.

        Engine.Renderer.Start()
        'start the engine renderer (the renderer is started in a different thread)

        Application.Run()
    End Sub

    Private Sub frmTarget_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles frmTarget.DoubleClick
        frmTarget.Close()
        'double click equals end application
    End Sub

    Private Sub frmTarget_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles frmTarget.FormClosing
        Engine = Nothing
        'the engine handles destorying all objects in the pools
        Application.Exit()
    End Sub

End Module