本文整理汇总了C++中LPDIRECT3D8::CheckDeviceType方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3D8::CheckDeviceType方法的具体用法?C++ LPDIRECT3D8::CheckDeviceType怎么用?C++ LPDIRECT3D8::CheckDeviceType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3D8
的用法示例。
在下文中一共展示了LPDIRECT3D8::CheckDeviceType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBackBufferFormat
//Get a supported back buffer format
bool WINDOW::GetBackBufferFormat( D3DFORMAT requestedFormat, D3DFORMAT & resultFormat,
D3DFORMAT frontBufferFormat,
LPDIRECT3D8 d3d, bool windowed)
{
//See if the requested back buffer format is supported
HRESULT hr;
hr=d3d->CheckDeviceType( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frontBufferFormat,
requestedFormat, windowed);
if(SUCCEEDED(hr))
{
LOG::Instance()->OutputSuccess("Chosen back buffer format is available in %s mode",
windowed ? "windowed" : "fullscreen");
resultFormat=requestedFormat;
return true;
}
//If failed, try A8R8G8B8, X8R8G8B8, R5G6B5
D3DFORMAT testFormats[3]={D3DFMT_A8R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_R5G6B5};
char * testStrings[3]={"D3DFMT_A8R8G8B8", "D3DFMT_X8R8G8B8", "D3DFMT_R5G6B5"};
for(int i=0; i<3; ++i)
{
D3DFORMAT currentTestFormat=testFormats[i];
if(FAILED(hr))
{
hr=d3d->CheckDeviceType( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frontBufferFormat,
currentTestFormat, windowed);
if(SUCCEEDED(hr))
{
LOG::Instance()->OutputMisc("%s will be used instead of chosen back buffer format in %s mode",
testStrings[i],
windowed ? "windowed" : "fullscreen");
resultFormat=testFormats[i];
return true;
}
}
}
//If still failed, no color formats supported
LOG::Instance()->OutputError("No suitable back buffer formats supported in %s mode",
windowed ? "windowed" : "fullscreen");
return false;
}
示例2: FindBackBufferType
D3DFORMAT FindBackBufferType(bool bWindowed, int iBPP)
{
HRESULT hr;
// If windowed, then bpp is ignored. Use whatever works.
vector<D3DFORMAT> vBackBufferFormats; // throw all possibilities in here
/* When windowed, add all formats; otherwise add only formats that match dwBPP. */
if( iBPP == 16 || bWindowed )
{
vBackBufferFormats.push_back( D3DFMT_R5G6B5 );
vBackBufferFormats.push_back( D3DFMT_X1R5G5B5 );
vBackBufferFormats.push_back( D3DFMT_A1R5G5B5 );
}
if( iBPP == 32 || bWindowed )
{
#if !defined(XBOX)
vBackBufferFormats.push_back( D3DFMT_R8G8B8 );
#endif
vBackBufferFormats.push_back( D3DFMT_X8R8G8B8 );
vBackBufferFormats.push_back( D3DFMT_A8R8G8B8 );
}
if( !bWindowed && iBPP != 16 && iBPP != 32 )
{
GraphicsWindow::Shutdown();
RageException::Throw( "Invalid BPP '%i' specified", iBPP );
}
// Test each back buffer format until we find something that works.
for( unsigned i=0; i < vBackBufferFormats.size(); i++ )
{
D3DFORMAT fmtBackBuffer = vBackBufferFormats[i];
D3DFORMAT fmtDisplay;
if( bWindowed )
fmtDisplay = g_DesktopMode.Format;
else // Fullscreen
fmtDisplay = vBackBufferFormats[i];
LOG->Trace( "Testing format: display %d, back buffer %d, windowed %d...",
fmtDisplay, fmtBackBuffer, bWindowed );
hr = g_pd3d->CheckDeviceType( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
fmtDisplay, fmtBackBuffer, bWindowed );
if( FAILED(hr) )
continue; // skip
// done searching
LOG->Trace( "This will work." );
return fmtBackBuffer;
}
LOG->Trace( "Couldn't find an appropriate back buffer format." );
return D3DFMT_UNKNOWN;
}