⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graphicsform.vb

📁 Windows mobile 6 Direct3D 编程例子
💻 VB
字号:
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic
Imports Microsoft.WindowsMobile.DirectX
Imports Microsoft.WindowsMobile.DirectX.Direct3D


Module ProgramMain
    Sub Main()
        Dim frm As GraphicsForm = New GraphicsForm

        ' Initialize Direct3D
        If Not frm.Init() Then
            MessageBox.Show("Could not initialize Direct3D")
            Return
        End If

        System.Windows.Forms.Application.Run(frm)
    End Sub
End Module

Public Class GraphicsForm
    Inherits Form
    ' Our global variables for me project
    Dim DeviceForm As Device = Nothing

    Dim PParameters As New PresentParameters

    ' Setup the rendering device
    Public Function Init() As Boolean
        Try
            ' We don't want to run fullscreen
            PParameters.Windowed = True
            ' Discard the frames
            PParameters.SwapEffect = SwapEffect.Discard
            'Create a DeviceForm
            DeviceForm = New Device(0, DeviceType.Default, Me, _
                CreateFlags.None, PParameters)
        Catch
            ' Catch any errors and return a failure
            Return False
        End Try

        Return True
    End Function

    'All rendering for each frame occurs here
    Private Sub Render()
        If Not IsNothing(DeviceForm) Then
            'Clear the backbuffer to a white color
            DeviceForm.Clear(ClearFlags.Target, _
                System.Drawing.Color.White, 1.0F, 0)
            'Begin the scene
            DeviceForm.BeginScene()
            DeviceForm.EndScene()
            ' Update the screen
            DeviceForm.Present()
        Else
            'DeviceForm is has not been set
        End If
    End Sub


    'Fired when the form needs to be redrawn
    Protected Overrides Sub OnPaint( _
        ByVal e As System.Windows.Forms.PaintEventArgs)

        ' Render on painting
        Me.Render()
    End Sub


End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -