Private Sub Render()
Dim intX As Integer
If m_obj3DDevice Is Nothing Then
Return
End If
Try
' clear the backbuffer to the colour set by user, black when first run
m_obj3DDevice.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, m_colBackColour, 1.0F, 0)
' begin the scene
m_obj3DDevice.BeginScene()
' setup the world, view, and projection matrices
SetupMatrices()
' meshes are divided into subsets, one for each material, render them in a loop
For intX = 0 To m_matMaterial.Length - 1
' set the material for this subset
m_obj3DDevice.Material = m_matMaterial(intX)
' draw the mesh subset
m_mshMesh.DrawSubset(intX)
Next intX
'end the scene
m_obj3DDevice.EndScene()
' display on screen
m_obj3DDevice.Present()
Catch objException As Exception
' bugger, somethings gone wrong, so tell user
MessageBox.Show("The following error has occured during the render process" & ControlChars.CrLf & _
ControlChars.CrLf & objException.Message, "Mesh View ~ Render Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
' set flg to stop this code being called again
m_blnRenderScene = False
End Try
End Sub