| 439 | } |
| 440 | |
| 441 | bool DDSFile::writeHeader( Stream &s ) |
| 442 | { |
| 443 | // write DDS magic |
| 444 | U32 magic = DDS_MAGIC; |
| 445 | s.write(magic); |
| 446 | |
| 447 | dds::DDS_HEADER header = {}; |
| 448 | dds::DDS_HEADER_DXT10 dx10header = {}; |
| 449 | |
| 450 | bool hasDx10Header = false; |
| 451 | //flags |
| 452 | U32 surfaceFlags = DDS_SURFACE_FLAGS_TEXTURE; |
| 453 | U32 cubemapFlags = 0; |
| 454 | U32 headerFlags = DDS_HEADER_FLAGS_TEXTURE; |
| 455 | |
| 456 | //pixel format |
| 457 | const dds::DDS_PIXELFORMAT &format = dds::getDDSFormat(mFormat); |
| 458 | |
| 459 | // todo better dx10 support |
| 460 | if (format.fourCC == dds::D3DFMT_DX10) |
| 461 | { |
| 462 | dx10header.dxgiFormat = dds::getDXGIFormat(mFormat); |
| 463 | dx10header.arraySize = 1; |
| 464 | dx10header.resourceDimension = dds::D3D10_RESOURCE_DIMENSION_TEXTURE2D; |
| 465 | dx10header.miscFlag = 0; |
| 466 | dx10header.miscFlags2 = 0; |
| 467 | hasDx10Header = true; |
| 468 | } |
| 469 | |
| 470 | if (mFlags.test(CompressedData)) |
| 471 | headerFlags |= DDS_HEADER_FLAGS_LINEARSIZE; |
| 472 | else |
| 473 | headerFlags |= DDS_HEADER_FLAGS_PITCH; |
| 474 | |
| 475 | if (mMipMapCount > 1) |
| 476 | { |
| 477 | surfaceFlags |= DDS_SURFACE_FLAGS_MIPMAP; |
| 478 | headerFlags |= DDS_HEADER_FLAGS_MIPMAP; |
| 479 | } |
| 480 | |
| 481 | //cubemap flags |
| 482 | if (mFlags.test(CubeMapFlag)) |
| 483 | { |
| 484 | surfaceFlags |= DDS_SURFACE_FLAGS_CUBEMAP; |
| 485 | cubemapFlags |= DDS_CUBEMAP_ALLFACES; |
| 486 | if (hasDx10Header) |
| 487 | dx10header.miscFlag = dds::D3D10_RESOURCE_MISC_TEXTURECUBE; |
| 488 | } |
| 489 | |
| 490 | //volume texture |
| 491 | if (mDepth > 0) |
| 492 | { |
| 493 | headerFlags |= DDS_HEADER_FLAGS_VOLUME; |
| 494 | dx10header.resourceDimension = dds::D3D10_RESOURCE_DIMENSION_TEXTURE3D; |
| 495 | } |
| 496 | |
| 497 | //main dds header |
| 498 | header.size = sizeof(dds::DDS_HEADER); |
nothing calls this directly
no test coverage detected