get glwpfcontrol to work
This commit is contained in:
@@ -128,28 +128,23 @@ Namespace PreviewN
|
|||||||
Me.SuspendLayout()
|
Me.SuspendLayout()
|
||||||
|
|
||||||
InitializeComponent()
|
InitializeComponent()
|
||||||
DoubleBuffered = True
|
|
||||||
|
|
||||||
'glControl1
|
'glControl1
|
||||||
Me.glControl1 = New Wpf.GLWpfControl
|
Dim glControl1 As New GLWpfControl
|
||||||
Me.glControlHost = New ElementHost
|
glControl1.IsEnabled = False
|
||||||
Me.glControlHost.BackColor = Color.Black
|
Dim glControlHost = New ElementHost
|
||||||
Me.glControlHost.Name = "glControl1"
|
glControlHost.BackColor = Color.Black
|
||||||
Me.glControlHost.Anchor = AnchorStyles.Left Or AnchorStyles.Top Or AnchorStyles.Right Or AnchorStyles.Bottom
|
glControlHost.Name = "glControl1"
|
||||||
Me.glControlHost.Location = New Point(0, 0)
|
glControlHost.Anchor = AnchorStyles.Left Or AnchorStyles.Top Or AnchorStyles.Right Or AnchorStyles.Bottom
|
||||||
Me.glControlHost.Size = Me.ClientSize
|
glControlHost.Location = New Point(0, 0)
|
||||||
Me.glControlHost.MinimumSize = New Size(600, 120)
|
glControlHost.Size = Me.ClientSize
|
||||||
Me.glControlHost.TabIndex = 0
|
glControlHost.MinimumSize = New Size(600, 120)
|
||||||
Me.glControlHost.TabStop = False
|
glControlHost.TabIndex = 0
|
||||||
Me.glControlHost.Child = glControl1
|
glControlHost.TabStop = False
|
||||||
Me.Controls.Add(Me.glControlHost)
|
ResumeLayout(False)
|
||||||
Me.ResumeLayout(False)
|
|
||||||
|
|
||||||
'RenderTimer.SynchronizingObject = Nothing
|
|
||||||
Scaling = scale
|
|
||||||
|
|
||||||
'Toolkit.Init()
|
|
||||||
|
|
||||||
|
Me.glControl1 = glControl1
|
||||||
|
Me.glControlHost = glControlHost
|
||||||
|
|
||||||
Dim controlSettings As New GLWpfControlSettings With
|
Dim controlSettings As New GLWpfControlSettings With
|
||||||
{
|
{
|
||||||
@@ -157,9 +152,13 @@ Namespace PreviewN
|
|||||||
.GraphicsProfile = Windowing.Common.ContextProfile.Compatability
|
.GraphicsProfile = Windowing.Common.ContextProfile.Compatability
|
||||||
}
|
}
|
||||||
glControl1.Start(controlSettings)
|
glControl1.Start(controlSettings)
|
||||||
AddHandler glControl1.MouseWheel, AddressOf glControl1_Wheel
|
|
||||||
ProjMatrix = Matrix4.CreatePerspectiveFieldOfView(FOV, glControl1.Width / glControl1.Height, 100.0F, 100000.0F)
|
glControlHost.Child = glControl1
|
||||||
glControlHost.Enabled = True
|
Controls.Add(glControlHost)
|
||||||
|
|
||||||
|
Scaling = scale
|
||||||
|
|
||||||
|
ProjMatrix = Matrix4.CreatePerspectiveFieldOfView(FOV, glControlHost.Width / glControlHost.Height, 100.0F, 100000.0F)
|
||||||
|
|
||||||
MyCamera.SetCameraMode(CameraMode.FLY, camMtx)
|
MyCamera.SetCameraMode(CameraMode.FLY, camMtx)
|
||||||
MyCamera.UpdateMatrix(camMtx)
|
MyCamera.UpdateMatrix(camMtx)
|
||||||
@@ -179,10 +178,15 @@ Namespace PreviewN
|
|||||||
|
|
||||||
Public Sub UpdateView()
|
Public Sub UpdateView()
|
||||||
If glControl1.IsEnabled Then
|
If glControl1.IsEnabled Then
|
||||||
glControlHost.Invoke(Sub() glControlHost.Invalidate())
|
Invoke(Sub() InvalidateGL())
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Public Sub InvalidateGL()
|
||||||
|
glControl1.InvalidateVisual()
|
||||||
|
glControlHost.Invalidate()
|
||||||
|
End Sub
|
||||||
|
|
||||||
Public Function AddModel(obj As Object3D) As Renderer
|
Public Function AddModel(obj As Object3D) As Renderer
|
||||||
Dim rndr As New Renderer(obj)
|
Dim rndr As New Renderer(obj)
|
||||||
AddModel(rndr)
|
AddModel(rndr)
|
||||||
@@ -194,9 +198,9 @@ Namespace PreviewN
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Sub HandlesOnShown(sender As Object, e As EventArgs) Handles MyBase.Shown
|
Public Sub HandlesOnShown(sender As Object, e As EventArgs) Handles MyBase.Shown
|
||||||
glControlHost.Enabled = True
|
glControl1.IsEnabled = True
|
||||||
RenderModels()
|
RenderModels()
|
||||||
glControlHost.Invalidate()
|
InvalidateGL()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Sub RenderModels()
|
Public Sub RenderModels()
|
||||||
@@ -212,7 +216,7 @@ Namespace PreviewN
|
|||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub glControl1_Load(sender As Object, e As EventArgs) Handles glControl1.Loaded
|
Private Sub glControl1_Load() Handles glControl1.Ready
|
||||||
GL.Enable(EnableCap.Blend)
|
GL.Enable(EnableCap.Blend)
|
||||||
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha)
|
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha)
|
||||||
|
|
||||||
@@ -265,14 +269,14 @@ Namespace PreviewN
|
|||||||
'glControl1.Context.Update(glControl1.WindowInfo)
|
'glControl1.Context.Update(glControl1.WindowInfo)
|
||||||
GL.Viewport(0, 0, glControlHost.Width, glControlHost.Height)
|
GL.Viewport(0, 0, glControlHost.Width, glControlHost.Height)
|
||||||
ProjMatrix = Matrix4.CreatePerspectiveFieldOfView(FOV, glControlHost.Width / glControlHost.Height, 100.0F, 100000.0F)
|
ProjMatrix = Matrix4.CreatePerspectiveFieldOfView(FOV, glControlHost.Width / glControlHost.Height, 100.0F, 100000.0F)
|
||||||
glControlHost.Invalidate()
|
InvalidateGL()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub glControl1_Wheel(sender As Object, e As Windows.Input.MouseWheelEventArgs)
|
Private Sub glControl1_Wheel(sender As Object, e As Windows.Input.MouseWheelEventArgs) Handles glControl1.MouseWheel
|
||||||
MyCamera.ResetMouseStuff()
|
MyCamera.ResetMouseStuff()
|
||||||
MyCamera.UpdateCameraMatrixWithScrollWheel(CInt(Math.Truncate(e.Delta * (If(IsShiftPressed, 3.5F, 1.5F)))), camMtx)
|
MyCamera.UpdateCameraMatrixWithScrollWheel(CInt(Math.Truncate(e.Delta * (If(IsShiftPressed, 3.5F, 1.5F)))), camMtx)
|
||||||
savedCamPos = MyCamera.Position
|
savedCamPos = MyCamera.Position
|
||||||
glControlHost.Invalidate()
|
InvalidateGL()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub glControl1_MouseDown(ByVal sender As Object, ByVal e As Windows.Input.MouseButtonEventArgs) Handles glControl1.MouseDown
|
Private Sub glControl1_MouseDown(ByVal sender As Object, ByVal e As Windows.Input.MouseButtonEventArgs) Handles glControl1.MouseDown
|
||||||
@@ -292,7 +296,7 @@ Namespace PreviewN
|
|||||||
Else
|
Else
|
||||||
MyCamera.UpdateCameraMatrixWithMouse(e.X, e.Y, camMtx)
|
MyCamera.UpdateCameraMatrixWithMouse(e.X, e.Y, camMtx)
|
||||||
End If
|
End If
|
||||||
glControlHost.Invalidate()
|
InvalidateGL()
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user