| 57 | } |
| 58 | |
| 59 | void CResourceManager::LoadShaderFile(LPCSTR fname) |
| 60 | { |
| 61 | // Check if file is compressed already |
| 62 | const string32 ID = "shENGINE"; |
| 63 | |
| 64 | string32 id; |
| 65 | IReader* F = FS.r_open(fname); |
| 66 | R_ASSERT(F, fname); |
| 67 | F->r(&id, 8); |
| 68 | |
| 69 | if (0 == strncmp(id, ID, 8)) |
| 70 | { |
| 71 | FATAL("Unsupported blender library. Compressed?"); |
| 72 | } |
| 73 | |
| 74 | string_path ini_path; |
| 75 | strcpy_s(ini_path, fname); |
| 76 | if (strext(ini_path)) |
| 77 | *strext(ini_path) = 0; |
| 78 | strcat_s(ini_path, ".ltx"); |
| 79 | |
| 80 | CInifile ini(ini_path, 0, 1, bShadersXrExport); |
| 81 | |
| 82 | // Load blenders |
| 83 | if (IReader* fs = F->open_chunk(2)) |
| 84 | { |
| 85 | IReader* chunk; |
| 86 | int chunk_id = 0; |
| 87 | |
| 88 | while ((chunk = fs->open_chunk(chunk_id)) != nullptr) |
| 89 | { |
| 90 | CBlender_DESC desc; |
| 91 | chunk->r(&desc, sizeof(desc)); |
| 92 | |
| 93 | IBlenderXr* B = IBlenderXr::Create(desc.CLS); |
| 94 | if (!B) |
| 95 | { |
| 96 | Msg("! Renderer doesn't support blender '%s'", desc.cName); |
| 97 | } |
| 98 | else |
| 99 | { |
| 100 | if (B->getDescription().version < desc.version) |
| 101 | { |
| 102 | Msg("! Version conflict in shader '%s'", desc.cName); |
| 103 | } |
| 104 | |
| 105 | chunk->seek(0); |
| 106 | |
| 107 | B->Load(*chunk, desc.version); |
| 108 | |
| 109 | // для конвертации в ltx |
| 110 | if (bShadersXrExport) |
| 111 | { |
| 112 | if (ini.section_exist(desc.cName)) |
| 113 | { |
| 114 | Msg("~~Found existing section [%s] in [%s]. Replacing!", desc.cName, ini_path); |
| 115 | ini.remove_section(desc.cName); |
| 116 | } |
nothing calls this directly
no test coverage detected