HRESULT HookIDirect3DDevice9::SetCurrentTexturePalette(LPVOID _this, UINT PaletteNumber) { LOG_API(); return pD3Dev->SetCurrentTexturePalette(PaletteNumber); }
/* Load the palette, if any, for the given texture into a palette slot, and make * it current. */ static void SetPalette( unsigned TexResource ) { /* If the texture isn't paletted, we have nothing to do. */ if( g_TexResourceToTexturePalette.find(TexResource) == g_TexResourceToTexturePalette.end() ) return; /* Is the palette already loaded? */ if( g_TexResourceToPaletteIndex.find(TexResource) == g_TexResourceToPaletteIndex.end() ) { /* It's not. Grab the least recently used slot. */ int iPalIndex = g_PaletteIndex.front(); /* If any other texture is currently using this slot, mark that palette unloaded. */ for( map<unsigned,int>::iterator i = g_TexResourceToPaletteIndex.begin(); i != g_TexResourceToPaletteIndex.end(); ++i ) { if( i->second != iPalIndex ) continue; g_TexResourceToPaletteIndex.erase(i); break; } /* Load it. */ #if !defined(XBOX) TexturePalette& pal = g_TexResourceToTexturePalette[TexResource]; g_pd3dDevice->SetPaletteEntries( iPalIndex, pal.p ); #else ASSERT(0); #endif g_TexResourceToPaletteIndex[TexResource] = iPalIndex; } const int iPalIndex = g_TexResourceToPaletteIndex[TexResource]; /* Find this palette index in the least-recently-used queue and move it to the end. */ for(list<int>::iterator i = g_PaletteIndex.begin(); i != g_PaletteIndex.end(); ++i) { if( *i != iPalIndex ) continue; g_PaletteIndex.erase(i); g_PaletteIndex.push_back(iPalIndex); break; } #if !defined(XBOX) g_pd3dDevice->SetCurrentTexturePalette( iPalIndex ); #else ASSERT(0); #endif }