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

📄 textureutils.h

📁 这是在s60第五版上用Open GL开发的软件
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
 * ==============================================================================
 *  Name        : Textureutils.h
 *
 *  Copyright (c) 2004-2006 Nokia Corporation.
 *  This material, including documentation and any related
 *  computer programs, is protected by copyright controlled by
 *  Nokia Corporation.
 * ==============================================================================
 */

#ifndef __TEXUTILS__
#define __TEXUTILS__

//  INCLUDE FILES

#include <fbs.h>
#include <e32base.h>
#include <e32std.h>
#include <e32math.h>
#include <w32std.h>
#include <eikenv.h>
#include <eikapp.h>
#include <eikappui.h>

#include <GLES/gl.h>      // OpenGL ES header file
#include <ImageConversion.h>
#include "Mathutils.h"



// MACROS

/** Texture name maximum length */
#define MAX_TEXTURE_NAME 20

// FORWARD DECLARATIONS

// =============================================================================
// =============================================================================

/**
 *  Abstract baseclass that implements basic finite state machine behaviour.
 */

class CFiniteStateMachine : public CBase
	{
	public: // Constructors and destructor
	    /** Factory method that constructs a CFiniteStateMachine by using the NewLC method and then cleans the cleanup stack. */
		static CFiniteStateMachine* NewL();
		/** Factory method that constructs a CFiniteStateMachine and leaves it to the cleanup stack. */
		static CFiniteStateMachine* NewLC();

        /** Destructor. Does nothing. */
		virtual ~CFiniteStateMachine();

	public: // New functions

		/*
		 * Sets the finite state machine's state to given state.
		 * pre-condition (aNewState != -1) : the value -1 should not be used to represent a state.
	 	 * @param aNewState Machine's next state.
		 */
		void SetStateL(TInt aNewState);

		/*
		* Returns the finite state machine's current state.
		* @return Current state.
		*/
		TInt GetCurrentState() const;

		/**
		* Returns the finite state machine's current state  (same as GetCurrentState())
		* @return Current state.
		*/
		TInt GetState() const;

		/**
		* Returns the finite state machine's previous state.
		* @return Current state.
		*/
		TInt GetPreviousState() const;

		/**
		 * This method is called when the finite state machine leaves the state aState
		 * @param aState State that was left.
		 */
		virtual void OnLeaveStateL( TInt aState );

		/**
		* This method is called when the finite state machine enters the state aState
		* @param aState State that was entered.
		*/
		virtual void OnEnterStateL( TInt aState );

	protected:
        /**
         * C++ default constructor. Initializes the current and previous states to -1.
         */
		CFiniteStateMachine();

		/**
		 * Symbian 2nd phase constructor. Initializes the current and previous states to -1.
         */
		virtual void ConstructL( void );


	private: // Data

		/** Current state. */
		TInt iState;
		/** Previous state. */
		TInt iPrevState;
	};

// =============================================================================
// =============================================================================

/**
 * Listener interface that can be used to listen for texture loading events from
 * CTextureManager.
 *
 * The class is intended to be implemented by a client class that observes the
 * texture loading operations of texture manager. The methods in this class
 * are called by the texture manager (class CTextureManager) during the loading
 * operations.
 *
 * Reference to implementations of this listener interface can be passed as
 * a parameter to the constructor of the texture manager (class CTextureManager).
 */
class MTextureLoadingListener
	{
	public:
		/** Called by the CTextureManager when it starts to load textures. */
		virtual void OnStartLoadingTexturesL() = 0;
		/** Called by the CTextureManager when it has loaded all the textures in the queue. */
		virtual void OnEndLoadingTexturesL() = 0;
	};


// =============================================================================
// =============================================================================

/**
 * This structure is used by the texture manager (class CTextureManager). It
 * stores information about a loaded texture or a texture about to be loaded.
 * The instance of this class must be created by the user of CTextureManager.
 * Optionally the iTextureHasColorKey and the related iMinColorKey and iMaxColorKey
 * fields can be set by the user before requesting the texture to be loaded.
 *
 * The iTextureName, iID, iTextureWidth and iTextureHeight fields are filled by the
 * texture manager upon loading the texture.
 */
struct TTexture
{
	/** Texture name (file name from which the texture has been loaded). */
	TBufC<MAX_TEXTURE_NAME> iTextureName;
	/** Unique ID that will be used to reference the texture through the glBindTexture() function. */
	GLuint iID;
	/** Indicates if this texture has some color key info. */
	TBool iTextureHasColorKey;
	/** Min. color key value. Only valid if field iTextureHasColorKey is true. */
	TUint8 iMinColorKey[3];
	/** Max. color key value. Only valid if field iTextureHasColorKey is true. */
	TUint8 iMaxColorKey[3];
	/** Width of the texture in pixels. */
	TInt iTextureWidth;
	/** Height of the texture in pixels. */
	TInt iTextureHeight;
	/** Mipmap generation flag. */
	TBool iGenerateMipmaps;

	//The following fields are used internally by the texture manager
	// to store this struct into a single linked list (class TSglQue).
	/** Do not change! Reserved for CTextureManager internal use! */
	static const TInt iOffset;
	/** Do not change! Reserved for CTextureManager internal use! */
	TSglQueLink iLink;
};

// =============================================================================
// =============================================================================

/**
 * Listener interface that can be used to listen for image loading operation
 * completion events from CImageHandler.
 *
 * The class is intended to be implemented by a client class that observes the
 * loading operation of image handler. The methods in this class
 * are called by the image handler (class CImageHandler) when it loads
 * an image.
 *
 * Reference to implementations of this listener interface can be passed as
 * a parameter to the constructor of the image handler (class CImageHandler).
 */
class MImageHandlerCallback
	{
	public: // New functions
		/**
		 * Called by CImageHandler when an image has been loaded.
		 * @param aError Error code given by the CImageHandler or 0 (zero) if the image was loaded successfully.
		 */
		virtual void ImageOperationCompleteL(TInt aError) = 0;
	};

// =============================================================================
// =============================================================================

/**
*  CImageHandler
*  Image loader class.
*/

class CImageHandler : public CActive
	{
	public: // Constructors and destructor
	    /** Factory method that constructs a CImageHandler by using the NewLC method and then cleans the cleanup stack. */
		static CImageHandler* NewL(CFbsBitmap* aBitmap, CFbsBitmap* aBitmapMask, RFs& aFs, MImageHandlerCallback& aCallback);
		/** Factory method that constructs a CImageHandler and leaves it to the cleanup stack. */
		static CImageHandler* NewLC(CFbsBitmap* aBitmap, CFbsBitmap* aBitmapMask, RFs& aFs, MImageHandlerCallback& aCallback);
        /** Desctructor. Destroys the CImageDecoder used by the image handler. */
		virtual ~CImageHandler();

	public: // New functions
		/**
		 * Sets the target bitmap where the bitmap data is loaded to.
         * @param aBitmap Bitmap where the image data is loaded to.
         * @param aBitmapMask Bitmap where the alpha channel data is loaded to.
		 * @return True if operation is successfull, false if not.
		 */
		TBool SetBitmapL( CFbsBitmap *aBitmap, CFbsBitmap *aBitmapMask );

		/**
		 * Loads a the given frame from the given file.
		 * @param aFileName Filename wherefrom the bitmap data is loaded.
		 * @param aSelectedFrame A single frame index in a multi-frame file. If not given the first frame is loaded.
	  	 */
		void LoadFileL(const TFileName& aFileName, TInt aSelectedFrame = 0);

		/**
		 * Returns the current frame information.
		 * @return Current frame information.
		 */
		const TFrameInfo& FrameInfo() const;

	private: // Functions from base classes

		/**
		 * CActive::RunL() implementation. Called on image load success/failure.
		 */
		void RunL();
		/**
		 * CActive::Cancel() implementation. Stops decoding.
		 */
		void DoCancel();

	protected:
        /**
         * C++ default constructor. Just stores the given parameters to corresponding attributes.
         * @param aBitmap Bitmap where the image data is loaded to.
         * @param aFs File server reference that is used to load the image data.
         * @param aCallback Listener interface implementation that is notified when an image has been loaded.
         */
		CImageHandler(CFbsBitmap *aBitmap, CFbsBitmap *aBitmapMask, RFs &aFs, MImageHandlerCallback &aCallback);
        /**
         * 2nd phase constructor. Adds this object to the active scheduler.
         */
		void ConstructL();

	private: // Data
		/** Image decoder that is used to load the image data from file. */
		CImageDecoder* iDecoder;

⌨️ 快捷键说明

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