| 152 | } |
| 153 | |
| 154 | ::testing::AssertionResult LoadDDS( const char* filePath, uint32_t& width, uint32_t& height, std::unique_ptr<uint8_t[]>& data ) |
| 155 | { |
| 156 | FILE* f; |
| 157 | if( fopen_s( &f, filePath, "rb" ) ) |
| 158 | { |
| 159 | return ::testing::AssertionFailure() << "failed to open file " << filePath; |
| 160 | } |
| 161 | ON_BLOCK_EXIT( [=] { fclose( f ); } ); |
| 162 | |
| 163 | DDS_HEADER header; |
| 164 | if( 1 != fread( &header, sizeof( header ), 1, f ) ) |
| 165 | { |
| 166 | return ::testing::AssertionFailure() << "failed to read DDS header from " << filePath; |
| 167 | } |
| 168 | |
| 169 | width = header.dwWidth; |
| 170 | height = header.dwHeight; |
| 171 | |
| 172 | if( width * height * 4 != header.dwPitchOrLinearSize ) |
| 173 | { |
| 174 | return ::testing::AssertionFailure() << "unexpected DDS file pixel format or pitch " << filePath; |
| 175 | } |
| 176 | |
| 177 | data.reset( new uint8_t[header.dwPitchOrLinearSize] ); |
| 178 | |
| 179 | if( header.dwPitchOrLinearSize != fread( data.get(), 1, header.dwPitchOrLinearSize, f ) ) |
| 180 | { |
| 181 | return ::testing::AssertionFailure() << "failed to read DDS pixel values " << filePath; |
| 182 | } |
| 183 | return ::testing::AssertionSuccess(); |
| 184 | } |
| 185 | |
| 186 | ::testing::AssertionResult CompareWithBitmap( const char* filePath, Tr2TextureAL& rt, Tr2RenderContextAL& renderContext ) |
| 187 | { |
no test coverage detected