6e8fbca745
match the genesis editor version 1.3.0.653.
200 lines
6.5 KiB
C++
200 lines
6.5 KiB
C++
/****************************************************************************
|
||
Copyright (c) 2011-2013,WebJet Business Division,CYOU
|
||
|
||
http://www.genesis-3d.com.cn
|
||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
of this software and associated documentation files (the "Software"), to deal
|
||
in the Software without restriction, including without limitation the rights
|
||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
copies of the Software, and to permit persons to whom the Software is
|
||
furnished to do so, subject to the following conditions:
|
||
|
||
The above copyright notice and this permission notice shall be included in
|
||
all copies or substantial portions of the Software.
|
||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||
THE SOFTWARE.
|
||
****************************************************************************/
|
||
#ifndef __PixelFormat_H__
|
||
#define __PixelFormat_H__
|
||
|
||
#include "../foundation/util/string.h"
|
||
|
||
namespace RenderBase
|
||
{
|
||
/** from Ogre
|
||
* Flags defining some on/off properties of pixel formats
|
||
*/
|
||
enum PixelFormatFlags {
|
||
// This format has an alpha channel
|
||
PFF_HASALPHA = 0x00000001,
|
||
// This format is compressed. This invalidates the values in elemBytes,
|
||
// elemBits and the bit counts as these might not be fixed in a compressed format.
|
||
PFF_COMPRESSED = 0x00000002,
|
||
// This is a floating point format
|
||
PFF_FLOAT = 0x00000004,
|
||
// This is a depth format (for depth textures)
|
||
PFF_DEPTH = 0x00000008,
|
||
// Format is in native endian. Generally true for the 16, 24 and 32 bits
|
||
// formats which can be represented as machine integers.
|
||
PFF_NATIVEENDIAN = 0x00000010,
|
||
// This is an intensity format instead of a RGB one. The luminance
|
||
// replaces R,G and B. (but not A)
|
||
PFF_LUMINANCE = 0x00000020
|
||
};
|
||
|
||
/** From Ogre Pixel component format */
|
||
enum PixelComponentType
|
||
{
|
||
PCT_BYTE = 0, /// Byte per component (8 bit fixed 0.0..1.0)
|
||
PCT_SHORT = 1, /// Short per component (16 bit fixed 0.0..1.0))
|
||
PCT_FLOAT16 = 2, /// 16 bit float per component
|
||
PCT_FLOAT32 = 3, /// 32 bit float per component
|
||
PCT_COUNT = 4 /// Number of pixel types
|
||
};
|
||
|
||
//-----------------------------------------------------------------------
|
||
/** From Ogre
|
||
* A record that describes a pixel format in detail.
|
||
*/
|
||
struct PixelFormatDescription {
|
||
/* Name of the format, as in the enum */
|
||
const char *name;
|
||
/* Number of bytes one element (colour value) takes. */
|
||
unsigned char elemBytes;
|
||
/* Pixel format flags, see enum PixelFormatFlags for the bit field
|
||
* definitions
|
||
*/
|
||
uint32 flags;
|
||
/** Component type
|
||
*/
|
||
PixelComponentType componentType;
|
||
/** Component count
|
||
*/
|
||
unsigned char componentCount;
|
||
/* Number of bits for red(or luminance), green, blue, alpha
|
||
*/
|
||
unsigned char rbits,gbits,bbits,abits; /*, ibits, dbits, ... */
|
||
|
||
/* Masks and shifts as used by packers/unpackers */
|
||
uint32 rmask, gmask, bmask, amask;
|
||
unsigned char rshift, gshift, bshift, ashift;
|
||
};
|
||
|
||
// <20>Ĵ<DEB8>ö<EFBFBD><C3B6>ʱ<EFBFBD>ǵ<EFBFBD>Ҫ<EFBFBD>ͽű<CDBD><C5B1>ĸ<EFBFBD>ʽͬ<CABD><CDAC>ScriptRuntime._PixelFormat<61><74>
|
||
// <20><><EFBFBD>ظ<EFBFBD>ʽ<EFBFBD>е<EFBFBD>˳<EFBFBD><CBB3>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>˳<EFBFBD><EFBFBD><F2A1A3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4>ֽ<EFBFBD><D6BD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ڵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>е<EFBFBD>ƽ̨<C6BD><CCA8>
|
||
// <20><><EFBFBD><EFBFBD>A8R8G8B8<42><38><EFBFBD><EFBFBD>{A<><41>R<EFBFBD><52>G<EFBFBD><47>B}<7D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>˻<EFBFBD><CBBB><EFBFBD><EFBFBD>ϣ<EFBFBD>PC<50><43><EFBFBD>ϣ<EFBFBD><CFA3>ڴ<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>[B<><42>G<EFBFBD><47>R<EFBFBD><52>A]<5D><>
|
||
// <20><><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>D3D<33><44>OpenGL<47><4C>һ<EFBFBD>µģ<C2B5><C4A3><EFBFBD><EFBFBD>ڴ<EFBFBD>˳<EFBFBD><CBB3>ȡ<EFBFBD><C8A1><EFBFBD>ڿͻ<DABF><CDBB>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>
|
||
// !!!!!!!!!!!<21><EFBFBD>ö<EFBFBD>ٺǵö<C7B5>Ӧ<EFBFBD><EFBFBD>PixelFormatDescription _pixelFormats <20><> CommonCount<6E><74>iOSCount <20>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
class PixelFormat
|
||
{
|
||
public:
|
||
/// enums
|
||
enum Code
|
||
{
|
||
// begin common
|
||
X8R8G8B8 = 0,
|
||
R8G8B8,
|
||
B8G8R8,
|
||
B8G8R8A8,
|
||
R8G8B8A8,
|
||
A8B8G8R8,
|
||
A8R8G8B8,
|
||
R5G6B5,
|
||
A1R5G5B5,
|
||
A4R4G4B4,
|
||
DXT1,
|
||
DXT2,
|
||
DXT3,
|
||
DXT4,
|
||
DXT5,
|
||
R16F,
|
||
G16R16F,
|
||
A16B16G16R16F,
|
||
R32F,
|
||
G32R32F,
|
||
A32B32G32R32F,
|
||
A8,
|
||
L8,
|
||
L8A8, //[2012/4/12 zhongdaohuan] mygui <20>õ<EFBFBD><C3B5>ĸ<EFBFBD>ʽ
|
||
L16,
|
||
G16R16,
|
||
D24X8,
|
||
D24S8,
|
||
// end common CommonCount
|
||
|
||
// begin iPhone / PowerVR
|
||
PVRTC_RGB2,
|
||
PVRTC_RGBA2,
|
||
PVRTC_RGB4,
|
||
PVRTC_RGBA4,
|
||
// end iphone / PowerVR end iOSCount
|
||
|
||
//ETC
|
||
ETC1_RGB8,
|
||
|
||
NumPixelFormats,
|
||
InvalidPixelFormat,
|
||
DescPixelFormatsCount, // <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NumPixelFormats<74><73>InvalidPixelFormat<61><74>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BUG<55><47><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
// <20><>¼<EFBFBD>ֿ<EFBFBD><D6BF>ı<EFBFBD>־λ<D6BE><CEBB> <20><><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>֮<EFBFBD>ǵ<F3A3ACBC><C7B5><EFBFBD>
|
||
CommonCount = D24S8 + 1,
|
||
iOSCount = PVRTC_RGBA4 + 1,
|
||
|
||
};
|
||
|
||
/// From Ogre:
|
||
static bool IsCompressed(Code code);
|
||
|
||
/** From Ogre: Returns the size in bytes of an element of the given pixel format.
|
||
* GetNumElemBytes
|
||
* @param: Code code
|
||
* @return: SizeT
|
||
The size in bytes of an element. See Remarks.
|
||
* @see:
|
||
* @remark:
|
||
Passing PF_UNKNOWN will result in returning a size of 0 bytes.
|
||
*/
|
||
static SizeT GetNumElemBytes(Code code);
|
||
|
||
// From Ogre: Gives the masks for the R, G, B and A component. Only valid for native endian formats
|
||
static void GetBitMasks(Code format, uint32 rgba[4]);
|
||
|
||
// From Ogre: Gives the number of bits (RGBA) for a format. For non-colour formats (dxt, depth) this returns [0,0,0,0].
|
||
static void GetBitDepths(Code format, int rgba[4]);
|
||
|
||
// From Ogre:Returns the size in memory of a region with the given extents and pixel format with consecutive memory layout
|
||
static SizeT GetMemorySize(SizeT width, SizeT height, SizeT depth, Code format);
|
||
|
||
/// convert from string
|
||
static Code FromString(const Util::String& str);
|
||
/// convert to string
|
||
static Util::String ToString(Code code);
|
||
|
||
/** From Ogre: Returns the property flags for this pixel format
|
||
* GetFlags
|
||
* @param: Code format
|
||
* @return: unsigned int
|
||
A bitfield combination of PFF_HASALPHA, PFF_ISCOMPRESSED,
|
||
PFF_FLOAT, PFF_DEPTH, PFF_NATIVEENDIAN, PFF_LUMINANCE
|
||
* @see:
|
||
* @remark:
|
||
*/
|
||
static unsigned int GetFlags( Code format );
|
||
};
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
#endif // __PixelFormat_H__
|