MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / readHeader

Method readHeader

Engine/source/gfx/bitmap/ddsFile.cpp:203–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203bool DDSFile::readHeader(Stream &s)
204{
205 U32 fourcc;
206 // Read the FOURCC
207 s.read(&fourcc);
208
209 if(fourcc != DDS_MAGIC)
210 {
211 Con::errorf("DDSFile::readHeader - unexpected magic number, wanted 'DDS '!");
212 return false;
213 }
214
215 //dds headers
216 dds::DDS_HEADER header = {};
217 dds::DDS_HEADER_DXT10 dx10header = {};
218 //todo DX10 formats
219 bool hasDx10Header = false;
220
221 //read in header
222 s.read(DDS_HEADER_SIZE, &header);
223 //check for dx10 header support
224 if ((header.ddspf.flags & DDS_FOURCC) && (header.ddspf.fourCC == dds::D3DFMT_DX10))
225 {
226 //read in dx10 header
227 s.read(DDS_HEADER_DX10_SIZE, &dx10header);
228 if (!dds::validateHeaderDx10(dx10header))
229 return false;
230
231 hasDx10Header = true;
232 }
233
234 //make sure our dds header is valid
235 if (!dds::validateHeader(header))
236 return false;
237
238 // store details
239 mPitchOrLinearSize = header.pitchOrLinearSize;
240 mMipMapCount = header.mipMapCount ? header.mipMapCount : 1;
241 mHeight = header.height;
242 mWidth = header.width;
243 mDepth = header.depth;
244 mFourCC = header.ddspf.fourCC;
245
246 //process dx10 header
247 if (hasDx10Header)
248 {
249 if (dx10header.arraySize > 1)
250 {
251 Con::errorf("DDSFile::readHeader - DX10 arrays not supported");
252 return false;
253 }
254
255 mFormat = dds::getGFXFormat(dx10header.dxgiFormat);
256 //make sure getGFXFormat gave us a valid format
257 if (mFormat == GFXFormat_FIRST)
258 return false;
259 //cubemap
260 if (dx10header.miscFlag & dds::D3D10_RESOURCE_MISC_TEXTURECUBE)

Callers

nothing calls this directly

Calls 9

validateHeaderDx10Function · 0.85
validateHeaderFunction · 0.85
getGFXFormatFunction · 0.85
isAlphaFormatFunction · 0.85
isCompressedFormatFunction · 0.85
getBitsPerPixelFunction · 0.85
errorfFunction · 0.50
readMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected