I am working on trying to build a simple DirectX 9.0c spinning triangle in Windows and am not able to implement the CreateDevice method correctly with a Declare. I am unsure if I should be attempting to implement this with declares or start with COM? I have been working through online examples in the Forum and on the Xojo Blog with COM and am having a tough time understanding the implementation of COM. Before I get too far, which is the correct path to work with DirectX 9.0c with Xojo on Windows: Declare, COM, or something else?
Below is the code which retrieves the pointer to a IDIRECT3D9 interface which is COM. I am trying to work through this in small steps :) Any help is appreciated. My guess is that I am going to need to expose the IDIRECT3D9 interface through COM.
I have a running VB6 project that works with DirectX9.0c on Windows 10, and am using it as a guideline to develop a simple triangle program.
Sub Action() Handles Action Dim D3D_SDK_VERSION as Int32 = 32 //32 = version 9.0c Dim d3d9 as Integer = Direct3DCreate9(D3D_SDK_VERSION) If d3d9 <> 0 Then System.DebugLog "Direct3DCreate9 interface correct" Else System.DebugLog "Direct3DCreate9 error. Check for version DirectX 9.0c" End If Dim pp as D3DPRESENT_PARAMETERS //Set Vertex format Dim vFlag as UInt32 //D3DFVF constants vFlag = D3DFVF_DIFFUSE + D3DFVF_XYZRHW pp.BackBufferCount = 1 pp.Windowed = True pp.BackBufferFormat = D3DFMT_A8R8G8B8 pp.SwapEffect = D3DSWAPEFFECT_DISCARD //CreateDevice Dim RetVal as Integer Dim mb as New MemoryBlock(8) RetVal = CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Window1.Handle, D3DCREATE_HARDWARE_VERTEXPROCESSING, pp, mb) If RetVal = S_OK Then System.DebugLog "CreateDevice was successful" Else System.DebugLog "CreateDevice failed" End If System.DebugLog "Continue with more code" End Sub
Here is the Xojo code project that I started.
Let me know what you would like and I am willing to share all information that I have.
I will be away from my development computer for the next 12 hours or so and will not have access to the forums. Thanks :)