2008-05-22 05:07:43 -07:00
|
|
|
// Copyright (C) 2004 Murphy McCauley
|
2009-01-14 04:37:51 -08:00
|
|
|
// Copyright (C) 2007-2009 Christian Stehno
|
2008-05-22 05:07:43 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
2007-11-21 15:27:21 -08:00
|
|
|
/*
|
|
|
|
Thanks to:
|
|
|
|
Max McGuire for his Flipcode article about WAL textures
|
|
|
|
Nikolaus Gebhardt for the Irrlicht 3D engine
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __C_IMAGE_LOADER_WAL_H_INCLUDED__
|
|
|
|
#define __C_IMAGE_LOADER_WAL_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "IImageLoader.h"
|
|
|
|
|
2009-08-24 02:12:27 -07:00
|
|
|
namespace irr
|
2007-11-21 15:27:21 -08:00
|
|
|
{
|
|
|
|
namespace video
|
|
|
|
{
|
2010-07-07 09:16:03 -07:00
|
|
|
#if 0
|
2007-11-21 15:27:21 -08:00
|
|
|
|
2009-08-24 02:12:27 -07:00
|
|
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
2007-11-21 15:27:21 -08:00
|
|
|
# pragma pack( push, packing )
|
|
|
|
# pragma pack( 1 )
|
|
|
|
# define PACK_STRUCT
|
|
|
|
#elif defined( __GNUC__ )
|
|
|
|
# define PACK_STRUCT __attribute__((packed))
|
|
|
|
#else
|
|
|
|
# error compiler not supported
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct SWALHeader {
|
|
|
|
char FrameName[32];
|
2009-08-24 02:12:27 -07:00
|
|
|
|
2007-11-21 15:27:21 -08:00
|
|
|
u32 ImageWidth;
|
|
|
|
u32 ImageHeight;
|
|
|
|
|
|
|
|
s32 MipmapOffset[4];
|
|
|
|
|
|
|
|
char NextFrameName[32];
|
|
|
|
|
|
|
|
u32 Flags; // surface properties, i.e. slick, sky, nodraw
|
|
|
|
u32 Contents; // i.e. solid, clip, area portal
|
|
|
|
u32 Value; // light
|
|
|
|
} PACK_STRUCT;
|
|
|
|
|
2009-08-24 02:12:27 -07:00
|
|
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
2007-11-21 15:27:21 -08:00
|
|
|
# pragma pack( pop, packing )
|
|
|
|
#endif
|
|
|
|
#undef PACK_STRUCT
|
|
|
|
|
2008-05-22 05:07:43 -07:00
|
|
|
//! An Irrlicht image loader for Quake engine WAL textures
|
2007-11-21 15:27:21 -08:00
|
|
|
class CImageLoaderWAL : public irr::video::IImageLoader
|
|
|
|
{
|
|
|
|
public:
|
2009-08-24 02:12:27 -07:00
|
|
|
virtual bool isALoadableFileExtension(const io::path& filename) const;
|
2007-11-21 15:27:21 -08:00
|
|
|
|
|
|
|
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
|
|
|
|
|
|
|
|
virtual irr::video::IImage* loadImage(irr::io::IReadFile* file) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static s32 DefaultPaletteQ2[256];
|
|
|
|
};
|
|
|
|
|
2010-07-07 09:16:03 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//! An Irrlicht image loader for Quake1,2 engine lmp textures/palette
|
|
|
|
class CImageLoaderLMP : public irr::video::IImageLoader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool isALoadableFileExtension(const io::path& filename) const;
|
|
|
|
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
|
|
|
|
virtual irr::video::IImage* loadImage(irr::io::IReadFile* file) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
//! An Irrlicht image loader for quake2 wal engine textures
|
|
|
|
class CImageLoaderWAL : public irr::video::IImageLoader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool isALoadableFileExtension(const io::path& filename) const;
|
|
|
|
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
|
|
|
|
virtual irr::video::IImage* loadImage(irr::io::IReadFile* file) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
//! An Irrlicht image loader for Halife 1 engine textures
|
|
|
|
class CImageLoaderWAL2 : public irr::video::IImageLoader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool isALoadableFileExtension(const io::path& filename) const;
|
|
|
|
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
|
|
|
|
virtual irr::video::IImage* loadImage(irr::io::IReadFile* file) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
|
|
|
# pragma pack( push, packing )
|
|
|
|
# pragma pack( 1 )
|
|
|
|
# define PACK_STRUCT
|
|
|
|
#elif defined( __GNUC__ )
|
|
|
|
# define PACK_STRUCT __attribute__((packed))
|
|
|
|
#else
|
|
|
|
# error compiler not supported
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct SLMPHeader {
|
|
|
|
u32 width; // width
|
|
|
|
u32 height; // height
|
|
|
|
// variably sized
|
|
|
|
} PACK_STRUCT;
|
|
|
|
|
|
|
|
// Halfelife wad3 type 67 file
|
|
|
|
struct miptex_halflife
|
|
|
|
{
|
|
|
|
c8 name[16];
|
|
|
|
u32 width, height;
|
|
|
|
u32 mipmap[4]; // four mip maps stored
|
|
|
|
} PACK_STRUCT;
|
|
|
|
|
|
|
|
//quake2 texture
|
|
|
|
struct miptex_quake2
|
|
|
|
{
|
|
|
|
c8 name[32];
|
|
|
|
u32 width;
|
|
|
|
u32 height;
|
|
|
|
u32 mipmap[4]; // four mip maps stored
|
|
|
|
c8 animname[32]; // next frame in animation chain
|
|
|
|
s32 flags;
|
|
|
|
s32 contents;
|
|
|
|
s32 value;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
|
|
|
# pragma pack( pop, packing )
|
|
|
|
#endif
|
|
|
|
#undef PACK_STRUCT
|
|
|
|
|
2007-11-21 15:27:21 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|