MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / PAAFileToDDS

Method PAAFileToDDS

engine/Poseidon/Graphics/Textures/DDSConverter.cpp:280–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278// --- PAA → DDS conversion (raw block copy for DXT) ---
279
280DDSFile DDSConverter::PAAFileToDDS(const std::string& paaPath)
281{
282 DDSFile result;
283
284 // Read PAA metadata
285 PAAInfo info;
286 if (!ReadPAAInfo(paaPath, info) || !info.formatName)
287 return result;
288
289 // Map PAA format → PixelFormat
290 PixelFormat pf = PixelFormat::Unknown;
291 switch (info.magic)
292 {
293 case 0xFF01:
294 pf = PixelFormat::DXT1;
295 break;
296 case 0xFF03:
297 pf = PixelFormat::DXT3;
298 break;
299 case 0xFF05:
300 pf = PixelFormat::DXT5;
301 break;
302 default:
303 break;
304 }
305
306 if (pf != PixelFormat::Unknown)
307 {
308 // DXT: extract raw compressed blocks from PAA mipmaps (no re-encoding)
309 std::ifstream f(paaPath, std::ios::binary);
310 if (!f.good())
311 return result;
312
313 // Skip magic word
314 uint16_t magic;
315 f.read(reinterpret_cast<char*>(&magic), 2);
316
317 // Skip TAGGs
318 while (f.good())
319 {
320 uint32_t tag;
321 f.read(reinterpret_cast<char*>(&tag), 4);
322 if (tag != 0x54414747)
323 {
324 f.seekg(-4, std::ios::cur);
325 break;
326 }
327 uint32_t tagName;
328 f.read(reinterpret_cast<char*>(&tagName), 4);
329 uint32_t tagSize;
330 f.read(reinterpret_cast<char*>(&tagSize), 4);
331 f.seekg(tagSize, std::ios::cur);
332 }
333
334 // Skip palette
335 uint16_t palCount;
336 f.read(reinterpret_cast<char*>(&palCount), 2);
337 if (palCount > 0)

Callers

nothing calls this directly

Calls 7

ReadPAAInfoFunction · 0.85
DecodePAAFileMipFunction · 0.85
seekgMethod · 0.80
readMethod · 0.45
resizeMethod · 0.45
emptyMethod · 0.45
validMethod · 0.45

Tested by

no test coverage detected