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

📄 directx.vb.svn-base

📁 MirUnleashed vb.net Module modMainServer Public WithEvents Socket As New WinsockServer Pub
💻 SVN-BASE
字号:
'### Visual Basic.NET and Direct X9 Legend of MiR Project ###'
'### Mir Unleashed Client DirectX Module ###'
'### http://www.lomcn.co.uk ###' '### Credits to TrueADM and DeathWish ###'

Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D

Module DirectX

    Public Sub Initialize(ByVal TargetForm As Form)

        D3Dpp.BackBufferFormat = Direct3D.Manager.Adapters(0).CurrentDisplayMode.Format

        D3Dpp.BackBufferWidth = 800
        D3Dpp.BackBufferHeight = 600

        D3Dpp.BackBufferCount = 1

        D3Dpp.SwapEffect = SwapEffect.Discard

        D3Dpp.PresentationInterval = PresentInterval.Immediate


        D3Dpp.MultiSample = MultiSampleType.None
        D3Dpp.Windowed = True

        D3D = New Direct3D.Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, TargetForm.Handle, Direct3D.CreateFlags.SoftwareVertexProcessing, D3Dpp)

        GameSprite = New Direct3D.Sprite(D3D)

        GameTexture = Direct3D.TextureLoader.FromFile(D3D, My.Application.Info.DirectoryPath & "\1.bmp", 800, 600, 1, Usage.RenderTarget, Format.A8B8G8R8, Pool.Default, Filter.None, Filter.None, 1)
        GameSurface = GameTexture.GetSurfaceLevel(0)

        AlphaTexture = Direct3D.TextureLoader.FromFile(D3D, My.Application.Info.DirectoryPath & "\Data\1.bmp", 800, 600, 1, Usage.RenderTarget, Format.A8B8G8R8, Pool.Default, Filter.None, Filter.None, 1)
        AlphaSurface = AlphaTexture.GetSurfaceLevel(0)

        GlowingTexture = Direct3D.TextureLoader.FromFile(D3D, My.Application.Info.DirectoryPath & "\Data\1.bmp", 800, 600, 1, Usage.RenderTarget, Format.A8B8G8R8, Pool.Default, Filter.None, Filter.None, 1)
        GlowingSurface = GlowingTexture.GetSurfaceLevel(0)

        MistTexture = Direct3D.TextureLoader.FromFile(D3D, My.Application.Info.DirectoryPath & "\Data\1.bmp", 800, 600, 1, Usage.RenderTarget, Format.A8B8G8R8, Pool.Default, Filter.None, Filter.None, 1)
        MistSurface = MistTexture.GetSurfaceLevel(0)

        SnowTexture = Direct3D.TextureLoader.FromFile(D3D, My.Application.Info.DirectoryPath & "\Data\1.bmp", 800, 600, 1, Usage.RenderTarget, Format.A8B8G8R8, Pool.Default, Filter.None, Filter.None, 1)
        SnowSurface = MistTexture.GetSurfaceLevel(0)

        MainSurface = D3D.GetBackBuffer(0, 0, BackBufferType.Mono)

        D3D.RenderState.Lighting = True

    End Sub

    Sub AttemptRecovery()
        ' when we lose the device, this code will run
        Try
            D3D.TestCooperativeLevel()  'Test for Exclusive control if it's lacking, it'll throw

        Catch e As DeviceLostException     'DeviceLostException. If it does, we just wait until
            'our game is given the focus again.
        Catch e As DeviceNotResetException  'If we have the focus, we only need to reset the device:

            ' Basically we re-do what we did in initialize graphics
            Try
                'Here, you need to destroy everything in Pool_Default, and all instances of the
                ' swapchain class.

                D3D.Reset(D3Dpp) 'reset the device, so we can use it again
                DeviceLost = False    'device is no longer lost!!!

                'Now recreate all your Pool_Default stuff, and your swapchain instances.

            Catch bug As DeviceLostException  'it is possible to lose the device while resetting it.
                'if it got lost again or not reset, do nothing
            End Try

        End Try
    End Sub 'AttemptRecovery 

End Module

⌨️ 快捷键说明

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