home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 February / CMCD0205.ISO / Software / Freeware / Programare / Sharp / SharpDevelop_1.0.3.1761_Setup.exe / Direct3DProject.xpt < prev    next >
Encoding:
Extensible Markup Language  |  2004-11-10  |  5.3 KB  |  189 lines

  1. <?xml version="1.0"?>
  2. <Template originator   = "Markus Palme"
  3.           created      = "07/03/2004"
  4.           lastModified = "20/10/2004">
  5.     
  6.     <!-- Template Header -->
  7.     <TemplateConfiguration>
  8.         <Name>${res:Templates.Project.Direct3DApplication.Name}</Name>
  9.         <Category>VBNET</Category>
  10.         <Icon>VB.Project.FullProject</Icon>
  11.         <LanguageName>VBNET</LanguageName>
  12.         <Description>${res:Templates.Project.Direct3DApplication.Description}</Description>
  13.     </TemplateConfiguration>
  14.     
  15.     <!-- Actions -->
  16.     <Actions>
  17.         <Open filename = "MainClass.vb"/>
  18.     </Actions>
  19.     
  20.     <!-- Template Content -->
  21.     <Combine name = "${ProjectName}" directory = ".">
  22.         <Options>
  23.             <StartupProject>${ProjectName}</StartupProject>
  24.         </Options>
  25.         
  26.         <Project name = "${ProjectName}" directory = ".">
  27.             <Options/>
  28.             
  29.             <References>
  30.                 <Reference type="Gac" refto="Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  31.                 <Reference type="Gac" refto="Microsoft.DirectX.Direct3D, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  32.             </References>
  33.             
  34.             <Files>
  35.                 <File name="MainClass.vb"><![CDATA[${StandardHeader.VBNET}
  36. Imports System
  37. Imports System.Collections
  38. Imports System.ComponentModel
  39. Imports System.Drawing
  40. Imports System.Windows.Forms
  41.  
  42. Imports Microsoft.DirectX
  43. Imports Microsoft.DirectX.Direct3D
  44.  
  45. Namespace ${StandardNamespace}
  46.     
  47.     ' This is the main class of my Direct3D application
  48.     Public Class MainClass
  49.         Inherits Form
  50.         
  51.         ' The rendering device
  52.         Private device As Device
  53.         
  54.         Public Sub New()
  55.             Me.ClientSize = new System.Drawing.Size(640, 480)
  56.             Me.Text = "Direct3D Project"
  57.         End Sub
  58.         
  59.         Public Function InitializeGraphics() As Boolean
  60.         
  61.             Try
  62.                 ' Now let's setup the Direct3D stuff
  63.                 Dim presentParams As New PresentParameters()
  64.                 presentParams.Windowed   = true
  65.                 presentParams.SwapEffect = SwapEffect.Discard
  66.                 
  67.                 ' Create the device
  68.                 device = new Device(0, DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, presentParams)
  69.                 
  70.                 ' Setup the event handlers for the device
  71.                 AddHandler device.DeviceLost, AddressOf InvalidateDeviceObjects
  72.                 AddHandler device.DeviceReset, AddressOf RestoreDeviceObjects
  73.                 AddHandler device.Disposing, AddressOf DeleteDeviceObjects
  74.                 AddHandler device.DeviceResizing, AddressOf EnvironmentResizing
  75.                 
  76.                 return True
  77.             Catch ex As DirectXException
  78.                 Return False
  79.             End Try
  80.         End Function
  81.         
  82.         Protected Overridable Sub InvalidateDeviceObjects(sender As Object, e As EventArgs)
  83.         
  84.         End Sub
  85.         
  86.         Protected Overridable Sub RestoreDeviceObjects(sender As Object, e As EventArgs)
  87.         
  88.         End Sub
  89.         
  90.         Protected Overridable Sub DeleteDeviceObjects(sender As Object, e As EventArgs)
  91.         
  92.         End Sub
  93.         
  94.         Protected Overridable Sub EnvironmentResizing(sender As Object, e As CancelEventArgs)
  95.         
  96.         End Sub
  97.         
  98.         ' This method moves the scene
  99.         Protected Overridable Sub FrameMove()
  100.             ' TODO : Frame movement
  101.         End Sub
  102.         
  103.         ' This method renders the scene
  104.         Protected Overridable Sub Render()
  105.             If Not device Is Nothing
  106.                 device.Clear(ClearFlags.Target, Color.Blue, 1.0f, 0)
  107.                 device.BeginScene()
  108.                 
  109.                 ' TODO : Scene rendering
  110.                 
  111.                 device.EndScene()
  112.                 device.Present()
  113.             End If
  114.         End Sub
  115.         
  116.         ' Our mainloop
  117.         Public Sub Run()
  118.             ' While the form is still valid, render and process messages
  119.             Do While Created
  120.                 FrameMove()
  121.                 Render()
  122.                 Application.DoEvents()
  123.             Loop
  124.         End Sub
  125.         
  126.         Protected Overrides Sub OnPaint(e As PaintEventArgs)
  127.             Me.Render()
  128.         End Sub
  129.         
  130.         Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs)
  131.             MyBase.OnKeyPress(e)
  132.             If Microsoft.VisualBasic.AscW(e.KeyChar) = CInt(System.Windows.Forms.Keys.Escape)
  133.                 Close()
  134.             End If
  135.         End Sub
  136.         
  137.         ' The main entry point for the application
  138.         Shared Sub Main()
  139.             Dim mainClass As New MainClass()
  140.             
  141.             If Not mainClass.InitializeGraphics()
  142.                 MessageBox.Show("Error while initializing Direct3D")
  143.                 Return
  144.             End If
  145.             
  146.             mainClass.Show()
  147.             mainClass.Run()
  148.         End Sub
  149.     End Class
  150. End Namespace
  151. ]]></File>
  152.             <File name="AssemblyInfo.vb"><![CDATA[Imports System.Reflection
  153. Imports System.Runtime.CompilerServices
  154.  
  155. ' Information about this assembly is defined by the following
  156. ' attributes.
  157. '    <ProjectOptions Target = "WinExe" PauseConsoleOutput = "False" />
  158. ' change them to the information which is associated with the assembly
  159. ' you compile.
  160.  
  161. <assembly: AssemblyTitle("")>
  162. <assembly: AssemblyDescription("")>
  163. <assembly: AssemblyConfiguration("")>
  164. <assembly: AssemblyCompany("")>
  165. <assembly: AssemblyProduct("")>
  166. <assembly: AssemblyCopyright("")>
  167. <assembly: AssemblyTrademark("")>
  168. <assembly: AssemblyCulture("")>
  169.  
  170. ' The assembly version has following format :
  171. '
  172. ' Major.Minor.Build.Revision
  173. '
  174. ' You can specify all values by your own or you can build default build and revision
  175. ' numbers with the '*' character (the default):
  176.  
  177. <assembly: AssemblyVersion("1.0.*")>
  178.  
  179. ' The following attributes specify the key for the sign of your assembly. See the
  180. ' .NET Framework documentation for more information about signing.
  181. ' This is not required, if you don't want signing let these attributes like they're.
  182. <assembly: AssemblyDelaySign(false)>
  183. <assembly: AssemblyKeyFile("")>]]>
  184. </File>
  185.             </Files>
  186.         </Project>
  187.     </Combine>
  188. </Template>
  189.