MCPcopy Create free account
hub / github.com/OGRECave/ogre / encode

Method encode

OgreMain/src/OgreDDSCodec.cpp:197–418  ·  view source on GitHub ↗

---------------------------------------------------------------------

Source from the content-addressed store, hash-verified

195 }
196 //---------------------------------------------------------------------
197 DataStreamPtr DDSCodec::encode(const Any& input) const
198 {
199 Image* image = any_cast<Image*>(input);
200
201 bool isCubeMap = image->hasFlag(IF_CUBEMAP);
202
203 // Establish texture attributes
204 bool isVolume = (image->getDepth() > 1);
205 bool isFloat32r = (image->getFormat() == PF_FLOAT32_R);
206 bool isFloat16 = (image->getFormat() == PF_FLOAT16_RGBA);
207 bool isFloat16r = (image->getFormat() == PF_FLOAT16_R);
208 bool isFloat32 = (image->getFormat() == PF_FLOAT32_RGBA);
209 bool notImplemented = false;
210 String notImplementedString = "";
211
212 // Check for all the 'not implemented' conditions
213 if ((isVolume == true)&&(image->getWidth() != image->getHeight()))
214 {
215 // Square textures only
216 notImplemented = true;
217 notImplementedString += "non square textures";
218 }
219
220 uint32 size = 1;
221 while (size < image->getWidth())
222 {
223 size <<= 1;
224 }
225 if (size != image->getWidth())
226 {
227 // Power two textures only
228 notImplemented = true;
229 notImplementedString += "non power two textures";
230 }
231
232 switch(image->getFormat())
233 {
234 case PF_A8R8G8B8:
235 case PF_X8R8G8B8:
236 case PF_R8G8B8:
237 case PF_A8B8G8R8:
238 case PF_X8B8G8R8:
239 case PF_B8G8R8:
240 case PF_FLOAT32_R:
241 case PF_FLOAT16_R:
242 case PF_FLOAT16_RGBA:
243 case PF_FLOAT32_RGBA:
244 break;
245 default:
246 // No crazy FOURCC or 565 et al. file formats at this stage
247 notImplemented = true;
248 notImplementedString = PixelUtil::getFormatName(image->getFormat());
249 break;
250 }
251
252
253
254 // Except if any 'not implemented' conditions were met

Callers

nothing calls this directly

Calls 12

flipEndianFunction · 0.85
bulkPixelConversionFunction · 0.85
MemoryDataStreamClass · 0.85
getNumMipmapsMethod · 0.80
swapFunction · 0.50
getDepthMethod · 0.45
getFormatMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
getSizeMethod · 0.45
writeMethod · 0.45
seekMethod · 0.45

Tested by

no test coverage detected