2008/06/01

気が変わったので

GLSharpに、
アンチエイリアス等のOpenGLのエクステンションを使用した
レンダリングコンテキストの作成機能を実装してみた。
サイトへのアップはもう少しかかります。


// * class Form1 : Form の中。

RenderingContext context;
protected override void OnHandleCreated( EventArgs e )
{
base.OnHandleCreated( e );

PixelFormatDescriptor pfd = new PixelFormatDescriptor();
PixelFormatAttributes pfa = new PixelFormatAttributes();
pfa.SampleBuffers = true; //←ここと
pfa.Samples = 4; //←ここで、マルチサンプリング(=アンチエイリアス)を設定。
IntPtr hdc = win32.GetDC( this.Handle );

context = new RenderingContext( hdc, pfd, pfa, null );
context.MakeCurrent();
gl.LoadAll();
glu.LoadAll();

if( context.Format.Attributes != null && context.Format.Attributes.Samples != 0 )
gl.Enable( EnableCap.Multisample );
}


と、こんな感じで使えるようになった。
PixelFormatAttributes、ContextFormatというクラスを新たに作って、
RenderingContextクラスのコンストラクタを作り直した。
・・・とかまだ公開してないコードの説明書いても、
しょうがないのだけど、
まぁ、予告ということで。

0 件のコメント: