FiFiWiki2

FiFiWikiの第2版

ユーザ用ツール

サイト用ツール


c.sharp:opentk

差分

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

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

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
最新リビジョン 両方とも次のリビジョン
c.sharp:opentk [2018/04/22 13:19]
fifi
c.sharp:opentk [2018/05/03 13:19]
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に変換する工程
 +-- クリッピング座標系(正規化視野空間とか正規化デバイス座標系)
 +-- 透視投影変換
 +-- 平行投影変換
 +
 +- 射影変換
 +
 +# 3Dの座標グリッドを美しく表示する方法
 +
 +- [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)
 +
 +```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を使う場合には、メモリリークに注意
 +
 +TextPrinterOptions.Defaultの場合はcacheがたまってしまう。.TextPrinterOptions.NoCacheにすべき。
 +
 +[opentkのライブラリ](https://​github.com/​mono/​opentk/​blob/​master/​Source/​Compatibility/​Graphics/​TextPrinter.cs)
 +には入っているが、
 +
 +[2016年の情報](https://​www.codeproject.com/​Articles/​1057539/​Abstract-of-the-text-rendering-with-OpenGL-OpenTK)では
 +外部ライブラリを使うとある。情報は古いかもしれないが(2018/​4/​22時点では以下のコードで動いた)
 +
 +
 +```c
 +
 +using OpenTK.Graphics.OpenGL;​
 +using System.Drawing;​
 +
 +namespace ConsoleApp1
 +{
 +    class FrontTextView
 +    {
 +
 +        OpenTK.Graphics.TextPrinter text = new OpenTK.Graphics.TextPrinter(OpenTK.Graphics.TextQuality.High);​
 +
 +        float size1 = 25;
 +        float size2 = 15;
 +        Font printerFont1;​
 +        Font printerFont2;​
 +
 +        string poem = "​Oxford Dictionaries definitions. Looking for the meanings of words, phrases, and expressions?​ We provide hundreds of thousands of definitions,​ synonyms, antonyms, and pronunciations for English and other languages, derived from our language research and expert analysis. We also offer a unique set of examples of real usage, as well as guides to: Writing help: This section gives guidelines on writing in everyday situations, from applying for a job to composing letters of ...";
 +
 +        public FrontTextView()
 +        {
 +        }
 +
 +        public void Render(int Width, int Height)
 +        {
 +            // ******** font settings
 +            size1 = Height / 30f;
 +            size2 = Height / 60f;
 +            printerFont1 = new Font(FontFamily.GenericMonospace,​ size1);
 +            printerFont2 = new Font(FontFamily.GenericSerif,​ size2, FontStyle.Regular);​ // FontFamily.GenericSansSerif
 +
 +            //​******** ​
 +            GL.MatrixMode(MatrixMode.Projection);​
 +            GL.PushMatrix();​ // 上書きするなら必要
 +            GL.LoadIdentity();​
 +            GL.MatrixMode(MatrixMode.Modelview);​
 +            GL.PushMatrix();​ // 上書きするために必要
 +            GL.LoadIdentity();​
 +
 +            GL.Viewport(0,​ 0, Width, Height);
 +            GL.Ortho(0, Width, Height, 0, -1, 1); // 射影変換 その他Perspectiveもある
 +
 +            // ******** Text Rendering
 +             ​text.Begin();​
 +            text.Print(this.BaseText,​ printerFont1,​ Color.DimGray,​ drawRect, OpenTK.Graphics.TextPrinterOptions.NoCache);​
 +            text.End();
 +            // ******** This is equivalent:
 +            GL.MatrixMode(MatrixMode.Modelview);​
 +            GL.PopMatrix();​
 +            GL.MatrixMode(MatrixMode.Projection);​
 +            GL.PopMatrix();​
 +
 +        }
 +    }
 +}
 +```
  
  
c.sharp/opentk.txt · 最終更新: 2018/05/03 13:32 by fifi