1
// Copyright (C) 2002-2011 Thomas Alten
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#ifndef __C_IMAGE_LOADER_DDS_H_INCLUDED__
6
#define __C_IMAGE_LOADER_DDS_H_INCLUDED__
8
#include "IrrCompileConfig.h"
10
#include "IImageLoader.h"
12
#define _IRR_COMPILE_WITH_DDS_LOADER_
18
#if defined(_IRR_COMPILE_WITH_DDS_LOADER_)
20
// byte-align structures
21
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
22
# pragma pack( push, packing )
25
#elif defined( __GNUC__ )
26
# define PACK_STRUCT __attribute__((packed))
46
#define DDS_LOW_5 0x001F;
47
#define DDS_MID_6 0x07E0;
48
#define DDS_HIGH_5 0xF800;
49
#define DDS_MID_555 0x03E0;
50
#define DDS_HI_555 0x7C00;
56
u32 colorSpaceLowValue;
57
u32 colorSpaceHighValue;
68
struct ddsMultiSampleCaps
86
u32 luminanceBitCount;
88
u32 privateFormatBitCount;
105
ddsMultiSampleCaps multiSampleCaps;
112
u32 bumpLuminanceBitMask;
118
u32 luminanceAlphaBitMask;
130
/* directdraw surface */
152
ddsColorKey ckDestOverlay;
155
ddsColorKey ckDestBlt;
156
ddsColorKey ckSrcOverlay;
157
ddsColorKey ckSrcBlt;
160
ddsPixelFormat pixelFormat;
166
/* data (Varying size) */
178
struct ddsAlphaBlockExplicit
184
struct ddsAlphaBlock3BitLinear
198
/* endian tomfoolery */
207
#ifndef __BIG_ENDIAN__
209
#define __BIG_ENDIAN__
214
#ifdef __BIG_ENDIAN__
216
s32 DDSBigLong( s32 src ) { return src; }
217
s16 DDSBigShort( s16 src ) { return src; }
218
f32 DDSBigFloat( f32 src ) { return src; }
220
s32 DDSLittleLong( s32 src )
222
return ((src & 0xFF000000) >> 24) |
223
((src & 0x00FF0000) >> 8) |
224
((src & 0x0000FF00) << 8) |
225
((src & 0x000000FF) << 24);
228
s16 DDSLittleShort( s16 src )
230
return ((src & 0xFF00) >> 8) |
231
((src & 0x00FF) << 8);
234
f32 DDSLittleFloat( f32 src )
236
floatSwapUnion in,out;
238
out.c[ 0 ] = in.c[ 3 ];
239
out.c[ 1 ] = in.c[ 2 ];
240
out.c[ 2 ] = in.c[ 1 ];
241
out.c[ 3 ] = in.c[ 0 ];
245
#else /*__BIG_ENDIAN__*/
247
s32 DDSLittleLong( s32 src ) { return src; }
248
s16 DDSLittleShort( s16 src ) { return src; }
249
f32 DDSLittleFloat( f32 src ) { return src; }
251
s32 DDSBigLong( s32 src )
253
return ((src & 0xFF000000) >> 24) |
254
((src & 0x00FF0000) >> 8) |
255
((src & 0x0000FF00) << 8) |
256
((src & 0x000000FF) << 24);
259
s16 DDSBigShort( s16 src )
261
return ((src & 0xFF00) >> 8) |
262
((src & 0x00FF) << 8);
265
f32 DDSBigFloat( f32 src )
267
floatSwapUnion in,out;
269
out.c[ 0 ] = in.c[ 3 ];
270
out.c[ 1 ] = in.c[ 2 ];
271
out.c[ 2 ] = in.c[ 1 ];
272
out.c[ 3 ] = in.c[ 0 ];
276
#endif /*__BIG_ENDIAN__*/
280
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
281
# pragma pack( pop, packing )
286
#endif // compiled with loader or reader
288
#ifdef _IRR_COMPILE_WITH_DDS_LOADER_
291
Surface Loader for DDS images
293
class CImageLoaderDDS : public IImageLoader
297
//! returns true if the file maybe is able to be loaded by this class
298
//! based on the file extension (e.g. ".tga")
299
virtual bool isALoadableFileExtension(const io::path& filename) const;
301
//! returns true if the file maybe is able to be loaded by this class
302
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
304
//! creates a surface from the file
305
virtual IImage* loadImage(io::IReadFile* file) const;
311
#endif // compiled with DDS loader
313
} // end namespace video
314
} // end namespace irr