VisualBasic OpenTK(顶点缓冲区对象)

时间:2018-10-16 18:48:11

标签: vb.net vbo opentk vertex-buffer-objects

我的问题是,如果我想用OpenTK库绘制在Visual Basic中制作的三角形并使用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 ,那么在屏幕上什么也看不到。

Screenshot

这是我的代码:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="slideshow_style.css">
</head>
<body>


<!-- Slideshow container -->
<div class="slideshow-container" onmouseover="stop_timeout()" onmouseout="start_timeout()">

  <!-- Full-width images with number and caption text -->
  <div class="mySlides fade">
    <div class="numbertext">1 / 4</div>
    <img src="img_lights_wide.jpg" style="width:100%">
    <div class="text">Caption Text</div>
  </div>

  <div class="mySlides fade">
    <div class="numbertext">2 / 4</div>
    <img src="img_mountains_wide.jpg" style="width:100%">
    <div class="text">Caption Two</div>
  </div>

  <div class="mySlides fade">
    <div class="numbertext">3 / 4</div>
    <img src="img_snow_wide.jpg" style="width:100%">
    <div class="text">Caption Three</div>
  </div>

    <div class="mySlides fade">
    <div class="numbertext">4 / 4</div>
    <img src="img_nature_wide.jpg" style="width:100%">
    <div class="text">Caption Four</div>
  </div>

  <!-- Next and previous buttons -->
  <a class="prev" onclick="plusSlides(-1)">&#10094;</a>
  <a class="next" onclick="plusSlides(1)">&#10095;</a>
</div>
<br>

<!-- The dots/circles -->
<div style="text-align:center">
  <span class="dot" onclick="currentSlide(0)"></span> 
  <span class="dot" onclick="currentSlide(1)"></span> 
  <span class="dot" onclick="currentSlide(2)"></span>
  <span class="dot" onclick="currentSlide(3)"></span>  
</div>


<script src="slideshow_script.js"></script>
</body>
</html> 

0 个答案:

没有答案