我努力学习如何在VB .NET环境中做OpenGL和它似乎是陶框架或OpenTK建议使用具有更高建议,以便OpenTK就是我选择尝试使用。OpenTK(OpenGL的)在VB .NET
因为我是这个品牌的新手,我只是想绘制一个简单的盒子,三角形或任何其他东西,以便在做出更复杂的事情之前能够理解这一切。迄今为止,我一直没有成功,所以我会按顺序列出迄今为止所做的工作,希望这里的某个人能够帮助我改正或提供一个新的例子,以便我可以绘制一个简单的形状。
1)I使用OpenTK opentk-2010-10-06.exe
2)在一个新的项目我加入OpenTK.dll和OpenTK.Compatibility.dll
3的参考文献中已安装)我添加控件(opentk.glcontrol.dll)
4)我将实际的控件添加到我的表单。
使用一些在线的例子我加了休息:
5)我写在我的引用:
Imports OpenTK
Imports OpenTK.GLControl
Imports OpenTK.Platform
Imports OpenTK.Graphics.OpenGL
Imports System.Math
6)我的全局变量:
Dim _STARTED As Boolean = False
7)我写我的事件:
Private Sub GlControl1_Resize(ByVal sender As Object,ByVal e As System.EventArgs)H andles GlControl1.Resize _STARTED =真 ResizeGL() 完子
Private Sub ResizeGL()
GL.Viewport(0, 0, GlControl1.Width, GlControl1.Height)
GL.MatrixMode(MatrixMode.Projection) ' Select The Projection Matrix
GL.MatrixMode(MatrixMode.Modelview) ' Select The Modelview Matrix
GL.LoadIdentity() ' Reset The Modelview Matrix
End Sub
Public Sub ViewPerspective() ' Set Up A Perspective View
GL.MatrixMode(MatrixMode.Projection) ' Select Projection
GL.LoadIdentity() ';
Dim perspective1 As Matrix4 = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, _
CSng((GlControl1.Width)/(GlControl1.Height)), 0.1, 1000)
GL.LoadMatrix(perspective1)
GL.MatrixMode(MatrixMode.Modelview) ' Select The Modelview Matrix
GL.LoadIdentity() ' Reset The Matrix
GL.Enable(EnableCap.DepthTest) ' This doesnt need to be here but.. If your using the Z buffer.. It dont hurt.
End Sub
Public Sub ViewOrtho()
GL.MatrixMode(MatrixMode.Projection) 'Select Projection
GL.LoadIdentity() ' Reset The Matrix
GL.Ortho(0, GlControl1.Width, -GlControl1.Height, 0, 0.1, 100.0) ' Select Ortho Mode
GL.MatrixMode(MatrixMode.Modelview) ' Select Modelview Matrix
GL.LoadIdentity() ' Reset The Matrix
End Sub
8)最后,我试图打电话给他们:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ViewOrtho()
End Sub
中没有显示上述结果,所以任何帮助将不胜感激。
即使你不知道一个完整的解决方案,任何反应都会很好。