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

📄 cengine.h

📁 S60 3D游戏引擎开发案例 S60 3D游戏引擎开发案例
💻 H
字号:
   /*
============================================================================
    * Name : CEngine.h
    * Part of : Example3D
    * Description : Definition of CEngine
    * Copyright (c) 2007 Nokia Corporation
============================================================================
    */

#ifndef __CENGINE_H__
#define __CENGINE_H__


// INCLUDES
#include <e32base.h>
#include <w32std.h>
#include "MGameTimerObserver.h"
#include "TBitmap.h"
#include "GLES/egl.h"
#include "GLES/gl.h"

// FORWARD DECLARATIONS
class CGameTimer;
class MGame;

// ENUMERATIONS

enum TDrawBuffer
	{
	EDoubleBuffered,		// direct screen write with double buffer
	EBitmapCopy,			// just blit screen with BitBlt
	ENoScreen				// No screen visible
	};


// CLASS DECLARATION

/**
*  CEngine is the game runner class and wrapper for symbian UI-classes
*  This class takes care of screen drawing, double buffering
*  timing and key events.
*  Uses CGameTimer for timing
*  Calls MGame derived game class
*/

class CEngine
	: public CBase
	, public MGameTimerObserver
	{
	public:

		/// Two-phased constructor
		/// @param aGc pointer to application's graphic context
		/// @param aWindow pointer to application's window
		/// @param aDisplayMode used screen color mode
		static CEngine* NewL( CWindowGc& aGc, RWindow& aWindow, TDisplayMode aDisplayMode );

		/// Destructor:
		~CEngine();

	private:
		
		/// Second-phase constructor
		void ConstructL();

		/// Default constructor
		/// @param aGc pointer to application's graphic context
		/// @param aWindow pointer to application's window
		/// @param aScreenSize physical screen size in pixels
		/// @param aDisplayMode used screen color mode
		CEngine( CWindowGc& aGc, RWindow& aWindow, TDisplayMode aDisplayMode );

	public: // MGameTimerObserver

		/// Game timer calls this function
		/// @return timer continue flag, 0 if timer is to stop.
		TInt DoGameFrameL();

	public: // New methods:
		
		/// Initializes screen with new draw rect
		/// @param aRect new draw rect
		void InitScreen( const TRect& aRect );


		/// Container updates key events here:
		/// @param aKeyEvent key event type
		/// @param aType key event code
		void KeyEvent( const TKeyEvent& aKeyEvent,TEventCode aType );

		/// starts updating engine
		void Start();

		/// stops updating engine
		void Stop();

		/// Receives command from application framework
		/// like change camera button
		void Command( TInt aCommand );

	private: // Data

		MGame*		iGame;					// pointer to game
		CGameTimer* iTimer;					// CIdle timer to run the engine

		CWindowGc&	iGc;
		RWindow&	iWindow;
		TRect		iDrawRect;				// Draw region on screen
		
		CFbsBitmap* iFbsBitmapBuffer;		// CFbsBitmap containing drawing screen
		TBitmapUtil*	iBitmapUtil;		// Only for bitmap locking

		TBitmap		iBuffer;				// CFbsBitmap wrapped to TBitmap type
		TBitmap		iScreen;				// TBitmap to direct screen memory

		TTime		iTime;					// time from start
		TInt		iUpdates;				// number of game "move"s

		TUint8		iKey[ 256 ];			// keyboard status
		TBool		iPaused;				// paused flag

		TDisplayMode		iDisplayMode;		// current display mode
		CFbsScreenDevice*	iFbsScreenDevice;	// screen device for direct screen flushing
		
		RFs					iFs;
		RFile				iFile;

		EGLDisplay      iGldisplay;
		EGLConfig       iGlconfig;
		EGLContext      iGlcontext;
		EGLSurface      iGlsurface;
	};


#endif

⌨️ 快捷键说明

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