本文整理汇总了C++中LPDIRECTDRAWPALETTE::GetCaps方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWPALETTE::GetCaps方法的具体用法?C++ LPDIRECTDRAWPALETTE::GetCaps怎么用?C++ LPDIRECTDRAWPALETTE::GetCaps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAWPALETTE
的用法示例。
在下文中一共展示了LPDIRECTDRAWPALETTE::GetCaps方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetupPalette
bool SetupPalette(LPDIRECTDRAWPALETTE lpDDPalette)
{
if (!lpDDPalette)
{
//logOutput << CurrentTimeString() << "Detaching palette" << endl;
g_CurrentPalette.Free();
g_bUsePalette = false;
return false;
}
logOutput << CurrentTimeString() << "initializing palette" << endl;
DWORD caps;
HRESULT hr;
if (FAILED(hr = lpDDPalette->GetCaps(&caps)))
{
logOutput << CurrentTimeString() << "Failed to get palette caps" << endl;
printDDrawError(hr, "SetupPalette");
return false;
}
if (caps & DDPCAPS_8BITENTRIES)
{
logOutput << CurrentTimeString() << "8-bit index-palette used (lookup color is an index to another lookup table), not implemented" << endl;
return false;
}
DWORD numEntries = 0;
if (caps & DDPCAPS_8BIT)
numEntries = 0x100;
else if (caps & DDPCAPS_4BIT)
numEntries = 0x10;
else if (caps & DDPCAPS_2BIT)
numEntries = 0x04;
else if (caps & DDPCAPS_1BIT)
numEntries = 0x02;
else
{
logOutput << CurrentTimeString() << "Unrecognized palette format" << endl;
return false;
}
//logOutput << CurrentTimeString() << "Trying to retrieve " << numEntries << " palette entries" << endl;
g_CurrentPalette.Reallocate(numEntries);
hr = lpDDPalette->GetEntries(0, 0, numEntries, g_CurrentPalette.entries);
if (FAILED(hr))
{
logOutput << CurrentTimeString() << "Failed to retrieve palette entries" << endl;
printDDrawError(hr, "SetupPalette");
g_CurrentPalette.Free();
return false;
}
g_CurrentPalette.primary_surface_palette_ref = lpDDPalette;
g_CurrentPalette.bInitialized = true;
g_bUsePalette = true;
logOutput << CurrentTimeString() << "Initialized palette with " << numEntries << " color entries" << endl;
return true;
}