⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 surfaceformat.h

📁 这个是symbian下的一个蛮庞大的3D游戏源代码!对于学习3D开发的人有很大的帮助!
💻 H
字号:
#ifndef _GR_SURFACEFORMAT_H
#define _GR_SURFACEFORMAT_H


#include <stdint.h>


namespace gr
{


/** 
 * Description of surface pixel bit layout.
 * Supports also conversions between pixel formats.
 * 
 * @ingroup gr
 */
class SurfaceFormat
{
public:
	/** 
	 * Type of surface pixel format.
	 */
	enum SurfaceFormatType
	{
		/** The surface format is unknown. */
		SURFACE_UNKNOWN,
		/** 24-bit RGB pixel format. */
		SURFACE_R8G8B8,
		/** 24-bit RGB pixel format. */
		SURFACE_B8G8R8,
		/** 32-bit RGB pixel format with alpha. */
		SURFACE_A8R8G8B8,
		/** 32-bit RGB pixel format where 8 bits are reserved for each color. */
		SURFACE_X8R8G8B8,
		/** 32-bit RGB pixel format where 8 bits are reserved for each color.  */
		SURFACE_X8B8G8R8,
		/** 32-bit RGB pixel format with alpha.  */
		SURFACE_A8B8G8R8,
		/** 16-bit RGB pixel format. (PS2) */
		SURFACE_R5G6B5,
		/** 16-bit RGB pixel format. */
		SURFACE_R5G5B5,
		/** 4-bit palettized pixel format. (PC/PS2) */
		SURFACE_P4,
		/** 8-bit palettized pixel format. (PC/PS2)	*/
		SURFACE_P8,
		/** 16-bit pixel format where 5 bits are reserved for color and 1 bit is reserved for transparency. */
		SURFACE_A1R5G5B5,
		/** 16-bit RGB pixel format where 4 bits are reserved for each color. */
		SURFACE_X4R4G4B4,
		/** 16-bit RGB pixel format. */
		SURFACE_A4R4G4B4,
		/** 16-bit pixel format where 5 bits are reserved for color and 1 bit is reserved for transparency. */
		SURFACE_A1B5G5R5,
		/** 8-bit RGB texture format. (PS2) */
		SURFACE_R3G3B2,
		/** 8-bit RGB texture format. */
		SURFACE_R3G2B3,
		/** 8-bit alpha-only. */
		SURFACE_A8,
		/** 16-bit RGB pixel format with alpha.	*/
		SURFACE_A8R3G3B2,
		/** 16-bit RGB pixel format with alpha.	*/
		SURFACE_A8R3G2B3,
		/** Surface format list terminator */
		SURFACE_LAST,
	};

	/**
	 * Creates surface format of SURFACE_UNKNOWN type.
	 */
	SurfaceFormat();

	/**
	 * Creates surface format from enumerated pixel format type. 
	 */
	SurfaceFormat( SurfaceFormatType type );

	/**
	 * Creates a surface format from bit count and 4 masks. 
	 * Format is set to SURFACE_UNKNOWN if match not found.
	 */
	SurfaceFormat( int bitCount, uint32_t redMask, uint32_t greenMask, uint32_t blueMask, uint32_t alphaMask );

	/**
	 * Returns type of surface format. 
	 */
	SurfaceFormatType	type() const;

	/** 
	 * Returns number of bits per pixel in the surface format.
	 * Returns 0 if the format is unknown or compressed.
	 */
	int			bitsPerPixel() const;

	/**
	 * Returns number of palette entries in this pixel format.
	 * @return Number of palette entries or 0 if the format is not palettized.
	 */
	int 		paletteEntries() const;

	/**
	 * Returns true if this is palettized pixel format. 
	 */
	bool		palettized() const		{return m_type == SURFACE_P8 || m_type == SURFACE_P4;}

	/** 
	 * Copies pixels from one surface pixel format to another.
	 * Only valid for non-compressed formats.
	 *
	 * Usage example: (copy pixels from format RGBA8888 to RGB565)
	 * <pre>
	   SurfaceFormat dstf( SURFACE_R5G6B5 );
	   dstf.copyPixels( dst, SURFACE_A8R8G8B8, src, pixels );
	   </pre>
	 */
	void		copyPixels( void* dst, const SurfaceFormat& dstpalfmt, const void* dstpal,
					const SurfaceFormat& srcfmt, const void* src, const SurfaceFormat& srcpalfmt, const void* srcpal, 
					int pixels ) const;

	/** Returns string description of the format. */
	const char*	toString() const;

private:
	SurfaceFormatType m_type;
};


} // gr


#endif // _GR_SURFACEFORMAT_H


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -