|
|
楼主 |
发表于 2014-12-8 19:51:13
|
显示全部楼层
本帖最后由 drzzm32 于 2014-12-8 20:12 编辑
来个福利。。。自己再次封装的一个类。。。这个就没注释了。。。福利嘛。。。
- Public Class DxLibVB
- Public Structure Images
- Public Handle As Integer
- Public Width As Integer
- Public Height As Integer
- End Structure
- Public Shared Sub DxSetIcon(ByVal Handle As Integer)
- DxLibDLL.DX.SetWindowIconHandle(Handle)
- End Sub
- Public Shared Sub DxInit(ByVal Title As String, Optional ByVal IsFullScreen As Boolean = False, Optional ByVal Width As Integer = 640, Optional ByVal Height As Integer = 480)
- If IsFullScreen Then
- DxLibDLL.DX.ChangeWindowMode(0)
- Else
- DxLibDLL.DX.ChangeWindowMode(1)
- End If
- DxLibDLL.DX.SetWindowSize(Width, Height)
- DxLibDLL.DX.SetGraphMode(1920, 1080, 32)
- DxLibDLL.DX.SetWindowText(Title)
- DxLibDLL.DX.SetDisplayRefreshRate(60)
- If DxLibDLL.DX.DxLib_Init() = -1 Then
- End
- End If
- End Sub
- Public Shared Sub DxEnd()
- DxLibDLL.DX.DxLib_End()
- End Sub
- Public Shared Function LoadTexture(ByVal IsRelativePath As Boolean, ByVal Path As String, ByRef Image As Images) As Boolean
- If Not Path = "" Or Not Path = Nothing Then
- If IsRelativePath Then
- If FileSystem.Dir(Application.StartupPath & Path) <> "" Then
- Image.Handle = DxLibDLL.DX.LoadGraph(Application.StartupPath & Path)
- Dim ImgTep As Bitmap = New Bitmap(Application.StartupPath & Path)
- Image.Width = ImgTep.Width
- Image.Height = ImgTep.Height
- ImgTep.Dispose()
- Return True
- Else
- Return False
- End If
- Else
- If FileSystem.Dir(Path) <> "" Then
- Image.Handle = DxLibDLL.DX.LoadGraph(Path)
- Dim ImgTep As Bitmap = New Bitmap(Path)
- Image.Width = ImgTep.Width
- Image.Height = ImgTep.Height
- ImgTep.Dispose()
- Return True
- Else
- Return False
- End If
- End If
- Else
- Return True
- End If
- End Function
- Public Shared Sub DrawPic(ByVal Image As Images, ByVal x As Single, ByVal y As Single)
- DxLibDLL.DX.DrawGraphF(x - (Image.Width / 2), y - (Image.Height / 2), Image.Handle, 1)
- 'DxLibDLL.DX.DrawGraphF(x, y, Image.Handle, 1)
- End Sub
- Public Shared Sub DrawPicR(ByVal Image As Images, ByVal Angle As Double, ByVal ExRate As Double, ByVal x As Single, ByVal y As Single, Optional ByVal z As Single = 0)
- DxLibDLL.DX.DrawRotaGraph3D(x - Image.Width / 2, y - Image.Height / 2, z, ExRate, Angle, Image.Handle, 1)
- End Sub
- End Class
复制代码
看了下日文的文档,貌似VB .NET调用这玩意效率不高?谁试试在Timer内调用?
问题找到了!!
需要在进入绘制循环之前调用这个函数:
- DxLibDLL.DX.SetDrawScreen(DxLibDLL.DX.DX_SCREEN_BACK)
复制代码
|
|