#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

161 lines
4.2 KiB

<?xml version="1.0"?>
<Template originator = "Markus Palme"
created = "07/03/2004"
lastModified = "07/20/2005">
<!-- Template Header -->
<TemplateConfiguration>
<Name>${res:Templates.Project.Direct3DApplication.Name}</Name>
<Category>VBNet</Category>
<Subcategory>${res:Templates.File.Categories.WindowsApplications}</Subcategory>
<Icon>VBNet.Project.FullProject</Icon>
<LanguageName>VBNet</LanguageName>
<Description>${res:Templates.Project.Direct3DApplication.Description}</Description>
</TemplateConfiguration>
<!-- Actions -->
<Actions>
<Open filename = "MainClass.vb"/>
</Actions>
<!-- Template Content -->
<Combine name = "${ProjectName}" directory = ".">
<Options>
<StartupProject>${ProjectName}</StartupProject>
</Options>
<Project name = "${ProjectName}" directory = ".">
<Options OutputType = "WinExe" />
<ProjectItems>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.DirectX" />
<Reference Include="Microsoft.DirectX.Direct3D" />
<Import Include="Microsoft.VisualBasic" />
<Import Include="System" />
<Import Include="System.Collections" />
<Import Include="System.Collections.Generic" />
<Import Include="System.Drawing" />
<Import Include="System.Diagnostics" />
<Import Include="System.Windows.Forms" />
<Import Include="Microsoft.DirectX" />
<Import Include="Microsoft.DirectX.Direct3D" />
</ProjectItems>
<Files>
<File name="MainClass.vb"><![CDATA[${StandardHeader.VBNET}
' This is the main class of my Direct3D application
Public Class MainClass
Inherits Form
' The rendering device
Private device As Device
Public Sub New()
Me.ClientSize = new System.Drawing.Size(640, 480)
Me.Text = "Direct3D Project"
End Sub
Public Function InitializeGraphics() As Boolean
Try
' Now let's setup the Direct3D stuff
Dim presentParams As New PresentParameters()
presentParams.Windowed = true
presentParams.SwapEffect = SwapEffect.Discard
' Create the device
device = new Device(0, DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, presentParams)
' Setup the event handlers for the device
AddHandler device.DeviceLost, AddressOf InvalidateDeviceObjects
AddHandler device.DeviceReset, AddressOf RestoreDeviceObjects
AddHandler device.Disposing, AddressOf DeleteDeviceObjects
AddHandler device.DeviceResizing, AddressOf EnvironmentResizing
return True
Catch ex As DirectXException
Return False
End Try
End Function
Protected Overridable Sub InvalidateDeviceObjects(sender As Object, e As EventArgs)
End Sub
Protected Overridable Sub RestoreDeviceObjects(sender As Object, e As EventArgs)
End Sub
Protected Overridable Sub DeleteDeviceObjects(sender As Object, e As EventArgs)
End Sub
Protected Overridable Sub EnvironmentResizing(sender As Object, e As CancelEventArgs)
End Sub
' This method moves the scene
Protected Overridable Sub FrameMove()
' TODO : Frame movement
End Sub
' This method renders the scene
Protected Overridable Sub Render()
If Not device Is Nothing
device.Clear(ClearFlags.Target, Color.Blue, 1.0f, 0)
device.BeginScene()
' TODO : Scene rendering
device.EndScene()
device.Present()
End If
End Sub
' Our mainloop
Public Sub Run()
' While the form is still valid, render and process messages
Do While Created
FrameMove()
Render()
Application.DoEvents()
Loop
End Sub
Protected Overrides Sub OnPaint(e As PaintEventArgs)
Me.Render()
End Sub
Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs)
MyBase.OnKeyPress(e)
If AscW(e.KeyChar) = CInt(Keys.Escape)
Close()
End If
End Sub
' The main entry point for the application
Shared Sub Main()
Dim mainClass As New MainClass()
If Not mainClass.InitializeGraphics()
MessageBox.Show("Error while initializing Direct3D")
Return
End If
mainClass.Show()
mainClass.Run()
End Sub
End Class
]]></File>
<File name="AssemblyInfo.vb" src="DefaultAssemblyInfo.vb"/>
</Files>
</Project>
</Combine>
</Template>