------------------------------------------------------------------------------- Load the background texture for the viewer -------------------------------------------------------------------------------
| 391 | // Load the background texture for the viewer |
| 392 | //------------------------------------------------------------------------------- |
| 393 | void LoadBGTexture() { |
| 394 | char szFileName[MAX_PATH]; |
| 395 | |
| 396 | DWORD dwTemp = MAX_PATH; |
| 397 | if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"TextureSrc",nullptr,nullptr, (BYTE*)szFileName,&dwTemp)) { |
| 398 | // Key was not found. Use C: |
| 399 | strcpy(szFileName,""); |
| 400 | } else { |
| 401 | // need to remove the file name |
| 402 | char* sz = strrchr(szFileName,'\\'); |
| 403 | if (!sz) |
| 404 | sz = strrchr(szFileName,'/'); |
| 405 | if (sz) |
| 406 | *sz = 0; |
| 407 | } |
| 408 | OPENFILENAME sFilename1 = { |
| 409 | sizeof(OPENFILENAME), |
| 410 | g_hDlg,GetModuleHandle(nullptr), |
| 411 | "Textures\0*.png;*.dds;*.tga;*.bmp;*.tif;*.ppm;*.ppx;*.jpg;*.jpeg;*.exr\0*.*\0", |
| 412 | nullptr, 0, 1, |
| 413 | szFileName, MAX_PATH, nullptr, 0, nullptr, |
| 414 | "Open texture as background", |
| 415 | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR, |
| 416 | 0, 1, ".jpg", 0, nullptr, nullptr |
| 417 | }; |
| 418 | if(GetOpenFileName(&sFilename1) == 0) return; |
| 419 | |
| 420 | // Now store the file in the registry |
| 421 | RegSetValueExA(g_hRegistry,"TextureSrc",0,REG_SZ,(const BYTE*)szFileName,MAX_PATH); |
| 422 | RegSetValueExA(g_hRegistry,"LastTextureSrc",0,REG_SZ,(const BYTE*)szFileName,MAX_PATH); |
| 423 | RegSetValueExA(g_hRegistry,"LastSkyBoxSrc",0,REG_SZ,(const BYTE*)"",MAX_PATH); |
| 424 | |
| 425 | CBackgroundPainter::Instance().SetTextureBG(szFileName); |
| 426 | } |
| 427 | |
| 428 | //------------------------------------------------------------------------------- |
| 429 | // Reset the background color to a smart and nice grey |
no test coverage detected