【解決方法】例外による Directx 8 の失敗

プログラミングQA


プロジェクトで問題が発生しています。directX 8 を使用して 3D 画像を作成したいのですが、例外がスローされるため画像を作成できません。

<pre lang="text">argumentnullException the argument of D3D.createDevice 's last parameter was null.

私のコード:

私が試したこと:

<pre lang="VB">
Imports System
imports system.drawing
imports system.data
imports system.collections.generic
imports system.windows.forms
imports Microsoft.direct4XVB.directX8
public class cellular
inherits Forms
Dim Dx8 As DirectX8
Dim D3D As Direct3D8
Dim app As Object = createObject("app")
Dim Device As Direct3Ddevice8
Dim apprunning As Boolean
Public Function init() As boolean
 On Error goto  errHdl:
  Dim Dispmode As D3Ddisplaymode,_
  Dwindow As D3Dpresent_parameters 
  Dx8=new DirectX8()
  D3D = Dx8.Direct3Dcreate()
  'the rest of the code isn't important reply 1209 to view it
  'the code where the problem Revolves 
  D3Ddevice = D3D.createDevice(D3Dadapter_default,D3Dedevtype_hal,D3Dcreate_software_vertexprocessing,D3Dwindow)
  init()=true
  Exit Function
  errhdl:
    init()=false
 End Function
End Class

解決策 1

まずは使用をやめましょう On Error – より現代的なものを使用する Try ... Catch その代わり。

次に、関数の定義を見てみましょう。
IDirect3D9::CreateDevice (d3d9.h) – Win32 アプリ | Microsoft Learn[^]

または MS チュートリアル:
IDirect3D9::CreateDevice (d3d9.h) – Win32 アプリ | Microsoft Learn[^]

6 つのパラメータが必要ですが、指定するのは 4 つだけです。

コメント

タイトルとURLをコピーしました