本文整理汇总了C++中LPDIRECT3D8::EnumAdapterModes方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3D8::EnumAdapterModes方法的具体用法?C++ LPDIRECT3D8::EnumAdapterModes怎么用?C++ LPDIRECT3D8::EnumAdapterModes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3D8
的用法示例。
在下文中一共展示了LPDIRECT3D8::EnumAdapterModes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetModes
void XBVideoConfig::GetModes(LPDIRECT3D8 pD3D)
{
bHasPAL = false;
bHasNTSC = false;
DWORD numModes = pD3D->GetAdapterModeCount(D3DADAPTER_DEFAULT);
D3DDISPLAYMODE mode;
CLog::Log(LOGINFO, "Available videomodes:");
for ( DWORD i = 0; i < numModes; i++ )
{
pD3D->EnumAdapterModes( 0, i, &mode );
// Skip modes we don't care about
if ( mode.Format != D3DFMT_LIN_A8R8G8B8 )
continue;
// ignore 640 wide modes
if ( mode.Width < 720)
continue;
// If we get here, we found an acceptable mode
CLog::Log(LOGINFO, "Found mode: %ix%i at %iHz", mode.Width, mode.Height, mode.RefreshRate);
if (mode.Width == 720 && mode.Height == 576 && mode.RefreshRate == 50)
bHasPAL = true;
if (mode.Width == 720 && mode.Height == 480 && mode.RefreshRate == 60)
bHasNTSC = true;
}
}
示例2: GetFullscreenFrontBufferFormat
//Get a supported front buffer format
bool WINDOW::GetFullscreenFrontBufferFormat(D3DFORMAT requestedFormat, D3DFORMAT & resultFormat,
LPDIRECT3D8 d3d)
{
//See if the requested front buffer format is supported
HRESULT hr;
bool requestedFormatSupported=false;
bool X8R8G8B8Supported=false;
bool R5G6B5Supported=false;
//Get the number of available display modes
unsigned int numModes=d3d->GetAdapterModeCount(D3DADAPTER_DEFAULT);
//Loop through the modes to see if the formats are supported
for(unsigned int i=0; i<numModes; ++i)
{
D3DDISPLAYMODE mode;
hr=d3d->EnumAdapterModes(D3DADAPTER_DEFAULT, i, &mode);
if(mode.Format==requestedFormat)
requestedFormatSupported=true;
if(mode.Format==D3DFMT_X8R8G8B8)
X8R8G8B8Supported=true;
if(mode.Format==D3DFMT_R5G6B5)
R5G6B5Supported=true;
}
//Return the best supported format
if(requestedFormatSupported)
{
LOG::Instance()->OutputSuccess("Chosen front buffer format is available in fullscreen mode");
resultFormat=requestedFormat;
return true;
}
if(X8R8G8B8Supported)
{
LOG::Instance()->OutputMisc("D3DFMT_X8R8G8B8 will be used instead of chosen front buffer format in %s mode");
resultFormat=D3DFMT_X8R8G8B8;
return true;
}
if(R5G6B5Supported)
{
LOG::Instance()->OutputMisc("D3DFMT_R5G6B5 will be used instead of chosen front buffer format in %s mode");
resultFormat=D3DFMT_R5G6B5;
return true;
}
//No color formats supported
LOG::Instance()->OutputError("No suitable front buffer formats supported in fullscreen mode");
return false;
}
示例3:
void RageDisplay_D3D::GetDisplayResolutions( DisplayResolutions &out ) const
{
out.clear();
int iCnt = g_pd3d->GetAdapterModeCount( D3DADAPTER_DEFAULT );
for( int i = 0; i < iCnt; ++i )
{
D3DDISPLAYMODE mode;
g_pd3d->EnumAdapterModes( D3DADAPTER_DEFAULT, i, &mode );
DisplayResolution res = { mode.Width, mode.Height };
out.insert( res );
}
}
示例4: GetInitialMode
//pre: XBVideoConfig::GetModes has been called before this function
RESOLUTION XBVideoConfig::GetInitialMode(LPDIRECT3D8 pD3D, D3DPRESENT_PARAMETERS *p3dParams)
{
bool bHasPal = HasPAL();
DWORD numModes = pD3D->GetAdapterModeCount(D3DADAPTER_DEFAULT);
D3DDISPLAYMODE mode;
for ( DWORD i = 0; i < numModes; i++ )
{
pD3D->EnumAdapterModes( 0, i, &mode );
// ignore 640 wide modes
if ( mode.Width < 720)
continue;
p3dParams->BackBufferWidth = mode.Width;
p3dParams->BackBufferHeight = mode.Height;
p3dParams->FullScreen_RefreshRateInHz = mode.RefreshRate;
if ((bHasPal) && ((mode.Height != 576) || (mode.RefreshRate != 50)))
{
continue;
}
//take the first available mode
}
if (HasPAL())
{
if (HasWidescreen() && (p3dParams->Flags & D3DPRESENTFLAG_WIDESCREEN))
{
return PAL_16x9;
}
else
{
return PAL_4x3;
}
}
if (HasWidescreen() && (p3dParams->Flags & D3DPRESENTFLAG_WIDESCREEN))
{
return NTSC_16x9;
}
else
{
return NTSC_4x3;
}
}
示例5: EnumAdapters
void EnumAdapters( int nAdapter )
{
int i,n;
char buf[128];
n = pD3D->GetAdapterModeCount(nAdapter);
D3DCapsStruct.m_DisplayModeNum = n;
if( D3DCapsStruct.m_DisplayMode==NULL )
D3DCapsStruct.m_DisplayMode = (D3DDISPLAYMODE*)GAlloc( sizeof(D3DDISPLAYMODE)*n );
for( i=0 ; i<n ; i++ ){
if( pD3D->EnumAdapterModes(nAdapter,i,&D3DCapsStruct.m_DisplayMode[i]) == D3D_OK){
wsprintf( buf, "%d x %d (%d Hz) - %s\n",
D3DCapsStruct.m_DisplayMode[i].Width,
D3DCapsStruct.m_DisplayMode[i].Height,
D3DCapsStruct.m_DisplayMode[i].RefreshRate,
TxFmtMode[ LIM(D3DCapsStruct.m_DisplayMode[i].Format,0,D3DFMT_D3DD_MAX-1) ] );
DebugPrintf( buf );
}
}
}
示例6: D3DReduceParams
/* If the given parameters have failed, try to lower them. */
bool D3DReduceParams( D3DPRESENT_PARAMETERS *pp )
{
D3DDISPLAYMODE current;
current.Format = pp->BackBufferFormat;
current.Height = pp->BackBufferHeight;
current.Width = pp->BackBufferWidth;
current.RefreshRate = pp->FullScreen_RefreshRateInHz;
const int iCnt = g_pd3d->GetAdapterModeCount( D3DADAPTER_DEFAULT );
int iBest = -1;
int iBestScore = 0;
LOG->Trace( "cur: %ux%u %uHz, format %i", current.Width, current.Height, current.RefreshRate, current.Format );
for( int i = 0; i < iCnt; ++i )
{
D3DDISPLAYMODE mode;
g_pd3d->EnumAdapterModes( D3DADAPTER_DEFAULT, i, &mode );
/* Never change the format. */
if( mode.Format != current.Format )
continue;
/* Never increase the parameters. */
if( mode.Height > current.Height || mode.Width > current.Width || mode.RefreshRate > current.RefreshRate )
continue;
/* Never go below 640x480 unless we already are. */
if( (current.Width >= 640 && current.Height >= 480) && (mode.Width < 640 || mode.Height < 480) )
continue;
/* Never go below 60Hz. */
if( mode.RefreshRate && mode.RefreshRate < 60 )
continue;
/* If mode.RefreshRate is 0, it means "default". We don't know what that means;
* assume it's 60Hz. */
/* Higher scores are better. */
int iScore = 0;
if( current.RefreshRate >= 70 && mode.RefreshRate < 70 )
{
/* Top priority: we really want to avoid dropping to a refresh rate that's
* below 70Hz. */
iScore -= 100000;
}
else if( mode.RefreshRate < current.RefreshRate )
{
/* Low priority: We're lowering the refresh rate, but not too far. current.RefreshRate
* might be 0, in which case this simply gives points for higher refresh
* rates. */
iScore += (mode.RefreshRate - current.RefreshRate);
}
/* Medium priority: */
int iResolutionDiff = (current.Height - mode.Height) + (current.Width - mode.Width);
iScore -= iResolutionDiff * 100;
if( iBest == -1 || iScore > iBestScore )
{
iBest = i;
iBestScore = iScore;
}
LOG->Trace( "try: %ux%u %uHz, format %i: score %i", mode.Width, mode.Height, mode.RefreshRate, mode.Format, iScore );
}
if( iBest == -1 )
return false;
D3DDISPLAYMODE BestMode;
g_pd3d->EnumAdapterModes( D3DADAPTER_DEFAULT, iBest, &BestMode );
pp->BackBufferHeight = BestMode.Height;
pp->BackBufferWidth = BestMode.Width;
pp->FullScreen_RefreshRateInHz = BestMode.RefreshRate;
return true;
}
示例7: SetVideoMode
CString RageDisplay_D3D::Init( VideoModeParams p )
{
GraphicsWindow::Initialize();
LOG->Trace( "RageDisplay_D3D::RageDisplay_D3D()" );
LOG->MapLog("renderer", "Current renderer: Direct3D");
typedef IDirect3D8 * (WINAPI * Direct3DCreate8_t) (UINT SDKVersion);
Direct3DCreate8_t pDirect3DCreate8;
#if defined(XBOX)
pDirect3DCreate8 = Direct3DCreate8;
#else
g_D3D8_Module = LoadLibrary("D3D8.dll");
if(!g_D3D8_Module)
return D3D_NOT_INSTALLED;
pDirect3DCreate8 = (Direct3DCreate8_t) GetProcAddress(g_D3D8_Module, "Direct3DCreate8");
if(!pDirect3DCreate8)
{
LOG->Trace( "Direct3DCreate8 not found" );
return D3D_NOT_INSTALLED;
}
#endif
g_pd3d = pDirect3DCreate8( D3D_SDK_VERSION );
if(!g_pd3d)
{
LOG->Trace( "Direct3DCreate8 failed" );
return D3D_NOT_INSTALLED;
}
if( FAILED( g_pd3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &g_DeviceCaps) ) )
return
"Your system is reporting that Direct3D hardware acceleration is not available. "
"Please obtain an updated driver from your video card manufacturer.\n\n";
D3DADAPTER_IDENTIFIER8 identifier;
g_pd3d->GetAdapterIdentifier( D3DADAPTER_DEFAULT, 0, &identifier );
LOG->Trace(
"Driver: %s\n"
"Description: %s\n"
"Max texture size: %d\n"
"Alpha in palette: %s\n",
identifier.Driver,
identifier.Description,
g_DeviceCaps.MaxTextureWidth,
(g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) ? "yes" : "no" );
LOG->Trace( "This display adaptor supports the following modes:" );
D3DDISPLAYMODE mode;
for( UINT u=0; u<g_pd3d->GetAdapterModeCount(D3DADAPTER_DEFAULT); u++ )
if( SUCCEEDED( g_pd3d->EnumAdapterModes( D3DADAPTER_DEFAULT, u, &mode ) ) )
LOG->Trace( " %ux%u %uHz, format %d", mode.Width, mode.Height, mode.RefreshRate, mode.Format );
g_PaletteIndex.clear();
for( int i = 0; i < 256; ++i )
g_PaletteIndex.push_back(i);
// Save the original desktop format.
g_pd3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &g_DesktopMode );
/* Up until now, all we've done is set up g_pd3d and do some queries. Now,
* actually initialize the window. Do this after as many error conditions
* as possible, because if we have to shut it down again we'll flash a window
* briefly. */
bool bIgnore = false;
return SetVideoMode( p, bIgnore );
}