F
Frankie D.
I am unable to create d3dm device using PLatform Invoke.
Native code is based on TUT01_CREATEDEVICE sample of PLatform Builder.
Return value of CreateDevice function signs failure. Why?
Please help!
Thanks in advance,
Frankie
Native code:
extern "C" DIRECTXNATIVE_API HRESULT InitD3DM( HWND hWnd );
....
DIRECTXNATIVE_API HRESULT InitD3DM( HWND hWnd )
{
g_pD3DM = Direct3DMobileCreate( D3DM_SDK_VERSION )
D3DMPRESENT_PARAMETERS d3dmpp;
memset( &d3dmpp, 0, sizeof(d3dmpp) );
d3dmpp.Windowed = TRUE;
d3dmpp.SwapEffect = D3DMSWAPEFFECT_DISCARD;
d3dmpp.BackBufferFormat = D3DMFMT_UNKNOWN;
// Create the Direct3D Mobile device.
UINT uAdapter;
// Use the default system D3DM driver
uAdapter = D3DMADAPTER_DEFAULT;
if( FAILED( g_pD3DM->CreateDevice( uAdapter,
D3DMDEVTYPE_DEFAULT,
hWnd, 0,
&d3dmpp, &g_pd3dmDevice ) ) )
{
OutputDebugString(TEXT("Unable to create a D3DM device.\n"));
return E_FAIL;
}
// Device state would normally be set here
return S_OK;
}
Managed Code:
#include <d3dm.h>
LPDIRECT3DMOBILE g_pD3DM = NULL; // Used to create the
D3DMDevice
LPDIRECT3DMOBILEDEVICE g_pd3dmDevice = NULL; // Our rendering device
HMODULE g_hRefDLL = NULL; // DLL handle for d3dmref.dll
bool g_bUseRef = false; // Flag denoting use of d3dmref
public partial class Form1 : Form
{
[DllImport("DirectXNative.dll", EntryPoint = "InitD3DM", SetLastError =
true)]
static extern UInt32 InitD3DM( IntPtr hWnd );
public Form1()
{
InitializeComponent();
InitD3DM(this.Handle);
}
}
Native code is based on TUT01_CREATEDEVICE sample of PLatform Builder.
Return value of CreateDevice function signs failure. Why?
Please help!
Thanks in advance,
Frankie
Native code:
extern "C" DIRECTXNATIVE_API HRESULT InitD3DM( HWND hWnd );
....
DIRECTXNATIVE_API HRESULT InitD3DM( HWND hWnd )
{
g_pD3DM = Direct3DMobileCreate( D3DM_SDK_VERSION )
D3DMPRESENT_PARAMETERS d3dmpp;
memset( &d3dmpp, 0, sizeof(d3dmpp) );
d3dmpp.Windowed = TRUE;
d3dmpp.SwapEffect = D3DMSWAPEFFECT_DISCARD;
d3dmpp.BackBufferFormat = D3DMFMT_UNKNOWN;
// Create the Direct3D Mobile device.
UINT uAdapter;
// Use the default system D3DM driver
uAdapter = D3DMADAPTER_DEFAULT;
if( FAILED( g_pD3DM->CreateDevice( uAdapter,
D3DMDEVTYPE_DEFAULT,
hWnd, 0,
&d3dmpp, &g_pd3dmDevice ) ) )
{
OutputDebugString(TEXT("Unable to create a D3DM device.\n"));
return E_FAIL;
}
// Device state would normally be set here
return S_OK;
}
Managed Code:
#include <d3dm.h>
LPDIRECT3DMOBILE g_pD3DM = NULL; // Used to create the
D3DMDevice
LPDIRECT3DMOBILEDEVICE g_pd3dmDevice = NULL; // Our rendering device
HMODULE g_hRefDLL = NULL; // DLL handle for d3dmref.dll
bool g_bUseRef = false; // Flag denoting use of d3dmref
public partial class Form1 : Form
{
[DllImport("DirectXNative.dll", EntryPoint = "InitD3DM", SetLastError =
true)]
static extern UInt32 InitD3DM( IntPtr hWnd );
public Form1()
{
InitializeComponent();
InitD3DM(this.Handle);
}
}