d
This commit is contained in:
@@ -29,6 +29,7 @@ Namespace PreviewN
|
||||
Private ReadOnly myModels As New Dictionary(Of Object3D, Renderer)
|
||||
Private WithEvents RenderTimer As New Timers.Timer(25) With {.AutoReset = True}
|
||||
Private _EnableCameraControlling As Boolean = False
|
||||
Private finishedLoading As Boolean = False
|
||||
|
||||
Public Property Scaling As Single = 500.0F
|
||||
Public Property ClearColor As Color = Color.CornflowerBlue
|
||||
@@ -125,13 +126,12 @@ Namespace PreviewN
|
||||
End Sub
|
||||
|
||||
Public Sub New(objs As Object3D(), scale As Single)
|
||||
Me.SuspendLayout()
|
||||
SuspendLayout()
|
||||
|
||||
InitializeComponent()
|
||||
|
||||
'glControl1
|
||||
Dim glControl1 As New GLWpfControl
|
||||
glControl1.IsEnabled = False
|
||||
Dim glControlHost = New ElementHost
|
||||
glControlHost.BackColor = Color.Black
|
||||
glControlHost.Name = "glControl1"
|
||||
@@ -141,7 +141,6 @@ Namespace PreviewN
|
||||
glControlHost.MinimumSize = New Size(600, 120)
|
||||
glControlHost.TabIndex = 0
|
||||
glControlHost.TabStop = False
|
||||
ResumeLayout(False)
|
||||
|
||||
Me.glControl1 = glControl1
|
||||
Me.glControlHost = glControlHost
|
||||
@@ -160,14 +159,16 @@ Namespace PreviewN
|
||||
|
||||
ProjMatrix = Matrix4.CreatePerspectiveFieldOfView(FOV, glControlHost.Width / glControlHost.Height, 100.0F, 100000.0F)
|
||||
|
||||
ResumeLayout()
|
||||
|
||||
MyCamera.SetCameraMode(CameraMode.FLY, camMtx)
|
||||
MyCamera.UpdateMatrix(camMtx)
|
||||
|
||||
Me.ResumeLayout()
|
||||
|
||||
For Each obj As Object3D In objs
|
||||
AddModel(obj)
|
||||
Next
|
||||
|
||||
finishedLoading = True
|
||||
End Sub
|
||||
|
||||
Public Sub UpdateOrbitCamera()
|
||||
@@ -177,12 +178,12 @@ Namespace PreviewN
|
||||
End Sub
|
||||
|
||||
Public Sub UpdateView()
|
||||
If glControl1.IsEnabled Then
|
||||
If glControlHost.Enabled AndAlso finishedLoading Then
|
||||
Invoke(Sub() InvalidateGL())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub InvalidateGL()
|
||||
Private Sub InvalidateGL()
|
||||
glControl1.InvalidateVisual()
|
||||
glControlHost.Invalidate()
|
||||
End Sub
|
||||
@@ -198,7 +199,6 @@ Namespace PreviewN
|
||||
End Sub
|
||||
|
||||
Public Sub HandlesOnShown(sender As Object, e As EventArgs) Handles MyBase.Shown
|
||||
glControl1.IsEnabled = True
|
||||
RenderModels()
|
||||
InvalidateGL()
|
||||
End Sub
|
||||
@@ -248,9 +248,8 @@ Namespace PreviewN
|
||||
|
||||
Public Sub HandlesOnPaint(renderTime As TimeSpan) Handles glControl1.Render
|
||||
GL.ClearColor(ClearColor)
|
||||
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit Or ClearBufferMask.DepthBufferBit)
|
||||
|
||||
GL.LoadIdentity()
|
||||
GL.MatrixMode(MatrixMode.Projection)
|
||||
GL.LoadMatrix(ProjMatrix)
|
||||
GL.MatrixMode(MatrixMode.Modelview)
|
||||
@@ -262,6 +261,9 @@ Namespace PreviewN
|
||||
End If
|
||||
Next
|
||||
|
||||
GL.End()
|
||||
GL.Finish()
|
||||
|
||||
'glControl1.SwapBuffers()
|
||||
End Sub
|
||||
|
||||
|
||||
Reference in New Issue
Block a user