我尝试使用 OpenTK 库在 VB.NET 中创建一个新的 GameWindow。
游戏窗口工作正常,我可以将其最大化或更改其大小非常好,但是窗口出现在任务栏中需要几秒钟,当我在任务栏中右键单击它时非常滞后。
我试过了
- 将更新/渲染时间更改为每秒 1 次更新,这不会改变任何内容
- 在单独的线程中启动 GameWindow
- 不要使用 ILMerge。不会改变任何东西。
源代码
模块主 ( Entry point
)
Imports OpenTK
Imports System.Threading
Module Main
Public Sub Main()
Dim MainGameWindow As New MyGameWindow
MainGameWindow.Run(30, 60) 'Tried changing this to MainGameWindow.Run(1, 1)
End Sub
End Module
类 MyGameWindow ( GameWindow
)
Imports OpenTK
Imports OpenTK.Graphics
Imports OpenTK.Graphics.OpenGL
Public Class MyGameWindow
Inherits GameWindow
Private GlLoaded As Boolean = False
Public Sub New()
MyBase.New(820, 520)
Title = "Game Test"
Icon = My.Resources.gameicon
End Sub
Private Sub MyGameWindow_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
GlLoaded = True
End Sub
Private Sub MyGameWindow_RenderFrame(ByVal sender As Object, ByVal e As OpenTK.FrameEventArgs) Handles Me.RenderFrame
If Not GlLoaded Then Return
'Nothing here yet...
End Sub
Private Sub MyGameWindow_UpdateFrame(ByVal sender As Object, ByVal e As OpenTK.FrameEventArgs) Handles Me.UpdateFrame
If Not GlLoaded Then Return
'Nothing here yet...
End Sub
Private Sub MyGameWindow_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
'Nothing here yet...
End Sub
End Class
环境
- Windows 7 家庭高级版 64 位(服务包 1)
- 目标框架设置为
.NET Framework 2.0
. 将其更改为 4.0 并不能解决问题。