1

DLL でマネージド DirectX 9 デバイスを作成し、その DLL を使用してシーンをオフスクリーン サーフェスにレンダリングしようとしています。オフスクリーン レンダリングの方法は知っていますが、私の質問は次のとおりです。

DLL 内で directx デバイスを作成することは可能ですか?

弱い試み #1 ( InvalidCallException):

Device device = new Device(0, DeviceType.Hardware, null, CreateFlags.SoftwareVertexProcessing, presentParams);

弱い試み #2 ( InvalidCallException):

Device device = new Device(0, DeviceType.Hardware, new IntPtr(0), CreateFlags.SoftwareVertexProcessing, presentParams);

使用可能なデバイス コンストラクターのオーバーロードは次のとおりです。

public Device(int, DeviceType, Control, CreateFlags, PresentParameters[]);
public Device(int, DeviceType, IntPtr, CreateFlags, PresentParameters[]);

助けがあれば、私の一日がうまくいく可能性があります!

4

1 に答える 1

0

答えを見つけました。隠しコントロールを作成し、幅と高さを適切に設定してから、ターゲットとして設定しました。完璧に動作します。後でこれに出くわすかもしれない人のために、コードは次のとおりです。

// Create the hidden control
Control hiddenControl = new Control();
control.Width = width;
control.Height = height;
control.Visible = false;         // Just for good measure, it wouldn't be displayed anyways

// Present Parameters
PresentParamaters presentParams = new PresentParamaters();
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.Windowed = true;

// Create the device
Device device = new Device(0, DeviceType.Hardware, hiddenControl, CreateFlags.SoftwareVertexProcessing, presentParams);

テクスチャにレンダリングする前に言ったように必要なのはそれだけです。実際にこのコントロールにレンダリングするとどうなるかはわかりません。

于 2010-11-18T06:17:57.700 に答える