VisualBasic OpenTK (объект буфера вершин)
Моя проблема в том, что если я хочу нарисовать треугольник, сделанный в Visual Basic с библиотекой OpenTK, и использовать VertexBufferObjects
это ничего не показывает мне на экране.
Это мой код:
Imports OpenTK
Imports OpenTK.Graphics
Imports OpenTK.Graphics.OpenGL
Public Class WinFrom1
''VBO
Public vertBuffer(3) As Vector3
Public VBO As Integer
Private Sub WinFrom1_Load(sender As Object, e As EventArgs) Handles Me.Load
GL.ClearColor(Color.White)
GL.Color3(Color.Black)
vertBuffer = New Vector3() {
New Vector3(0, 0, 0),
New Vector3(0, 10, 0),
New Vector3(10, 0, 10)
}
VBO = GL.GenBuffer
GL.BindBuffer(BufferTarget.ArrayBuffer, VBO)
GL.BufferData(BufferTarget.ArrayBuffer, Vector3.SizeInBytes * vertBuffer.Length,
vertBuffer, BufferUsageHint.StaticDraw)
GL.BindBuffer(BufferTarget.ArrayBuffer, 0)
End Sub
Private Sub WinFrom1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
Dim Fov As Matrix4 = Matrix4.CreatePerspectiveFieldOfView(1, 16 / 9, 1, 10000)
Dim LookAt As Matrix4 = Matrix4.LookAt(100, 50, 0, 0, 1, 0, 0, 1, 0) 'Setup camera
'First Clear Buffer
GL.Clear(ClearBufferMask.ColorBufferBit)
GL.Clear(ClearBufferMask.DepthBufferBit)
'Basic Seetup for viewing
GL.MatrixMode(MatrixMode.Projection) 'Load Perspective
GL.LoadIdentity()
GL.LoadMatrix(Fov)
GL.MatrixMode(MatrixMode.Modelview) 'Load Camera
GL.LoadIdentity()
GL.LoadMatrix(LookAt)
GL.Viewport(0, 0, OpenGL.Width, OpenGL.Height) 'Size of Window
GL.Enable(EnableCap.DepthTest) 'Enable correct Z Drawings
GL.DepthFunc(DepthFunction.Less) 'Enable correct Z Drawings
GL.Enable(EnableCap.Texture2D) 'Enable Textures
GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest)
' NOVBO(LookAt)
GL.EnableClientState(ArrayCap.VertexArray)
GL.BindBuffer(BufferTarget.ArrayBuffer, VBO)
GL.VertexPointer(2, VertexPointerType.Float, Vector3.SizeInBytes, 0)
OpenGL.VSync = True
OpenGL.SwapBuffers() 'Load to Gl Control
End Sub
End Class