私はVB.NET環境内でopenGLを実行する方法を学ぼうとしていましたが、TaoフレームワークまたはOpenTKが推奨されており、OpenTKの方が推奨されているようです。
私はこれにまったく慣れていないので、単純なボックスや三角形などを実際に描いて、より複雑なものを作成する前にすべてを理解できるようにしようとしています。これまでのところうまくいかなかったので、これまでに行ったことを順番にリストします。簡単な形を描くために、ここの誰かが修正したり、新しい例を提供したりできることを願っています。
1)opentk-2010-10-06.exeを使用してOpenTKをインストールしました
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)Handles GlControl1.Resize _STARTED = True ResizeGL()End Sub
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
上記の結果は表示されませんので、ご協力いただければ幸いです。
完全な解決策がわからなくても、どんな応答でもいいでしょう。