2010/06/18(金)RenderStateManager.cs
void SetRenderState<T>(RenderState state, T value); T GetRenderState<T>(RenderState state);
SlimDXのDirect3D9のRenderState周りに関してGetとSetメソッドしかない。
なんで RenderStateManagerとかないの? ググったらGone.とか書いてあるページが出てきたけど。
正直不便。なので、Managed DirectXライクに、その辺をラップするRenderStateManagerを作ったりなど。
この辺欲しい人他にもいるんじゃないかなぁと思って公開してみるテスト。
ついでに、google-code-prettify を入れた。
なんか、大文字で始まると型名として認識されるのか色が変わっちゃう(笑
/* RenderStateManager.cs */
using System;
using System.Collections.Generic;
using System.Text;
using SlimDX.Direct3D9;
namespace Tsukikage.GameSDK.Direct3D
{
/// <summary>
/// 描画の諸設定。
/// Render states define set-up states for all kinds of vertex and pixel processing.
/// Some render states set up vertex processing, and some set up pixel processing.
/// Render states can be saved and restored using stateblocks.
/// Applications use the methods of the StateBlock class to encapsulate render states.
/// </summary>
public sealed class RenderStateManager
{
Device device;
internal RenderStateManager(Device device)
{
this.device = device;
}
/// <summary>
/// A floating point value that specifies the amount to adaptively tessellate, in the W direction.
/// The default value is 1.0f.
/// </summary>
public float AdaptiveTessellateW
{
get { return device.GetRenderState<float>(RenderState.AdaptiveTessW); }
set { device.SetRenderState(RenderState.AdaptiveTessW, value); }
}
/// <summary>
/// A floating point value that specifies the amount to adaptively tessellate, in the X direction.
/// The default value is 0.0f.
/// </summary>
public float AdaptiveTessellateX
{
get { return device.GetRenderState<float>(RenderState.AdaptiveTessX); }
set { device.SetRenderState(RenderState.AdaptiveTessX, value); }
}
/* (省略) */
}
}
RenderStateManager.cs (注:テストしてないよ)
元ソースはここ。
http://code.google.com/p/slimdx/source/browse/trunk/source/direct3d9/Enums.h#3803
XMLドキュメントコメントは、includeタグを使った方がいいのかもしれないけれど、
どうもプロジェクト内のコードを書くときにIntellisenseが拾ってくれないようなので、
それじゃあなぁ...
MDX側のRenderStateManagerにはそれっぽいプロパティがない↓
/// <summary> /// An integer value that specifies which user-defined clip planes are active. Use /// </summary> ClipPlaneEnable = D3DRS_CLIPPLANEENABLE,
と、SDX側にそれっぽいフラグがない↓
//
// 概要:
// Enables or disables w-buffering.
public bool UseWBuffer { get; set; }
が、謎のままである。
とか記事を書いて自分に発破を掛けるなど。なんやしらんが、6月は怒濤の忙しさである。
ただまぁ、最近ラッパーがどんどん薄くなってきているのと、ラッピングに掛かるコストと見て、
正直この辺をラップする意味ないんじゃないのと思うこともしばしばある……。