XNAβ2 / リセットされたデバイスにおける挙動

GraphicsDevice.SetRenderTarget(int, RenderTarget2D);

  • NullReferenceException
  • InvalidOperationException "The Method is invalid."

EffectParameter.SetValue(Texture); // Texture = RenderTarget2D.GetTexture();

  • AccessViolationException

状況

 マネージコード・デバッグでは上記のあいまいな例外が出ているとします。

解法(今回の場合)

 DeviceResetイベントでRenderTarget2D・Textureを再作成しましょう。

コメント

 XNAβ2で改変を進めるコードネームGalaxyで発生していた例外を試行錯誤で原因特定した結果、こういう理由でした。GameクラスやGraphicsDeviceManagerにもっと難しい問題があるのかと、あれこれ試していました。