Optional lunar.png loading from file

This commit is contained in:
Silent 2015-03-20 21:10:13 +01:00
parent 70e449fed0
commit 7d4e85b1dc

View file

@ -567,15 +567,26 @@ void DrawMoonWithPhases(int moonColor, float* screenPos, float sizeX, float size
{ {
if ( !gpMoonMask ) if ( !gpMoonMask )
{ {
HMODULE thisModule;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)DrawMoonWithPhases, &thisModule);
HRSRC resource = FindResource(thisModule, MAKEINTRESOURCE(IDR_LUNAR64), RT_RCDATA); if ( GetFileAttributes("lunar.png") != INVALID_FILE_ATTRIBUTES )
void* pMoonMask = static_cast<void*>(LoadResource(thisModule, resource)); {
// load from file
gpMoonMask = CPNGFile::ReadFromFile("lunar.png");
}
else
{
// Load from memory
gpMoonMask = CPNGFile::ReadFromMemory(pMoonMask, SizeofResource(thisModule, resource)); HMODULE thisModule;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)DrawMoonWithPhases, &thisModule);
FreeResource(pMoonMask); HRSRC resource = FindResource(thisModule, MAKEINTRESOURCE(IDR_LUNAR64), RT_RCDATA);
void* pMoonMask = static_cast<void*>(LoadResource(thisModule, resource));
gpMoonMask = CPNGFile::ReadFromMemory(pMoonMask, SizeofResource(thisModule, resource));
FreeResource(pMoonMask);
}
} }
//D3DPERF_BeginEvent(D3DCOLOR_ARGB(0,0,0,0), L"render moon"); //D3DPERF_BeginEvent(D3DCOLOR_ARGB(0,0,0,0), L"render moon");