本文整理汇总了C++中LPDIRECT3D9::GetAdapterCount方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3D9::GetAdapterCount方法的具体用法?C++ LPDIRECT3D9::GetAdapterCount怎么用?C++ LPDIRECT3D9::GetAdapterCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3D9
的用法示例。
在下文中一共展示了LPDIRECT3D9::GetAdapterCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitializeWindowed
HRESULT KGraphicsEngine::InitializeWindowed(HWND hBaseWindow, HWND hRenderWindow)
{
// Create the D3D object.
if ( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
{
MessageBox(hBaseWindow,"Failed Create the D3D object!.","Failed Create the D3D object!",0);
return E_FAIL;
}
// Get the current desktop display mode, so we can set up a back
// buffer of the same format
g_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,&g_D3DCaps);
if ( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &m_DisplayMode ) ) )
{
MessageBox(hBaseWindow,"Failed GetAdapterDisplayMode !.","Failed Create the D3D object!",0);
return E_FAIL;
}
// Set up the structure used to create the D3DDevice
D3DFORMAT DepFormat;
if (SUCCEEDED(g_pD3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
m_DisplayMode.Format,
m_DisplayMode.Format,
D3DFMT_D24S8)))
{
DepFormat = D3DFMT_D24S8;
}
else
{
DepFormat = D3DFMT_D16;
}
memset( &m_PresentParam, 0, sizeof(D3DPRESENT_PARAMETERS) );
memset(&m_RenderWindowRect, 0, sizeof(m_RenderWindowRect));
if(hRenderWindow)
::GetWindowRect(hRenderWindow,&m_RenderWindowRect);
else
{
::GetWindowRect(hBaseWindow,&m_RenderWindowRect);
hRenderWindow = hBaseWindow;
}
//m_PresentParam.BackBufferWidth = m_RenderWindowRect.right-m_RenderWindowRect.left ;
//m_PresentParam.BackBufferHeight= m_RenderWindowRect.bottom - m_RenderWindowRect.top;
m_PresentParam.BackBufferWidth = m_DisplayMode.Width ;
m_PresentParam.BackBufferHeight= m_DisplayMode.Height;
m_PresentParam.Windowed = TRUE ;
m_PresentParam.SwapEffect = D3DSWAPEFFECT_DISCARD;
m_PresentParam.BackBufferFormat = m_DisplayMode.Format;
m_PresentParam.EnableAutoDepthStencil = TRUE;
m_PresentParam.AutoDepthStencilFormat = DepFormat;
m_PresentParam.MultiSampleType = D3DMULTISAMPLE_NONE;
m_PresentParam.hDeviceWindow = hBaseWindow;
m_PresentParam.Flags = 0;
m_PresentParam.FullScreen_RefreshRateInHz = 0;
m_PresentParam.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
//just set camera's aspect
m_cCamera.Aspect = m_PresentParam.BackBufferWidth*1.0f/m_PresentParam.BackBufferHeight;
HRESULT hr;
// Set default settings
UINT AdapterToUse=D3DADAPTER_DEFAULT;
D3DDEVTYPE DeviceType=D3DDEVTYPE_HAL;
//#if SHIPPING_VERSION
// When building a shipping version, disable NVPerfHUD (opt-out)
//#else
// Look for 'NVIDIA NVPerfHUD' adapter
// If it is present, override default settings
for (UINT Adapter=0;Adapter<g_pD3D->GetAdapterCount();Adapter++)
{
D3DADAPTER_IDENTIFIER9 Identifier;
HRESULT Res=g_pD3D->GetAdapterIdentifier(Adapter,0,&Identifier);
if (strcmp(Identifier.Description,"NVIDIA NVPerfHUD")==0)
{
AdapterToUse=Adapter;
DeviceType=D3DDEVTYPE_REF;
break;
}
}
//#endif
// Create the D3DDevice
/*if ( FAILED(hr = g_pD3D->CreateDevice( AdapterToUse, DeviceType, hBaseWindow,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&m_PresentParam, &g_pd3dDevice ) ) )
{*/
if ( FAILED(hr = g_pD3D->CreateDevice( AdapterToUse, DeviceType, hBaseWindow,
D3DCREATE_MIXED_VERTEXPROCESSING,
&m_PresentParam, &g_pd3dDevice ) ) )
{
if ( FAILED(hr = g_pD3D->CreateDevice( AdapterToUse, DeviceType, hBaseWindow,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&m_PresentParam, &g_pd3dDevice ) ) )
{
//.........这里部分代码省略.........
示例2: GetAdapterCount
UINT HookIDirect3D9:: GetAdapterCount(LPVOID _this)
{
LOG_API();
return pD3D->GetAdapterCount();
}
示例3: initD3D
void initD3D()
{
d3d = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS PresentParams;
memset(&PresentParams, 0, sizeof(D3DPRESENT_PARAMETERS));
PresentParams.Windowed = TRUE;
PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
///////////////////////////////////////////////////////////////////////
// Set default settings
UINT AdapterToUse = D3DADAPTER_DEFAULT;
D3DDEVTYPE DeviceType = D3DDEVTYPE_HAL;
#ifdef SHIPPING_VERSION
if(FAILED(d3d->CreateDevice(AdapterToUse, DeviceType, hMainWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&PresentParams, &device)))
{
MessageBoxA(hMainWnd, "Unable to initialize PerfectHUD", 0, MB_ICONHAND);
terminate();
}
#else
// Look for 'NVIDIA PerfHUD' adapter
// If it is present, override default settings
for (UINT Adapter = 0; Adapter < d3d->GetAdapterCount(); Adapter++)
{
D3DADAPTER_IDENTIFIER9 Identifier;
HRESULT Res;
Res = d3d->GetAdapterIdentifier(Adapter, 0, &Identifier);
if (strstr(Identifier.Description, "PerfHUD") != 0)
{
AdapterToUse = Adapter;
DeviceType = D3DDEVTYPE_REF;
break;
}
}
#endif
//////////////////////////////////////////////////////////////////////
device->SetRenderState(D3DRS_POINTSIZE_MAX, *((DWORD*)&pointSize));
device->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&pointSize));
device->SetRenderState(D3DRS_LIGHTING, FALSE);
device->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
D3DXCreateTextureFromFile(device, L"particle.png", &particleTexture);
D3DXCreateTextureFromFile(device, L"overlay.png", &overlayTexture);
D3DXCreateTexture(device, Width, Height, 0, D3DUSAGE_RENDERTARGET, D3DFMT_X8B8G8R8, D3DPOOL_DEFAULT, &renderTexture);
renderTexture->GetSurfaceLevel(0, &renderTarget);
device->GetRenderTarget(0, &orig);
//»нициализаци¤ матриц
D3DXMATRIX matrixView;
D3DXMATRIX matrixProjection;
D3DXMatrixLookAtLH(
&matrixView,
&D3DXVECTOR3(0, 0, 0),
&D3DXVECTOR3(0, 0, 1),
&D3DXVECTOR3(0, 1, 0));
D3DXMatrixOrthoOffCenterLH(&matrixProjection, 0, Width, Height, 0, 0, 255);
device->SetTransform(D3DTS_VIEW, &matrixView);
device->SetTransform(D3DTS_PROJECTION, &matrixProjection);
device->SetTexture(0, particleTexture);
}