FiFiWiki2

FiFiWikiの第2版

ユーザ用ツール

サイト用ツール


c.sharp:opentk

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
c.sharp:opentk [2018/04/26 10:18]
fifi
c.sharp:opentk [2018/05/03 13:32] (現在)
fifi
ライン 1: ライン 1:
 +# リファレンス
 +
 +- [OpenGL入門](http://​wisdom.sakura.ne.jp/​system/​opengl/​)
 +- [Xamarin OpenGLES](https://​developer.xamarin.com/​api/​namespace/​OpenTK/​)
 +- [giawa/​opengl4tutorials:​ Tutorial Particle](https://​github.com/​giawa/​opengl4tutorials)
 +- [neokabuto/​OpenTKTutorialContent:​ Project files from OpenTK tutorials from my blog](https://​github.com/​neokabuto/​OpenTKTutorialContent)
 +- [jeske/​SimpleScene:​ Simple 3D scene manager in C# and OpenTK / OpenGL](https://​github.com/​jeske/​SimpleScene)
 +
 +# 座標変換を完全に理解する
 +
 +- ワールド座標変換
 +- ビュー/​プロジェクション座標変換
 +-- 2Dに変換する工程
 +-- クリッピング座標系(正規化視野空間とか正規化デバイス座標系)
 +-- 透視投影変換
 +-- 平行投影変換
 +
 +- 射影変換
 +
 +```c
 +// 実際に表示されているアプリケーションの画面のどの領域に表示するかを指定
 +GL.Viewport(0,​ Width, 0, Height);
 +
 +// 基本形
 +//​画面描画で実行される。
 +protected override void OnRenderFrame(FrameEventArgs e)
 +{
 +    base.OnRenderFrame(e);​
 + 
 +    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);​
 +    ​
 +    // [クリッピング座標系] クリッピング空間の指定. カメラの表示画角を指定するだけ (順不動) ​
 +    GL.MatrixMode(MatrixMode.Projection);​
 +    Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, (float)glControl.Size.Width / (float)glControl.Size.Height,​ 1.0f, 64.0f);
 +    GL.LoadMatrix(ref projection);​
 +    ​
 +    // [ビュー座標系] カメラの位置,​方向,​を指定するだけ (順不動)
 +    GL.MatrixMode(MatrixMode.Modelview);​
 +    Matrix4 modelview = Matrix4.LookAt(Vector3.Zero,​ Vector3.UnitZ,​ Vector3.UnitY);​
 +    GL.LoadMatrix(ref modelview);
 +    ​
 +    // ワールド座標系でオブジェクトを配置
 +    GL.Begin(BeginMode.Quads);​
 + 
 +    GL.Color4(Color4.White); ​                           //​色名で指定
 +    GL.Vertex3(-1.0f,​ 1.0f, 4.0f);
 +    GL.Color4(new float[] { 1.0f, 0.0f, 0.0f, 1.0f });  //​配列で指定
 +    GL.Vertex3(-1.0f,​ -1.0f, 4.0f);
 +    GL.Color4(0.0f,​ 1.0f, 0.0f, 1.0f); ​                 //​4つの引数にfloat型で指定
 +    GL.Vertex3(1.0f,​ -1.0f, 4.0f);
 +    GL.Color4((byte)0,​ (byte)0, (byte)255, (byte)255); ​ //​byte型で指定
 +    GL.Vertex3(1.0f,​ 1.0f, 4.0f);
 + 
 +    GL.End();
 + 
 +    SwapBuffers();​
 +}
 +
 +```
  
 # 3Dの座標グリッドを美しく表示する方法 # 3Dの座標グリッドを美しく表示する方法
  
-[Drawing a Grid in OpenTK](http://​deathbyalgorithm.blogspot.jp/​2013/​05/​drawing-grid-in-opentk.html) +[Drawing a Grid in OpenTK](http://​deathbyalgorithm.blogspot.jp/​2013/​05/​drawing-grid-in-opentk.html) 
-[Setting up OpenTK](http://​deathbyalgorithm.blogspot.jp/​2013/​05/​setting-up-opentk.html)+[Setting up OpenTK](http://​deathbyalgorithm.blogspot.jp/​2013/​05/​setting-up-opentk.html) 
 + 
 +```c 
 +/* 線のアンチエイリアス */ 
 +GL.Enable(EnableCap.LineSmooth);​ // 線のアンチエイリアスを有効化 
 +GL.Hint(HintTarget.LineQualityHintSgix,​ HintMode.Fastest);​ // アンチエイリアスの 
 +GL.Enable(EnableCap.Blend);​ // 線周辺のブレンドを 
 +GL.BlendFunc(BlendingFactorSrc.SrcAlpha,​ BlendingFactorDest.OneMinusSrcAlpha);​ 
 +``` 
  
 # OpenTKの文字列表示について # OpenTKの文字列表示について
  
 OpenTK.Graphics.TextPrinterを使う場合には、メモリリークに注意 OpenTK.Graphics.TextPrinterを使う場合には、メモリリークに注意
 +
 +TextPrinterOptions.Defaultの場合はcacheがたまってしまう。.TextPrinterOptions.NoCacheにすべき。
  
 [opentkのライブラリ](https://​github.com/​mono/​opentk/​blob/​master/​Source/​Compatibility/​Graphics/​TextPrinter.cs) [opentkのライブラリ](https://​github.com/​mono/​opentk/​blob/​master/​Source/​Compatibility/​Graphics/​TextPrinter.cs)
ライン 56: ライン 126:
  
             GL.Viewport(0,​ 0, Width, Height);             GL.Viewport(0,​ 0, Width, Height);
-            GL.Ortho(0, Width, Height, 0, -1, 1);+            GL.Ortho(0, Width, Height, 0, -1, 1); // 射影変換 その他Perspectiveもある
  
             // ******** Text Rendering             // ******** Text Rendering
c.sharp/opentk.1524737897.txt.gz · 最終更新: 2018/04/26 10:18 by fifi