My Project
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ParaEngine::CParaEngineApp Class Reference

This class demonstrate how to initialize, destroy and drive the game loop of ParaEngine through the C++ programming interface. More...

#include <ParaEngineApp.h>

Inheritance diagram for ParaEngine::CParaEngineApp:
ParaEngine::CParaEngineAppBase ParaEngine::CParaEngineAppBase CD3DApplication ParaEngine::CParaEngineAppBase ParaEngine::IObject ParaEngine::CCommandLineParams ParaEngine::IParaEngineApp ParaEngine::IObject ParaEngine::CCommandLineParams ParaEngine::IParaEngineApp ParaEngine::IObject ParaEngine::CCommandLineParams ParaEngine::IParaEngineApp

Public Member Functions

 CParaEngineApp (const char *lpCmdLine)
 start the application immediately, it calls StartApp with the given command line. More...
 
 CParaEngineApp ()
 One needs to manually start the application.
 
virtual int Run (HINSTANCE hInstance)
 only call this function if one does not want to manage game loop externally. More...
 
bool IsDebugBuild ()
 whether it is debug build. More...
 
virtual HRESULT DoWork ()
 this function is called per frame, in most cases, it will render the 3d scene and frame move. More...
 
virtual void EnablePassiveRendering (bool bEnable)
 passive rendering, it will not render the scene, but simulation and time remains the same. More...
 
virtual bool IsPassiveRenderingEnabled ()
 passive rendering, it will not render the scene, but simulation and time remains the same. More...
 
virtual void Enable3DRendering (bool bEnable)
 disable 3D rendering, do not present the scene. More...
 
virtual bool Is3DRenderingEnabled ()
 whether 3D rendering is enabled, do not present the scene. More...
 
virtual void SetFullScreenMode (bool bFullscreen)
 whether to use full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device. More...
 
virtual bool IsFullScreenMode ()
 
virtual void BringWindowToTop ()
 The BringWindowToTop current window to the top of the Z order. More...
 
virtual void SetAllowWindowClosing (bool bAllowClosing)
 whether the user can close the window (sending WM_CLOSE message). More...
 
virtual bool IsWindowClosingAllowed ()
 
virtual void ShowMenu (bool bShow)
 turn on/off menu
 
virtual void GetScreenResolution (Vector2 *pOut)
 change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device. More...
 
virtual void SetScreenResolution (const Vector2 &vSize)
 
virtual void GetResolution (float *pX, float *pY)
 change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device. More...
 
virtual void SetResolution (float x, float y)
 
virtual int GetMultiSampleType ()
 anti-aliasing for both windowed and full screen mode. More...
 
virtual void SetMultiSampleType (int nType)
 
virtual int GetMultiSampleQuality ()
 anti-aliasing for both windowed and full screen mode. More...
 
virtual void SetMultiSampleQuality (int nType)
 
virtual bool UpdateScreenMode ()
 call this function to update changes of FullScreen Mode and Screen Resolution. More...
 
virtual bool SetWindowedMode (bool bWindowed)
 switch to either windowed mode or full screen mode. More...
 
virtual bool IsWindowedMode ()
 return true if it is currently under windowed mode. More...
 
virtual void SetWindowText (const char *pChar)
 set the window title when at windowed mode
 
virtual const char * GetWindowText ()
 get the window title when at windowed mode
 
virtual void FixWindowSize (bool fixed)
 
virtual void GetStats (string &output, DWORD dwFields=0)
 get the render engine stats to output. More...
 
bool WriteRegStr (const string &root_key, const string &sSubKey, const string &name, const string &value)
 Write a string to the registry. More...
 
const char * ReadRegStr (const string &root_key, const string &sSubKey, const string &name)
 Read string from the registry. More...
 
bool WriteRegDWORD (const string &root_key, const string &sSubKey, const string &name, DWORD value)
 Write a DWORD to the registry. More...
 
DWORD ReadRegDWORD (const string &root_key, const string &sSubKey, const string &name)
 Read DWORD from the registry. More...
 
virtual void GetCursorPosition (int *pX, int *pY, bool bInBackbuffer=true)
 get the current mouse cursor position. More...
 
virtual void GameToClient (int &inout_x, int &inout_y, bool bInBackbuffer=true)
 translate a position from game coordination system to client window position. More...
 
virtual void ClientToGame (int &inout_x, int &inout_y, bool bInBackbuffer=true)
 translate a position from client window position to game coordination system. More...
 
virtual void WriteConfigFile (const char *sFileName)
 write the current setting to config file. More...
 
virtual bool HasNewConfig ()
 get whether ParaEngine is loaded from config/config.new.txt. More...
 
virtual void SetHasNewConfig (bool bHasNewConfig)
 set whether ParaEngine is loaded from config/config.new.txt. More...
 
virtual void SetIgnoreWindowSizeChange (bool bIgnoreSizeChange)
 switch to ignore windows size change. More...
 
virtual bool GetIgnoreWindowSizeChange ()
 return true if it is currently under windowed mode. More...
 
virtual bool ForceRender ()
 render the current frame and does not return until everything is presented to screen. More...
 
HRESULT OnCreateWindow ()
 this function should be called when the application is created. More...
 
HRESULT ConfirmDevice (LPDIRECT3D9 pD3d, D3DCAPS9 *, DWORD, D3DFORMAT, D3DFORMAT)
 Called during device initialization, this code checks the device for some minimum set of capabilities, and rejects those that don't pass by returning false. More...
 
HRESULT Init (HWND *pHWND)
 init application More...
 
HRESULT OneTimeSceneInit ()
 This function should be called only once when the application start, one can initialize game objects here. More...
 
virtual HRESULT InitDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has been created, which will happen during application initialization and windowed/full screen toggles. More...
 
virtual HRESULT RestoreDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has been reset, which will happen after a lost device scenario. More...
 
virtual HRESULT Render ()
 This callback function will be called at the end of every frame to perform all the rendering calls for the scene, and it will also be called if the window needs to be repainted. More...
 
void GenerateD3DDebugString ()
 Output text information to console, for debugging only. More...
 
virtual HRESULT FrameMove ()
 This callback function will be called once at the beginning of every frame. More...
 
virtual HRESULT FrameMove (double fTime)
 Called once per frame, the call is the entry point for animating the scene. More...
 
virtual HRESULT InvalidateDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has entered a lost state and before IDirect3DDevice9::Reset is called. More...
 
virtual HRESULT DeleteDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has been destroyed, which generally happens as a result of application termination or windowed/full screen toggles. More...
 
virtual HRESULT FinalCleanup ()
 This function should be called only once when the application end, one can destroy game objects here. More...
 
void HandleUserInput ()
 process game input. More...
 
virtual void SetMainWindow (HWND hWnd, bool bIsExternalWindow=true)
 set the hWnd on to which we will render and process window messages. More...
 
virtual HWND GetMainWindow ()
 
virtual HRESULT StartApp (const char *sCommandLine=0)
 call this function to create the ParaEngine main rendering device based on the current window. More...
 
void InitSystemModules ()
 
void InitWin3DSettings ()
 
void InitLogger ()
 
void BootStrapAndLoadConfig ()
 
void InitApp (const char *sCommandLine)
 
bool CheckClientLicense ()
 
void LoadAndApplySettings ()
 
virtual HRESULT StopApp ()
 This is the last function that should be called. More...
 
virtual LRESULT MsgProcWinThread (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool bCallDefProcedure=true)
 the window message processor. More...
 
virtual LRESULT MsgProcWinThreadCustom (UINT uMsg, WPARAM wParam, LPARAM lParam)
 
virtual LRESULT SendMessageToApp (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 Send a RAW win32 message the application to be processed in the next main thread update interval. More...
 
virtual bool PostWinThreadMessage (UINT uMsg, WPARAM wParam, LPARAM lParam)
 post a raw win32 message from any thread to the thread on which hWnd is created. More...
 
virtual bool GetMessageFromApp (CWinRawMsg *pMsg)
 get a message from the application message queue and remove it from the queue. More...
 
virtual LRESULT MsgProcApp (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 Before handling window messages, application should pass incoming windows messages to the application through this callback function. More...
 
virtual HRESULT Create (HINSTANCE hInstance=0)
 create instance
 
virtual HRESULT CreateFromD3D9Device (IDirect3DDevice9 *pD3dDevice, IDirect3DSwapChain9 *apSwapChain)
 
virtual HRESULT Render3DEnvironment (bool bForceRender=false)
 Frame move and render a frame during idle time (no messages are waiting). More...
 
virtual float GetFPS ()
 
void UpdateFrameStats (double fTime)
 
virtual HINSTANCE GetModuleHandle ()
 change the cursor to indicate a movie recording state More...
 
virtual void SetRefreshTimer (float fTimeInterval, int nFrameRateControl=0)
 Set the frame rate timer interval. More...
 
virtual float GetRefreshTimer ()
 get the refresh timer.
 
virtual void GetWindowCreationSize (int *pWidth, int *pHeight)
 get the window creation size in default application config. More...
 
virtual PEAppState GetAppState ()
 get application state
 
virtual void SetAppState (ParaEngine::PEAppState state)
 set application state
 
virtual void ActivateApp (bool bActivate)
 this function is called whenever the application is disabled or enabled. More...
 
virtual bool IsAppActive ()
 whether the application is active or not. More...
 
virtual DWORD GetCoreUsage ()
 Get the current ParaEngine app usage. More...
 
virtual void SetCoreUsage (DWORD dwUsage)
 Set the current ParaEngine app usage. More...
 
virtual void SetMinUIResolution (int nWidth, int nHeight, bool bAutoUIScaling=true)
 set the minimum UI resolution size. More...
 
virtual void Exit (int nReturnCode=0)
 Send the exit message, so that the game engine will prepare to exit in the next frame. More...
 
virtual bool HasFocus (HWND hWnd=0)
 this returns true if the main window or one of its child window has key focus. More...
 
virtual bool IsTouchInputting ()
 whether the last mouse input is from touch or mouse. More...
 
virtual bool IsSlateMode ()
 
virtual int32 GetTouchPointX ()
 obsoleted function:
 
virtual int32 GetTouchPointY ()
 
virtual bool IsServerMode ()
 server mode has no user interface
 
void SetAutoLowerFrameRateWhenNotFocused (bool bEnabled)
 default to false. if true, we will lower frame rate when the window is not focused.
 
bool GetAutoLowerFrameRateWhenNotFocused ()
 
void SetToggleSoundWhenNotFocused (bool bEnabled)
 if true, sound volume will be set to 0, when not focused.
 
bool GetToggleSoundWhenNotFocused ()
 
bool AppHasFocus ()
 return true if app has focus. More...
 
CViewportManagerGetViewportManager ()
 managing multiple 3d views
 
 CParaEngineApp (const char *lpCmdLine=NULL)
 
virtual HRESULT StartApp (const char *sCommandLine=0)
 This is the first function that should be called when acquiring the IParaEngineApp interface. More...
 
virtual void InitSystemModules ()
 
void BootStrapAndLoadConfig ()
 
virtual HRESULT StopApp ()
 This is the last function that should be called. More...
 
virtual void SetMainWindow (HWND hWnd, bool bIsExternalWindow=true)
 set the hWnd on to which we will render and process window messages. More...
 
virtual HWND GetMainWindow ()
 
virtual int Run (HINSTANCE hInstance)
 only call this function if one does not want to manage game loop externally. More...
 
virtual HRESULT DoWork ()
 this function is called per frame, in most cases, it will render the 3d scene and frame move. More...
 
virtual HRESULT CreateFromD3D9Device (IDirect3DDevice9 *pD3dDevice, IDirect3DSwapChain9 *apSwapChain)
 create from an existing d3d device. More...
 
virtual HRESULT InitDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has been created, which will happen during application initialization and windowed/full screen toggles. More...
 
virtual HRESULT RestoreDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has been reset, which will happen after a lost device scenario. More...
 
virtual HRESULT InvalidateDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has entered a lost state and before IDirect3DDevice9::Reset is called. More...
 
virtual HRESULT DeleteDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has been destroyed, which generally happens as a result of application termination or windowed/full screen toggles. More...
 
virtual HRESULT Create (HINSTANCE hInstance=0)
 create d3d render device based on the current main window. More...
 
virtual HRESULT Render3DEnvironment (bool bForceRender=false)
 Frame move and render a frame during idle time (no messages are waiting). More...
 
void UpdateStats (double fTime)
 
virtual LRESULT MsgProcWinThread (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool bCallDefProcedure=true)
 the window message processor. More...
 
virtual LRESULT MsgProcWinThreadCustom (UINT uMsg, WPARAM wParam, LPARAM lParam)
 
virtual LRESULT SendMessageToApp (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 Send a RAW win32 message the application to be processed in the next main thread update interval. More...
 
virtual bool PostWinThreadMessage (UINT uMsg, WPARAM wParam, LPARAM lParam)
 post a raw win32 message from any thread to the thread on which hWnd is created. More...
 
virtual bool GetMessageFromApp (CWinRawMsg *pMsg)
 get a message from the application message queue and remove it from the queue. More...
 
virtual LRESULT MsgProcApp (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 handle a message in the main application thread.
 
virtual void EnablePassiveRendering (bool bEnable)
 passive rendering, it will not render the scene, but simulation and time remains the same. More...
 
virtual bool IsPassiveRenderingEnabled ()
 passive rendering, it will not render the scene, but simulation and time remains the same. More...
 
virtual void BringWindowToTop ()
 The BringWindowToTop current window to the top of the Z order. More...
 
virtual void SetAllowWindowClosing (bool bAllowClosing)
 whether the user can close the window (sending WM_CLOSE message). More...
 
virtual bool IsWindowClosingAllowed ()
 
virtual void SetFullScreenMode (bool bFullscreen)
 whether to use full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device. More...
 
virtual bool IsFullScreenMode ()
 
virtual void ShowMenu (bool bShow)
 turn on/off menu
 
virtual Vector2 GetScreenResolution ()
 change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device. More...
 
virtual void SetScreenResolution (const Vector2 &vSize)
 
virtual int GetMultiSampleType ()
 anti-aliasing for both windowed and full screen mode. More...
 
virtual void SetMultiSampleType (int nType)
 
virtual int GetMultiSampleQuality ()
 anti-aliasing for both windowed and full screen mode. More...
 
virtual void SetMultiSampleQuality (int nType)
 
virtual bool UpdateScreenMode ()
 call this function to update changes of FullScreen Mode and Screen Resolution. More...
 
virtual bool SetWindowedMode (bool bWindowed)
 switch to either windowed mode or full screen mode. More...
 
virtual bool IsWindowedMode ()
 return true if it is currently under windowed mode. More...
 
virtual void SetWindowText (const char *pChar)
 set the window title when at windowed mode
 
virtual const char * GetWindowText ()
 get the window title when at windowed mode
 
virtual void WriteConfigFile (const char *sFileName)
 write the current setting to config file. More...
 
virtual bool HasNewConfig ()
 get whether ParaEngine is loaded from config/config.new.txt. More...
 
virtual void SetHasNewConfig (bool bHasNewConfig)
 set whether ParaEngine is loaded from config/config.new.txt. More...
 
virtual void GetWindowCreationSize (int *pWidth, int *pHeight)
 get the window creation size in default application config. More...
 
virtual bool IsAppActive ()
 whether the application is active or not. More...
 
virtual void SetMinUIResolution (int nWidth, int nHeight, bool bAutoUIScaling=true)
 set the minimum UI resolution size. More...
 
virtual void GetResolution (float *pX, float *pY)
 change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device. More...
 
virtual void SetResolution (float x, float y)
 
virtual NPL::INPLRuntimeGetNPLRuntime ()
 get the NPL runtime system associate with the application. More...
 
virtual bool IsSlateMode ()
 
virtual bool IsServerMode ()
 server mode has no user interface
 
virtual float GetFPS ()
 
HRESULT Init (HWND *pHWND)
 init application
 
void InitAudioEngine ()
 
HRESULT OneTimeSceneInit (HWND *pHWND)
 This function should be called only once when the application start, one can initialize game objects here. More...
 
virtual HRESULT FrameMove (double fTime)
 This callback function will be called once at the beginning of every frame. More...
 
HRESULT FinalCleanup ()
 This function should be called only once when the application end, one can destroy game objects here.
 
void HandleUserInput ()
 process game input. More...
 
virtual void Exit (int nReturnCode=0)
 Send the exit message, so that the game engine will prepare to exit in the next frame. More...
 
virtual ParaEngine::PEAppState GetAppState ()
 get application state
 
virtual void SetAppState (ParaEngine::PEAppState state)
 set application state
 
CViewportManagerGetViewportManager ()
 
 CParaEngineApp (const char *lpCmdLine=NULL)
 
virtual HRESULT StartApp (const char *sCommandLine=0)
 This is the first function that should be called when acquiring the IParaEngineApp interface. More...
 
virtual void InitSystemModules ()
 
void LoadAndApplySettings ()
 
void BootStrapAndLoadConfig ()
 
virtual HRESULT StopApp ()
 This is the last function that should be called. More...
 
virtual void SetMainWindow (HWND hWnd, bool bIsExternalWindow=true)
 set the hWnd on to which we will render and process window messages. More...
 
virtual HWND GetMainWindow ()
 
virtual int Run (HINSTANCE hInstance)
 only call this function if one does not want to manage game loop externally. More...
 
virtual HRESULT DoWork ()
 this function is called per frame, in most cases, it will render the 3d scene and frame move. More...
 
virtual HRESULT CreateFromD3D9Device (IDirect3DDevice9 *pD3dDevice, IDirect3DSwapChain9 *apSwapChain)
 create from an existing d3d device. More...
 
virtual HRESULT InitDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has been created, which will happen during application initialization and windowed/full screen toggles. More...
 
virtual HRESULT RestoreDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has been reset, which will happen after a lost device scenario. More...
 
virtual HRESULT InvalidateDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has entered a lost state and before IDirect3DDevice9::Reset is called. More...
 
virtual HRESULT DeleteDeviceObjects ()
 This callback function will be called immediately after the Direct3D device has been destroyed, which generally happens as a result of application termination or windowed/full screen toggles. More...
 
virtual HRESULT Create (HINSTANCE hInstance=0)
 create d3d render device based on the current main window. More...
 
virtual HRESULT Render3DEnvironment (bool bForceRender=false)
 Frame move and render a frame during idle time (no messages are waiting). More...
 
void UpdateStats (double fTime)
 
virtual LRESULT MsgProcWinThread (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool bCallDefProcedure=true)
 the window message processor. More...
 
virtual LRESULT MsgProcWinThreadCustom (UINT uMsg, WPARAM wParam, LPARAM lParam)
 
virtual LRESULT SendMessageToApp (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 Send a RAW win32 message the application to be processed in the next main thread update interval. More...
 
virtual bool PostWinThreadMessage (UINT uMsg, WPARAM wParam, LPARAM lParam)
 post a raw win32 message from any thread to the thread on which hWnd is created. More...
 
virtual bool GetMessageFromApp (CWinRawMsg *pMsg)
 get a message from the application message queue and remove it from the queue. More...
 
virtual LRESULT MsgProcApp (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 handle a message in the main application thread.
 
virtual void EnablePassiveRendering (bool bEnable)
 passive rendering, it will not render the scene, but simulation and time remains the same. More...
 
virtual bool IsPassiveRenderingEnabled ()
 passive rendering, it will not render the scene, but simulation and time remains the same. More...
 
virtual void BringWindowToTop ()
 The BringWindowToTop current window to the top of the Z order. More...
 
virtual void SetAllowWindowClosing (bool bAllowClosing)
 whether the user can close the window (sending WM_CLOSE message). More...
 
virtual bool IsWindowClosingAllowed ()
 
virtual void SetFullScreenMode (bool bFullscreen)
 whether to use full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device. More...
 
virtual bool IsFullScreenMode ()
 
virtual void ShowMenu (bool bShow)
 turn on/off menu
 
virtual Vector2 GetScreenResolution ()
 change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device. More...
 
virtual void SetScreenResolution (const Vector2 &vSize)
 
virtual int GetMultiSampleType ()
 anti-aliasing for both windowed and full screen mode. More...
 
virtual void SetMultiSampleType (int nType)
 
virtual int GetMultiSampleQuality ()
 anti-aliasing for both windowed and full screen mode. More...
 
virtual void SetMultiSampleQuality (int nType)
 
virtual bool UpdateScreenMode ()
 call this function to update changes of FullScreen Mode and Screen Resolution. More...
 
virtual bool SetWindowedMode (bool bWindowed)
 switch to either windowed mode or full screen mode. More...
 
virtual bool IsWindowedMode ()
 return true if it is currently under windowed mode. More...
 
virtual void SetWindowText (const char *pChar)
 set the window title when at windowed mode
 
virtual const char * GetWindowText ()
 get the window title when at windowed mode
 
virtual void FixWindowSize (bool fixed)
 
virtual void WriteConfigFile (const char *sFileName)
 write the current setting to config file. More...
 
virtual bool HasNewConfig ()
 get whether ParaEngine is loaded from config/config.new.txt. More...
 
virtual void SetHasNewConfig (bool bHasNewConfig)
 set whether ParaEngine is loaded from config/config.new.txt. More...
 
virtual void GetWindowCreationSize (int *pWidth, int *pHeight)
 get the window creation size in default application config. More...
 
virtual bool IsAppActive ()
 whether the application is active or not. More...
 
virtual void SetMinUIResolution (int nWidth, int nHeight, bool bAutoUIScaling=true)
 set the minimum UI resolution size. More...
 
virtual void GetResolution (float *pX, float *pY)
 change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device. More...
 
virtual void SetResolution (float x, float y)
 
virtual NPL::INPLRuntimeGetNPLRuntime ()
 get the NPL runtime system associate with the application. More...
 
virtual bool IsSlateMode ()
 
virtual bool IsServerMode ()
 server mode has no user interface
 
virtual float GetFPS ()
 
HRESULT Init (HWND *pHWND)
 init application
 
void InitAudioEngine ()
 
HRESULT OneTimeSceneInit (HWND *pHWND)
 This function should be called only once when the application start, one can initialize game objects here. More...
 
virtual HRESULT FrameMove (double fTime)
 This callback function will be called once at the beginning of every frame. More...
 
HRESULT FinalCleanup ()
 This function should be called only once when the application end, one can destroy game objects here.
 
void HandleUserInput ()
 process game input. More...
 
virtual void Exit (int nReturnCode=0)
 Send the exit message, so that the game engine will prepare to exit in the next frame. More...
 
virtual ParaEngine::PEAppState GetAppState ()
 get application state
 
virtual void SetAppState (ParaEngine::PEAppState state)
 set application state
 
CViewportManagerGetViewportManager ()
 
bool IsDebugBuild ()
 whether it is debug build. More...
 
void handle_mainloop_timer (const boost::system::error_code &err)
 
int CalculateRenderTime (double fIdealInterval, double *pNextInterval)
 return true if this is a render tick, otherwise false. More...
 
bool IsKeyPressed (DWORD nKey)
 return true if the key is being pressed at the time of calling. More...
 
virtual float GetRefreshTimer ()
 get the refresh timer.
 
virtual void SetRefreshTimer (float fTimeInterval, int nFrameRateControl=0)
 Set the frame rate timer interval. More...
 
void InitApp (const char *sCommandLine)
 
bool WriteRegStr (const string &root_key, const string &sSubKey, const string &name, const string &value)
 Write a string to the registry. More...
 
const char * ReadRegStr (const string &root_key, const string &sSubKey, const string &name)
 Read string from the registry. More...
 
bool WriteRegDWORD (const string &root_key, const string &sSubKey, const string &name, DWORD value)
 Write a DWORD to the registry. More...
 
DWORD ReadRegDWORD (const string &root_key, const string &sSubKey, const string &name)
 Read DWORD from the registry. More...
 
- Public Member Functions inherited from ParaEngine::CParaEngineAppBase
 CParaEngineAppBase (const char *sCmd)
 
virtual LifetimeType LifetimeControl ()
 
virtual BaseInterfaceAcquireInterface ()
 
virtual void ReleaseInterface ()
 
virtual void DeleteInterface ()
 
virtual void OnFrameEnded ()
 call this function at the end of the frame. More...
 
void DoTestCode ()
 
virtual void WriteToLog (const char *sFormat,...)
 append text to log file. More...
 
virtual void AppLog (const char *sFormat)
 write app log to file with time and code location. More...
 
virtual bool FindParaEngineDirectory (const char *sHint=NULL)
 set the current working directory. More...
 
void AutoSetLocale ()
 
virtual void SetTouchInputting (bool bTouchInputting)
 whether the last mouse input is from touch or mouse. More...
 
virtual void SetReturnCode (int nReturnCode)
 Get the exit code that will be used when the standalone executable exit. More...
 
virtual int GetReturnCode ()
 
virtual void SystemMessageBox (const std::string &msg)
 show a system message box to the user. More...
 
virtual void SetAppCommandLine (const char *pCommandLine)
 set string specifying the command line for the application, excluding the program name. More...
 
virtual const char * GetAppCommandLine ()
 get string specifying the command line for the application, excluding the program name. More...
 
virtual const char * GetAppCommandLineByParam (const char *pParam, const char *defaultValue)
 return a specified parameter value in the command line of the application. More...
 
virtual CRefCountedAddToSingletonReleasePool (CRefCounted *pObject)
 we will automatically release singleton object when app stops, in the verse order when object is added to the pool.
 
virtual bool HasClosingRequest ()
 whether there is closing request in the message queue. More...
 
virtual void SetHasClosingRequest (bool val)
 
virtual bool LoadNPLPackage (const char *sFilePath, std::string *pOutMainFile=NULL)
 load NPL package from a disk folder. More...
 
virtual bool FindBootStrapper ()
 check if there is bootstrapper file specified at command line, if not it will use NPL code wiki admin app.
 
virtual bool InitCommandLineParams ()
 parse common command line parameters
 
virtual const char * GetModuleDir ()
 get the NPL bin directory (main executable directory). More...
 
CViewportManagerGetViewportManager ()
 managing multiple 3d views
 
virtual void VerifyCommandLine (const char *sCommandLine, std::string &strCmd)
 
- Public Member Functions inherited from ParaEngine::BaseInterface
BaseInterfaceGetInterface (Interface_ID id)
 
virtual Interface_ID GetID ()
 
virtual BaseInterfaceCloneInterface (void *remapDir=NULL)
 
- Public Member Functions inherited from ParaEngine::CCommandLineParams
 CCommandLineParams (const char *lpCmdLine)
 
const char * GetAppCommandLine ()
 get string specifying the command line for the application, excluding the program name. More...
 
const char * GetAppCommandLineByParam (const char *pParam, const char *defaultValue)
 return a specified parameter value in the command line of the application. More...
 
void SetAppCommandLine (const char *pCommandLine)
 set string specifying the command line for the application, excluding the program name. More...
 
- Public Member Functions inherited from ParaEngine::IObject
virtual void Clone (IObject *obj) const
 Clone the object's contains to a pointer. More...
 
virtual IObjectClone () const
 Clone the object's contains and return a pointer to the newly created object. More...
 
virtual bool Equals (const IObject *obj) const
 Compare the object with another object. More...
 
virtual const ITypeGetType () const
 
virtual std::string ToString () const
 
WeakPtr_typeGetWeakReference ()
 get weak reference object. More...
 
virtual int ProcessObjectEvent (const ObjectEvent &event)
 this function is only used to backward compatibility of ParaObject:AddEvent() function. More...
 
- Public Member Functions inherited from ParaEngine::CRefCounted
void addref () const
 add reference count of the object. More...
 
bool delref () const
 decrease reference count of the object. More...
 
int GetRefCount () const
 get the reference count
 
virtual int Release ()
 
CRefCountedAddToAutoReleasePool ()
 addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More...
 
- Public Member Functions inherited from CD3DApplication
virtual void Pause (bool bPause)
 
virtual bool IsPaused ()
 
HRESULT PresentScene ()
 force present the scene. More...
 
void EnablePassiveRendering (bool bEnable)
 
bool IsPassiveRenderingEnabled ()
 
void Enable3DRendering (bool bEnable)
 disable 3D rendering, do not present the scene. More...
 
bool Is3DRenderingEnabled ()
 whether 3D rendering is enabled, do not present the scene. More...
 
void SetRefreshTimer (float fTimeInterval, int nFrameRateControl=0)
 Set the frame rate timer interval. More...
 
float GetRefreshTimer () const
 get the refresh timer.
 
virtual HRESULT Create ()
 
ParaEngine::PEAppState GetAppState ()
 
void SetAppState (ParaEngine::PEAppState state)
 
bool IsExternalD3DDevice ()
 whether the d3d device is managed externally
 

Protected Member Functions

ITouchInputTranslatorLoadTouchInputPlug ()
 
void UpdateMouse ()
 
void UpdateKey ()
 
void UpdateMouse ()
 
- Protected Member Functions inherited from ParaEngine::CParaEngineAppBase
void InitCommon ()
 shared init called in constructor. More...
 
void DestroySingletons ()
 
void LoadPackages ()
 we will load all packages that matches the following pattern in the order given by their name, such that "main_001.pkg" is always loaded before "main_002.pkg" we will skip packages *_32bits.pkg when in 64bits; and skip *_64bits.pkg in 32bits; packages without above suffix will be loaded in both version.
 
void LoadPackagesInFolder (const std::string &sPkgFolder)
 
void RegisterObjectClass (IAttributeFields *pObject)
 register a given class. More...
 
void RegisterObjectClasses ()
 register any custom classes
 
- Protected Member Functions inherited from CD3DApplication
HRESULT DisplayErrorMsg (HRESULT hr, DWORD dwType)
 
bool FindBestWindowedMode (bool bRequireHAL, bool bRequireREF)
 
bool FindBestFullscreenMode (bool bRequireHAL, bool bRequireREF)
 
HRESULT LaunchReadme ()
 
HRESULT ChooseInitialD3DSettings ()
 
HRESULT Initialize3DEnvironment ()
 
HRESULT HandlePossibleSizeChange (bool bUpdateSizeOnly=false)
 this function is called whenever the main window size changes. More...
 
HRESULT Reset3DEnvironment ()
 
HRESULT ToggleFullscreen ()
 
HRESULT ForceWindowed ()
 
HRESULT UserSelectNewDevice ()
 
void Cleanup3DEnvironment ()
 
HRESULT Render3DEnvironment (bool bForceRender=false)
 frame move and render More...
 
virtual void BuildPresentParamsFromSettings ()
 
virtual HRESULT AdjustWindowForChange ()
 
virtual void UpdateStats ()
 
virtual HRESULT ConfirmDevice (D3DCAPS9 *, DWORD, D3DFORMAT, D3DFORMAT)
 
virtual bool UpdateViewPort ()
 update view port by backbuffer size. More...
 

Protected Attributes

HINSTANCE m_hInstance
 
ref_ptr< CGUIRootm_pGUIRoot
 2d gui root
 
ref_ptr< CSceneObjectm_pRootScene
 3d scene root object
 
ref_ptr< CViewportManagerm_pViewportManager
 viewport
 
ref_ptr< CParaWorldAssetm_pParaWorldAsset
 asset manager
 
CDirectKeyboardm_pKeyboard
 
float m_fAspectRatio
 
CAudioEnginem_pAudioEngine
 
bool m_bDrawReflection:1
 
bool m_bDisplayText:1
 
bool m_bDisplayHelp:1
 
bool m_bServerMode:1
 
bool m_bHasNewConfig:1
 
bool m_bAllowWindowClosing:1
 
bool m_bAutoLowerFrameRateWhenNotFocused:1
 
bool m_bToggleSoundWhenNotFocused:1
 
int m_nInitialGameEffectSet
 initial game effect setting to be loaded from the config file. More...
 
int m_nWindowedDesired
 1 window mode desired, 0 full screen mode desired, -1 if unknown. More...
 
bool m_bIsKeyEvent
 
bool m_bUpdateScreenDevice
 
std::string m_cmd
 
CWinRawMsgQueuem_pWinRawMsgQueue
 The thread safe message queue target for receiving messages from window thread. More...
 
DWORD m_dwWinThreadID
 the thread id of the main window thread. More...
 
DWORD m_dwCoreUsage
 the Core usage. More...
 
bool m_bAppHasFocus
 whether app has focus. More...
 
std::string m_sTitleString
 for debugging display
 
HWND m_hwndTopLevelWnd
 set foreground window
 
bool m_isSlateMode
 
int32 m_touchPointX
 
int32 m_touchPointY
 
float m_fFPS
 
ITouchInputTranslatorm_pTouchInput
 
ParaEngine::PEAppState m_nAppState
 
int m_nScreenWidth
 
int m_nScreenHeight
 
double m_fTime
 
bool m_bIsAppActive
 
std::string m_sWindowTitle
 
ref_ptr< CParaEngineGLViewm_pGLView
 
boost::asio::io_service m_main_io_service
 the main game loop
 
boost::asio::steady_timer m_main_timer
 the main timer that ticks 30 times a second
 
bool m_bQuit
 
bool m_bMainLoopExited
 
float m_fRefreshTimerInterval
 
HWND m_hWnd
 
bool m_bStartFullscreen
 
- Protected Attributes inherited from ParaEngine::CParaEngineAppBase
bool m_bEnable3DRendering
 
bool m_isTouching
 
bool m_hasClosingRequest
 
int m_nReturnCode
 the application exit code or return code. More...
 
CObjectAutoReleasePoolm_pSingletonReleasePool
 a pool of registered singleton object. More...
 
std::string m_sPackagesDir
 packages/ directory path
 
std::string m_sModuleDir
 bin/ module path
 
std::string m_sInitialWorkingDir
 initial working directory
 
PEAppState m_nAppState
 application state
 
- Protected Attributes inherited from ParaEngine::IObject
WeakPtr_type m_weak_reference
 
- Protected Attributes inherited from ParaEngine::CRefCounted
int m_refcount
 
- Protected Attributes inherited from CD3DApplication
CD3DEnumeration m_d3dEnumeration
 
CD3DSettings m_d3dSettings
 
bool m_bWindowed
 
bool m_bActive
 
bool m_bDeviceLost
 
bool m_bMinimized
 
bool m_bMaximized
 
bool m_bIgnoreSizeChange
 
bool m_bDeviceObjectsInited
 
bool m_bDeviceObjectsRestored
 
bool m_bFrameMoving
 
bool m_bSingleStep
 
bool m_bDisableD3D
 if this is true, the directX is not needed to run the application. More...
 
bool m_bPassiveRendering
 passive rendering, it will not render the scene, but simulation and time remains the same. Default is false
 
bool m_bEnable3DRendering
 whether to render 3d scene and present to screen.
 
D3DPRESENT_PARAMETERS m_d3dpp
 
HWND m_hWnd
 
HWND m_hWndFocus
 
HMENU m_hMenu
 
LPDIRECT3D9 m_pD3D
 
LPDIRECT3DDEVICE9 m_pd3dDevice
 
IDirect3DSwapChain9 * m_pd3dSwapChain
 
D3DCAPS9 m_d3dCaps
 
D3DSURFACE_DESC m_d3dsdBackBuffer
 
DWORD m_dwCreateFlags
 
DWORD m_dwWindowStyle
 
RECT m_rcWindowBounds
 
RECT m_rcWindowClient
 
int m_nClientWidth
 
int m_nClientHeight
 
double m_fTime
 
double m_fElapsedTime
 
FLOAT m_fFPS
 
TCHAR m_strDeviceStats [90]
 
TCHAR m_strFrameStats [90]
 
float m_fRefreshTimerInterval
 
int m_nFrameRateControl
 
TCHAR * m_strWindowTitle
 
DWORD m_dwCreationWidth
 
DWORD m_dwCreationHeight
 
bool m_bShowCursorWhenFullscreen
 
bool m_bClipCursorWhenFullscreen
 
bool m_bStartFullscreen
 
bool m_bCreateMultithreadDevice
 
bool m_bAllowDialogBoxMode
 
bool m_bIsExternalWindow
 whether the main rendering window is an externally provided window or not. More...
 
bool m_bIsExternalD3DDevice
 
ParaEngine::PEAppState m_nAppState
 application state
 

Additional Inherited Members

- Public Types inherited from ParaEngine::BaseInterface
enum  LifetimeType { noRelease, immediateRelease, wantsRelease, serverControlled }
 
- Public Types inherited from ParaEngine::IObject
typedef ParaEngine::weak_ptr< IObjectWeakPtr_type
 
- Static Public Member Functions inherited from ParaEngine::CParaEngineAppBase
static CParaEngineAppGetInstance ()
 the singleton application. More...
 
static void SetCurrentInstance (CParaEngineApp *pInstance)
 
- Static Protected Member Functions inherited from CD3DApplication
static bool ConfirmDeviceHelper (D3DCAPS9 *pCaps, VertexProcessingType vertexProcessingType, D3DFORMAT adapterFormat, D3DFORMAT backBufferFormat)
 
- Static Protected Attributes inherited from ParaEngine::CParaEngineAppBase
static CParaEngineAppg_pCurrentApp = NULL
 

Detailed Description

This class demonstrate how to initialize, destroy and drive the game loop of ParaEngine through the C++ programming interface.

Users can derive their main Windows application from this class. Note: paraengine is designed to be manipulated through the NPL scripting interface Currently,its C++ programming interface is not designed to be used from outside the core code. i.e. Users' ability to program through C++ API is restricted by the amount of source code unvailed to them.

this class can be regarded as sample code for writing your own ParaEngine games logics. This class is not engine specific, but it contains basic steps to establish a running environment of any paraEngine created games. For example: SceneObject, Environment and AI simulator are created here. Message handling, Timing and I/O are also processed partly here.

See also
ParaWorld::CMyD3DApplication Note for debugging: please see the macro comments

Users can derive their main Windows application from this class. Note: ParaEngine is designed to be manipulated through the NPL scripting interface Currently,its C++ programming interface is not designed to be used from outside the core code. i.e. Users' ability to program through C++ API is restricted by the amount of source code unvailed to them.

this class can be regarded as sample code for writing your own ParaEngine games logics. This class is not engine specific, but it contains basic steps to establish a running environment of any paraEngine created games. For example: SceneObject, Environment and AI simulator are created here. Message handling, Timing and I/O are also processed partly here.

See also
ParaWorld::CMyD3DApplication Note for debugging: please see the macro comments

Constructor & Destructor Documentation

§ CParaEngineApp() [1/3]

ParaEngine::CParaEngineApp::CParaEngineApp ( const char *  lpCmdLine)

start the application immediately, it calls StartApp with the given command line.

Parameters
lpCmdLinecommand line arguments. we support the following argument at the moment
  • bootstappper="config/bootstrapper.xml"

§ CParaEngineApp() [2/3]

ParaEngine::CParaEngineApp::CParaEngineApp ( const char *  lpCmdLine = NULL)
Parameters
lpCmdLinecommand line arguments. we support the following argument at the moment
  • bootstappper="config/bootstrapper.xml"

§ CParaEngineApp() [3/3]

ParaEngine::CParaEngineApp::CParaEngineApp ( const char *  lpCmdLine = NULL)
Parameters
lpCmdLinecommand line arguments. we support the following argument at the moment
  • bootstappper="config/bootstrapper.xml"

Member Function Documentation

§ ActivateApp()

void CParaEngineApp::ActivateApp ( bool  bActivate)
virtual

this function is called whenever the application is disabled or enabled.

usually called when receiving the WM_ACTIVATEAPP message. [main thread only]

Reimplemented from ParaEngine::CParaEngineAppBase.

§ AppHasFocus()

bool CParaEngineApp::AppHasFocus ( )

return true if app has focus.

Usually we will lower render frame move when app has lost focus in web browser mode.

§ BringWindowToTop() [1/3]

void CParaEngineApp::BringWindowToTop ( )
virtual

The BringWindowToTop current window to the top of the Z order.

This function only works if IsFullScreenMode() is false.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ BringWindowToTop() [2/3]

virtual void ParaEngine::CParaEngineApp::BringWindowToTop ( )
inlinevirtual

The BringWindowToTop current window to the top of the Z order.

This function only works if IsFullScreenMode() is false.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ BringWindowToTop() [3/3]

virtual void ParaEngine::CParaEngineApp::BringWindowToTop ( )
inlinevirtual

The BringWindowToTop current window to the top of the Z order.

This function only works if IsFullScreenMode() is false.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ CalculateRenderTime()

int ParaEngine::CParaEngineApp::CalculateRenderTime ( double  fIdealInterval,
double *  pNextInterval 
)

return true if this is a render tick, otherwise false.

Parameters
fIdealIntervalthe ideal interval (FPS) when this function will return true at ideal FPS.
pNextIntervalmain_loop timer interval.
Returns
frameDelta. if this is bigger than 0, we will render a frame.

tricky: run the main_loop as fast as possible at least 100FPS, so that FPS is more accurate.

define to output interval to log file to change timer implementation.

§ ClientToGame()

void CParaEngineApp::ClientToGame ( int &  inout_x,
int &  inout_y,
bool  bInBackbuffer = true 
)
virtual

translate a position from client window position to game coordination system.

Parameters
inout_xin and out
inout_yin and out
bInBackbufferif true, it will scale the output according to the ratio of back buffer and current window size.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ ConfirmDevice()

HRESULT CParaEngineApp::ConfirmDevice ( LPDIRECT3D9  pD3d,
D3DCAPS9 *  pCaps,
DWORD  dwBehavior,
D3DFORMAT  adapterFormat,
D3DFORMAT  backBufferFormat 
)

Called during device initialization, this code checks the device for some minimum set of capabilities, and rejects those that don't pass by returning false.

Called during device initialization, this code checks the device for some minimum set of capabilities.

TODO: Just for mouse picking, however, I am going to turn this out because I have managed to sidestep using GetTransform() function. GetTransform() is needed for mouse ray picking

Need to support post-pixel processing (for alpha blending)

Billboard uses alpha textures and/or straight alpha. Make sure the device supports them

Debugging vertex shaders requires either REF or software vertex processing and debugging pixel shaders requires REF.

Need to support vs 1.1 or use software vertex processing

Need to support A8R8G8B8 textures

Need to support A8 textures, if not tell the engine to use A8R8G8B8 for A8.

§ Create() [1/2]

virtual HRESULT ParaEngine::CParaEngineApp::Create ( HINSTANCE  hInstance = 0)
inlinevirtual

create d3d render device based on the current main window.

Use this function to create a new render device automatically.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ Create() [2/2]

virtual HRESULT ParaEngine::CParaEngineApp::Create ( HINSTANCE  hInstance = 0)
virtual

create d3d render device based on the current main window.

Use this function to create a new render device automatically.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ CreateFromD3D9Device() [1/2]

virtual HRESULT ParaEngine::CParaEngineApp::CreateFromD3D9Device ( IDirect3DDevice9 *  pD3dDevice,
IDirect3DSwapChain9 *  apSwapChain 
)
inlinevirtual

create from an existing d3d device.

This is an advanced function to replaced the default render device. and caller is responsible for managing device life time. The external caller must call InitDeviceObjects(), RestoreDeviceObjects(), InvalidateDeviceObjects(), DeleteDeviceObjects() at proper time

Reimplemented from CD3DApplication.

§ CreateFromD3D9Device() [2/2]

virtual HRESULT ParaEngine::CParaEngineApp::CreateFromD3D9Device ( IDirect3DDevice9 *  pD3dDevice,
IDirect3DSwapChain9 *  apSwapChain 
)
inlinevirtual

create from an existing d3d device.

This is an advanced function to replaced the default render device. and caller is responsible for managing device life time. The external caller must call InitDeviceObjects(), RestoreDeviceObjects(), InvalidateDeviceObjects(), DeleteDeviceObjects() at proper time

Reimplemented from CD3DApplication.

§ DeleteDeviceObjects() [1/3]

virtual HRESULT ParaEngine::CParaEngineApp::DeleteDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has been destroyed, which generally happens as a result of application termination or windowed/full screen toggles.

Resources created in the OnCreateDevice callback should be released here, which generally includes all D3DPOOL_MANAGED resources.

Reimplemented from CD3DApplication.

§ DeleteDeviceObjects() [2/3]

virtual HRESULT ParaEngine::CParaEngineApp::DeleteDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has been destroyed, which generally happens as a result of application termination or windowed/full screen toggles.

Resources created in the OnCreateDevice callback should be released here, which generally includes all D3DPOOL_MANAGED resources.

Reimplemented from CD3DApplication.

§ DeleteDeviceObjects() [3/3]

HRESULT ParaEngine::CParaEngineApp::DeleteDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has been destroyed, which generally happens as a result of application termination or windowed/full screen toggles.

Called when the app is exiting, or the device is being changed, this function deletes any device dependent objects.

Resources created in the OnCreateDevice callback should be released here, which generally includes all D3DPOOL_MANAGED resources.

ParaEngine fixed code: must call these functions as given below

Reimplemented from CD3DApplication.

§ DoWork() [1/3]

HRESULT CParaEngineApp::DoWork ( )
virtual

this function is called per frame, in most cases, it will render the 3d scene and frame move.

call this as often as one like internally it will use a timer to best fit the interval.

Reimplemented from CD3DApplication.

§ DoWork() [2/3]

virtual HRESULT ParaEngine::CParaEngineApp::DoWork ( )
inlinevirtual

this function is called per frame, in most cases, it will render the 3d scene and frame move.

call this as often as one like internally it will use a timer to best fit the interval.

Reimplemented from CD3DApplication.

§ DoWork() [3/3]

virtual HRESULT ParaEngine::CParaEngineApp::DoWork ( )
inlinevirtual

this function is called per frame, in most cases, it will render the 3d scene and frame move.

call this as often as one like internally it will use a timer to best fit the interval.

Reimplemented from CD3DApplication.

§ Enable3DRendering()

void CParaEngineApp::Enable3DRendering ( bool  bEnable)
virtual

disable 3D rendering, do not present the scene.

This is usually called before and after we show a standard win32 window during full screen mode, such as displaying a flash window

Parameters
bEnabletrue to enable.

This is usually called before and after we show a standard win32 window during full screen mode, such as displaying a flash window

Reimplemented from ParaEngine::CParaEngineAppBase.

§ EnablePassiveRendering() [1/3]

void CParaEngineApp::EnablePassiveRendering ( bool  bEnable)
virtual

passive rendering, it will not render the scene, but simulation and time remains the same.

Default is false

Reimplemented from ParaEngine::CParaEngineAppBase.

§ EnablePassiveRendering() [2/3]

virtual void ParaEngine::CParaEngineApp::EnablePassiveRendering ( bool  bEnable)
inlinevirtual

passive rendering, it will not render the scene, but simulation and time remains the same.

Default is false

Reimplemented from ParaEngine::CParaEngineAppBase.

§ EnablePassiveRendering() [3/3]

virtual void ParaEngine::CParaEngineApp::EnablePassiveRendering ( bool  bEnable)
inlinevirtual

passive rendering, it will not render the scene, but simulation and time remains the same.

Default is false

Reimplemented from ParaEngine::CParaEngineAppBase.

§ Exit() [1/3]

virtual void ParaEngine::CParaEngineApp::Exit ( int  nReturnCode = 0)
virtual

Send the exit message, so that the game engine will prepare to exit in the next frame.

this is the recommended way of exiting application. this is mainly used for writing test cases. Where a return value of 0 means success, any other value means failure.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ Exit() [2/3]

virtual void ParaEngine::CParaEngineApp::Exit ( int  nReturnCode = 0)
virtual

Send the exit message, so that the game engine will prepare to exit in the next frame.

this is the recommended way of exiting application. this is mainly used for writing test cases. Where a return value of 0 means success, any other value means failure.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ Exit() [3/3]

void ParaEngine::CParaEngineApp::Exit ( int  nReturnCode = 0)
virtual

Send the exit message, so that the game engine will prepare to exit in the next frame.

this is the recommended way of exiting application. this is mainly used for writing test cases. Where a return value of 0 means success, any other value means failure.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ FinalCleanup()

HRESULT ParaEngine::CParaEngineApp::FinalCleanup ( )
virtual

This function should be called only once when the application end, one can destroy game objects here.

Called before the app exits, this function gives the app the chance to cleanup after itself.

ParaEngine fixed code: must call these functions as given below

Reimplemented from CD3DApplication.

§ ForceRender()

bool CParaEngineApp::ForceRender ( )
virtual

render the current frame and does not return until everything is presented to screen.

this function is usually used to draw the animated loading screen.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ FrameMove() [1/4]

HRESULT CParaEngineApp::FrameMove ( )
virtual

This callback function will be called once at the beginning of every frame.

This is the best location for your application to handle updates to the scene, but is not intended to contain actual rendering calls, which should instead be placed in the OnFrameRender callback.

Parameters
fTimeCurrent time elapsed.

Reimplemented from CD3DApplication.

§ FrameMove() [2/4]

virtual HRESULT ParaEngine::CParaEngineApp::FrameMove ( double  fTime)
virtual

This callback function will be called once at the beginning of every frame.

This is the best location for your application to handle updates to the scene, but is not intended to contain actual rendering calls, which should instead be placed in the OnFrameRender callback.

Parameters
fTimeCurrent time elapsed.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ FrameMove() [3/4]

HRESULT ParaEngine::CParaEngineApp::FrameMove ( double  fTime)
virtual

Called once per frame, the call is the entry point for animating the scene.

ParaEngine fixed code: must call these functions as given below TODO: I have no idea whether we should simulate before calling IO functions or vice versa. since, some IO actions will not be validated by the simulator before it is rendered. However, the camera IO need to get the biped position that is being rendered for the current frame. hence the current order is changed to SIM->SCRIPT->IO(camera and biped control)->RENDER the old order is IO(camera and biped control)->SIM->SCRIPT->RENDER

process all messages in the main game thread.

<<fElapsedEnvSimTime>> in worst case, it might be half of 60.f, that is only 1/30secs. Animate the environment, remote script and network module it must be called if IO is executed. Since IO may change the cognitive state of some characters The environment simulator will provide feedback (constraint) on those subjective state. e.g. An IO event might send a character to a moving state(mentally), however, if the character is blocked, this cognitive state must be prohibited, before rendering function is called. Such constraints are feedback by the physical environment

– Call AI script and remote scripts as well as some simulation in the form of triggering scripts. It is important for this script to come before m_pEnvironmentSim->Animate() because the latter may add objects which may be deleted to the visiting biped list. Hence, when m_pEnvironmentSim->Animate() is called, the scene can no longer drop objects.

– Animate the scene –: – Environment simulation is carried out by m_pEnvironmentSim always call Environment simulation before you frame move any other object in the scene since Environment simulation may change the object's cached actions.

<<fElapsedIOTime>> in worst case, it might be half of 60.f, that is only 1/30secs. handle mouse and key board I/O events Faster than the user input <= 1/30 sec

process all user key and mouse messages

Engine required: Camera control some object in the scene requires to update its parameters each frame currently only Camera control responses.

Render() will be called after this function with m_fElapsedTime as its time advances

Reimplemented from ParaEngine::CParaEngineAppBase.

§ FrameMove() [4/4]

virtual HRESULT ParaEngine::CParaEngineApp::FrameMove ( double  fTime)
virtual

This callback function will be called once at the beginning of every frame.

This is the best location for your application to handle updates to the scene, but is not intended to contain actual rendering calls, which should instead be placed in the OnFrameRender callback.

Parameters
fTimeCurrent time elapsed.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GameToClient()

void CParaEngineApp::GameToClient ( int &  inout_x,
int &  inout_y,
bool  bInBackbuffer = true 
)
virtual

translate a position from game coordination system to client window position.

Parameters
inout_xin and out
inout_yin and out
bInBackbufferif true, it will scale the output according to the ratio of back buffer and current window size.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GenerateD3DDebugString()

void CParaEngineApp::GenerateD3DDebugString ( )

Output text information to console, for debugging only.

§ GetCoreUsage()

DWORD CParaEngineApp::GetCoreUsage ( )
virtual

Get the current ParaEngine app usage.

[main thread only]

Returns
see PE_USAGE

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetCursorPosition()

void CParaEngineApp::GetCursorPosition ( int *  pX,
int *  pY,
bool  bInBackbuffer = true 
)
virtual

get the current mouse cursor position.

Parameters
pXout
pYout
bInBackbufferif true, it will scale the output according to the ratio of back buffer and current window size.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetIgnoreWindowSizeChange()

bool CParaEngineApp::GetIgnoreWindowSizeChange ( )
virtual

return true if it is currently under windowed mode.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetMessageFromApp() [1/3]

virtual bool ParaEngine::CParaEngineApp::GetMessageFromApp ( CWinRawMsg pMsg)
inlinevirtual

get a message from the application message queue and remove it from the queue.

This function is mostly used internally by the main thread.

Parameters
pMsgthe receiving message
Returns
true if one message is fetched. or false if there is no more messages in the queue.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetMessageFromApp() [2/3]

virtual bool ParaEngine::CParaEngineApp::GetMessageFromApp ( CWinRawMsg pMsg)
virtual

get a message from the application message queue and remove it from the queue.

This function is mostly used internally by the main thread.

Parameters
pMsgthe receiving message
Returns
true if one message is fetched. or false if there is no more messages in the queue.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetMessageFromApp() [3/3]

bool ParaEngine::CParaEngineApp::GetMessageFromApp ( CWinRawMsg pMsg)
virtual

get a message from the application message queue and remove it from the queue.

This function is mostly used internally by the main thread.

Parameters
pMsgthe receiving message
Returns
true if one message is fetched. or false if there is no more messages in the queue.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetModuleHandle()

HINSTANCE CParaEngineApp::GetModuleHandle ( )
virtual

change the cursor to indicate a movie recording state

get the module handle, it may be exe or the dll handle, depending on how the main host app is built.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetMultiSampleQuality() [1/3]

int CParaEngineApp::GetMultiSampleQuality ( )
virtual

anti-aliasing for both windowed and full screen mode.

it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetMultiSampleQuality() [2/3]

virtual int ParaEngine::CParaEngineApp::GetMultiSampleQuality ( )
inlinevirtual

anti-aliasing for both windowed and full screen mode.

it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetMultiSampleQuality() [3/3]

virtual int ParaEngine::CParaEngineApp::GetMultiSampleQuality ( )
inlinevirtual

anti-aliasing for both windowed and full screen mode.

it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetMultiSampleType() [1/3]

int CParaEngineApp::GetMultiSampleType ( )
virtual

anti-aliasing for both windowed and full screen mode.

it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetMultiSampleType() [2/3]

virtual int ParaEngine::CParaEngineApp::GetMultiSampleType ( )
inlinevirtual

anti-aliasing for both windowed and full screen mode.

it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetMultiSampleType() [3/3]

virtual int ParaEngine::CParaEngineApp::GetMultiSampleType ( )
inlinevirtual

anti-aliasing for both windowed and full screen mode.

it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetNPLRuntime() [1/2]

NPL::INPLRuntime * ParaEngine::CParaEngineApp::GetNPLRuntime ( )
virtual

get the NPL runtime system associate with the application.

NPL provides communication framework across different language systems.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetNPLRuntime() [2/2]

virtual NPL::INPLRuntime* ParaEngine::CParaEngineApp::GetNPLRuntime ( )
virtual

get the NPL runtime system associate with the application.

NPL provides communication framework across different language systems.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetResolution() [1/3]

void ParaEngine::CParaEngineApp::GetResolution ( float *  pX,
float *  pY 
)
virtual

change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetResolution() [2/3]

virtual void ParaEngine::CParaEngineApp::GetResolution ( float *  pX,
float *  pY 
)
virtual

change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetResolution() [3/3]

virtual void ParaEngine::CParaEngineApp::GetResolution ( float *  pX,
float *  pY 
)
virtual

change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetScreenResolution() [1/3]

void CParaEngineApp::GetScreenResolution ( Vector2 pOut)
virtual

change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetScreenResolution() [2/3]

ParaEngine::Vector2 ParaEngine::CParaEngineApp::GetScreenResolution ( )
virtual

change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device.

§ GetScreenResolution() [3/3]

virtual Vector2 ParaEngine::CParaEngineApp::GetScreenResolution ( )
virtual

change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device.

§ GetStats()

void CParaEngineApp::GetStats ( string &  output,
DWORD  dwFields = 0 
)
virtual

get the render engine stats to output.

Parameters
outputthe output buffer.
dwFieldscurrent it is 0, which just collect graphics card settings. 1 is os information.

§ GetWindowCreationSize() [1/3]

virtual void ParaEngine::CParaEngineApp::GetWindowCreationSize ( int *  pWidth,
int *  pHeight 
)
virtual

get the window creation size in default application config.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetWindowCreationSize() [2/3]

virtual void ParaEngine::CParaEngineApp::GetWindowCreationSize ( int *  pWidth,
int *  pHeight 
)
virtual

get the window creation size in default application config.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ GetWindowCreationSize() [3/3]

void ParaEngine::CParaEngineApp::GetWindowCreationSize ( int *  pWidth,
int *  pHeight 
)
virtual

get the window creation size in default application config.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ HandleUserInput() [1/3]

void ParaEngine::CParaEngineApp::HandleUserInput ( )

process game input.

§ HandleUserInput() [2/3]

void ParaEngine::CParaEngineApp::HandleUserInput ( )

process game input.

§ HandleUserInput() [3/3]

void ParaEngine::CParaEngineApp::HandleUserInput ( )

process game input.

handle 2D GUI input: dispatch mouse and key event for gui objects.

handle the camera user input. One can also block camera input and handle everything from script.

handle 3D scene input

handle 2D GUI input: dispatch mouse and key event for gui objects.

handle the automatic camera user input.

3D scene handler

§ HasFocus()

bool CParaEngineApp::HasFocus ( HWND  hWnd = 0)
virtual

this returns true if the main window or one of its child window has key focus.

Parameters
hWndthe current window handle from which we will compare. If 0, we will use GetFocus() to get it.

§ HasNewConfig() [1/3]

bool ParaEngine::CParaEngineApp::HasNewConfig ( )
virtual

get whether ParaEngine is loaded from config/config.new.txt.

if this is true, we need to ask the user to save to config/config.txt. This is usually done at start up.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ HasNewConfig() [2/3]

virtual bool ParaEngine::CParaEngineApp::HasNewConfig ( )
virtual

get whether ParaEngine is loaded from config/config.new.txt.

if this is true, we need to ask the user to save to config/config.txt. This is usually done at start up.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ HasNewConfig() [3/3]

virtual bool ParaEngine::CParaEngineApp::HasNewConfig ( )
virtual

get whether ParaEngine is loaded from config/config.new.txt.

if this is true, we need to ask the user to save to config/config.txt. This is usually done at start up.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ Init()

HRESULT ParaEngine::CParaEngineApp::Init ( HWND *  pHWND)
virtual

init application

fixing win vista or win 7 security filters.

set up dSound

Create a blank root scene with certain dimensions units is Meter.

create the default system font, the game should also use this sys font to save resources

set up terrain engine parameters

Reimplemented from ParaEngine::CParaEngineAppBase.

§ InitDeviceObjects() [1/3]

virtual HRESULT ParaEngine::CParaEngineApp::InitDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has been created, which will happen during application initialization and windowed/full screen toggles.

This is the best location to create D3DPOOL_MANAGED resources since these resources need to be reloaded whenever the device is destroyed. Resources created here should be released in the OnDestroyDevice callback.

Reimplemented from CD3DApplication.

§ InitDeviceObjects() [2/3]

virtual HRESULT ParaEngine::CParaEngineApp::InitDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has been created, which will happen during application initialization and windowed/full screen toggles.

This is the best location to create D3DPOOL_MANAGED resources since these resources need to be reloaded whenever the device is destroyed. Resources created here should be released in the OnDestroyDevice callback.

Reimplemented from CD3DApplication.

§ InitDeviceObjects() [3/3]

HRESULT ParaEngine::CParaEngineApp::InitDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has been created, which will happen during application initialization and windowed/full screen toggles.

Initialize scene objects.

This is the best location to create D3DPOOL_MANAGED resources since these resources need to be reloaded whenever the device is destroyed. Resources created here should be released in the OnDestroyDevice callback.

ParaEngine fixed code: must call these functions as given below

Asset must be the first to be initialized. Otherwise, the global device object will not be valid

Reimplemented from CD3DApplication.

§ InitWin3DSettings()

void CParaEngineApp::InitWin3DSettings ( )

AppUsesDepthBuffer needed for Parallel world

AppUsesMixedVP needed for parallel world

enable stencil buffer

Just turn off Full screen cursor, we will use mine.

§ InvalidateDeviceObjects() [1/3]

virtual HRESULT ParaEngine::CParaEngineApp::InvalidateDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has entered a lost state and before IDirect3DDevice9::Reset is called.

Resources created in the OnResetDevice callback should be released here, which generally includes all D3DPOOL_DEFAULT resources. See the "Lost Devices" section of the documentation for information about lost devices.

Reimplemented from CD3DApplication.

§ InvalidateDeviceObjects() [2/3]

virtual HRESULT ParaEngine::CParaEngineApp::InvalidateDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has entered a lost state and before IDirect3DDevice9::Reset is called.

Resources created in the OnResetDevice callback should be released here, which generally includes all D3DPOOL_DEFAULT resources. See the "Lost Devices" section of the documentation for information about lost devices.

Reimplemented from CD3DApplication.

§ InvalidateDeviceObjects() [3/3]

HRESULT ParaEngine::CParaEngineApp::InvalidateDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has entered a lost state and before IDirect3DDevice9::Reset is called.

Called when the device-dependent objects are about to be lost.

Resources created in the OnResetDevice callback should be released here, which generally includes all D3DPOOL_DEFAULT resources. See the "Lost Devices" section of the documentation for information about lost devices.

ParaEngine fixed code: must call these functions as given below

Reimplemented from CD3DApplication.

§ Is3DRenderingEnabled()

bool CParaEngineApp::Is3DRenderingEnabled ( )
virtual

whether 3D rendering is enabled, do not present the scene.

This is usually called before and after we show a standard win32 window during full screen mode, such as displaying a flash window

Reimplemented from ParaEngine::CParaEngineAppBase.

§ IsAppActive() [1/3]

virtual bool ParaEngine::CParaEngineApp::IsAppActive ( )
virtual

whether the application is active or not.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ IsAppActive() [2/3]

virtual bool ParaEngine::CParaEngineApp::IsAppActive ( )
virtual

whether the application is active or not.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ IsAppActive() [3/3]

bool ParaEngine::CParaEngineApp::IsAppActive ( )
virtual

whether the application is active or not.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ IsDebugBuild() [1/2]

bool ParaEngine::CParaEngineApp::IsDebugBuild ( )

whether it is debug build.

§ IsDebugBuild() [2/2]

bool ParaEngine::CParaEngineApp::IsDebugBuild ( )

whether it is debug build.

§ IsKeyPressed()

bool ParaEngine::CParaEngineApp::IsKeyPressed ( DWORD  nKey)

return true if the key is being pressed at the time of calling.

Parameters
nKeya direct input key, such as DIK_SPACE.

§ IsPassiveRenderingEnabled() [1/3]

bool CParaEngineApp::IsPassiveRenderingEnabled ( )
virtual

passive rendering, it will not render the scene, but simulation and time remains the same.

Default is false

Reimplemented from ParaEngine::CParaEngineAppBase.

§ IsPassiveRenderingEnabled() [2/3]

virtual bool ParaEngine::CParaEngineApp::IsPassiveRenderingEnabled ( )
inlinevirtual

passive rendering, it will not render the scene, but simulation and time remains the same.

Default is false

Reimplemented from ParaEngine::CParaEngineAppBase.

§ IsPassiveRenderingEnabled() [3/3]

virtual bool ParaEngine::CParaEngineApp::IsPassiveRenderingEnabled ( )
inlinevirtual

passive rendering, it will not render the scene, but simulation and time remains the same.

Default is false

Reimplemented from ParaEngine::CParaEngineAppBase.

§ IsTouchInputting()

virtual bool ParaEngine::CParaEngineApp::IsTouchInputting ( )
inlinevirtual

whether the last mouse input is from touch or mouse.

by default it is mouse mode.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ IsWindowedMode() [1/3]

bool CParaEngineApp::IsWindowedMode ( )
virtual

return true if it is currently under windowed mode.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ IsWindowedMode() [2/3]

virtual bool ParaEngine::CParaEngineApp::IsWindowedMode ( )
inlinevirtual

return true if it is currently under windowed mode.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ IsWindowedMode() [3/3]

virtual bool ParaEngine::CParaEngineApp::IsWindowedMode ( )
inlinevirtual

return true if it is currently under windowed mode.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ MsgProcApp()

LRESULT ParaEngine::CParaEngineApp::MsgProcApp ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
virtual

Before handling window messages, application should pass incoming windows messages to the application through this callback function.

menu command

application defined command

Reimplemented from ParaEngine::CParaEngineAppBase.

§ MsgProcWinThread() [1/3]

virtual LRESULT ParaEngine::CParaEngineApp::MsgProcWinThread ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
bool  bCallDefProcedure = true 
)
inlinevirtual

the window message processor.

One needs send all messages belonging to the main window to this function, after calling Create().

Note
: the main rendering thread can be a different thread than the window proc thread.
Parameters
bCallDefProcedurewhether we will call the ::DefWindowProdure().
Returns
: 0 if message was not processed. 1 if message is processed. -1 if message is processed by can be passed on to other processor.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ MsgProcWinThread() [2/3]

virtual LRESULT ParaEngine::CParaEngineApp::MsgProcWinThread ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
bool  bCallDefProcedure = true 
)
inlinevirtual

the window message processor.

One needs send all messages belonging to the main window to this function, after calling Create().

Note
: the main rendering thread can be a different thread than the window proc thread.
Parameters
bCallDefProcedurewhether we will call the ::DefWindowProdure().
Returns
: 0 if message was not processed. 1 if message is processed. -1 if message is processed by can be passed on to other processor.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ MsgProcWinThread() [3/3]

LRESULT CParaEngineApp::MsgProcWinThread ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
bool  bCallDefProcedure = true 
)
virtual

the window message processor.

One needs send all messages belonging to the main window to this function, after calling Create().

Note
: the main rendering thread can be a different thread than the window proc thread.
Parameters
bCallDefProcedurewhether we will call the ::DefWindowProdure().
Returns
: 0 if message was not processed. 1 if message is processed. -1 if message is processed by can be passed on to other processor.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ OnCreateWindow()

HRESULT CParaEngineApp::OnCreateWindow ( )

this function should be called when the application is created.

I.e. the windows HWND is valid.

§ OneTimeSceneInit() [1/3]

HRESULT CParaEngineApp::OneTimeSceneInit ( )
virtual

This function should be called only once when the application start, one can initialize game objects here.

Called during initial app startup, this function performs all the permanent initialization.

Parameters
pHWND:apointer to the handle of the current application window.

ParaEngine modules are setup here. ParaEngine fixed code: must call these functions as given below

Reimplemented from CD3DApplication.

§ OneTimeSceneInit() [2/3]

HRESULT ParaEngine::CParaEngineApp::OneTimeSceneInit ( HWND *  pHWND)

This function should be called only once when the application start, one can initialize game objects here.

Parameters
pHWND:apointer to the handle of the current application window.

load frame rate controller

§ OneTimeSceneInit() [3/3]

HRESULT ParaEngine::CParaEngineApp::OneTimeSceneInit ( HWND *  pHWND)

This function should be called only once when the application start, one can initialize game objects here.

Parameters
pHWND:apointer to the handle of the current application window.

§ PostWinThreadMessage() [1/3]

virtual bool ParaEngine::CParaEngineApp::PostWinThreadMessage ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
inlinevirtual

post a raw win32 message from any thread to the thread on which hWnd is created.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ PostWinThreadMessage() [2/3]

virtual bool ParaEngine::CParaEngineApp::PostWinThreadMessage ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
virtual

post a raw win32 message from any thread to the thread on which hWnd is created.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ PostWinThreadMessage() [3/3]

bool ParaEngine::CParaEngineApp::PostWinThreadMessage ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
virtual

post a raw win32 message from any thread to the thread on which hWnd is created.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ ReadRegDWORD() [1/2]

DWORD ParaEngine::CParaEngineApp::ReadRegDWORD ( const string &  root_key,
const string &  sSubKey,
const string &  name 
)

Read DWORD from the registry.

Valid values for root_key are listed under WriteRegStr. NULL will be returned if the DWORD is not present or type is a string.

§ ReadRegDWORD() [2/2]

DWORD ParaEngine::CParaEngineApp::ReadRegDWORD ( const string &  root_key,
const string &  sSubKey,
const string &  name 
)

Read DWORD from the registry.

Valid values for root_key are listed under WriteRegStr. NULL will be returned if the DWORD is not present or type is a string.

§ ReadRegStr() [1/2]

const char * ParaEngine::CParaEngineApp::ReadRegStr ( const string &  root_key,
const string &  sSubKey,
const string &  name 
)

Read string from the registry.

Valid values for root_key are listed under WriteRegStr. NULL will be returned if the string is not present. If the value is present, but is of type REG_DWORD, it will be read and converted to a string.

§ ReadRegStr() [2/2]

const char* ParaEngine::CParaEngineApp::ReadRegStr ( const string &  root_key,
const string &  sSubKey,
const string &  name 
)

Read string from the registry.

Valid values for root_key are listed under WriteRegStr. NULL will be returned if the string is not present. If the value is present, but is of type REG_DWORD, it will be read and converted to a string.

§ Render()

HRESULT CParaEngineApp::Render ( )
virtual

This callback function will be called at the end of every frame to perform all the rendering calls for the scene, and it will also be called if the window needs to be repainted.

Called once per frame, the call is the entry point for 3d rendering.

After this function has returned, application should call IDirect3DDevice9::Present to display the contents of the next buffer in the swap chain

Parameters
fTimeCurrent time elapsed.

This function sets up render states, clears the viewport, and renders the scene. ParaEngine fixed code: must call these functions as given below

clear all render targets

force using less equal

Reimplemented from CD3DApplication.

§ Render3DEnvironment() [1/3]

virtual HRESULT ParaEngine::CParaEngineApp::Render3DEnvironment ( bool  bForceRender = false)
virtual

Frame move and render a frame during idle time (no messages are waiting).

Call this function during CPU idle time. internally it uses a timer to control frame rates, so it is safe to call this as often as one like.

Parameters
bForceRenderif true, it will force frame move and render the scene. if not, it will internally use a frame rate controller that maintain the frame rate at 30 fps, no matter who often this function is called.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ Render3DEnvironment() [2/3]

virtual HRESULT ParaEngine::CParaEngineApp::Render3DEnvironment ( bool  bForceRender = false)
virtual

Frame move and render a frame during idle time (no messages are waiting).

Call this function during CPU idle time. internally it uses a timer to control frame rates, so it is safe to call this as often as one like.

Parameters
bForceRenderif true, it will force frame move and render the scene. if not, it will internally use a frame rate controller that maintain the frame rate at 30 fps, no matter who often this function is called.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ Render3DEnvironment() [3/3]

HRESULT ParaEngine::CParaEngineApp::Render3DEnvironment ( bool  bForceRender = false)
virtual

Frame move and render a frame during idle time (no messages are waiting).

Call this function during CPU idle time. internally it uses a timer to control frame rates, so it is safe to call this as often as one like.

Parameters
bForceRenderif true, it will force frame move and render the scene. if not, it will internally use a frame rate controller that maintain the frame rate at 30 fps, no matter who often this function is called.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ RestoreDeviceObjects() [1/3]

virtual HRESULT ParaEngine::CParaEngineApp::RestoreDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has been reset, which will happen after a lost device scenario.

This is the best location to create D3DPOOL_DEFAULT resources since these resources need to be reloaded whenever the device is lost. Resources created here should be released in the OnLostDevice callback.

Reimplemented from CD3DApplication.

§ RestoreDeviceObjects() [2/3]

virtual HRESULT ParaEngine::CParaEngineApp::RestoreDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has been reset, which will happen after a lost device scenario.

This is the best location to create D3DPOOL_DEFAULT resources since these resources need to be reloaded whenever the device is lost. Resources created here should be released in the OnLostDevice callback.

Reimplemented from CD3DApplication.

§ RestoreDeviceObjects() [3/3]

HRESULT ParaEngine::CParaEngineApp::RestoreDeviceObjects ( )
virtual

This callback function will be called immediately after the Direct3D device has been reset, which will happen after a lost device scenario.

Initialize scene objects.

This is the best location to create D3DPOOL_DEFAULT resources since these resources need to be reloaded whenever the device is lost. Resources created here should be released in the OnLostDevice callback.

ParaEngine fixed code: must call these functions as given below

Set up the camera's projection matrix

these render state is preferred.

these render state is just for point occlusion testing. See also CBaseObject::DrawOcclusionObject()

Reimplemented from CD3DApplication.

§ Run() [1/3]

int ParaEngine::CParaEngineApp::Run ( HINSTANCE  hInstance)
virtual

only call this function if one does not want to manage game loop externally.

Reimplemented from CD3DApplication.

§ Run() [2/3]

virtual int ParaEngine::CParaEngineApp::Run ( HINSTANCE  hInstance)
virtual

only call this function if one does not want to manage game loop externally.

Reimplemented from CD3DApplication.

§ Run() [3/3]

virtual int ParaEngine::CParaEngineApp::Run ( HINSTANCE  hInstance)
virtual

only call this function if one does not want to manage game loop externally.

Reimplemented from CD3DApplication.

§ SendMessageToApp() [1/3]

virtual LRESULT ParaEngine::CParaEngineApp::SendMessageToApp ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
inlinevirtual

Send a RAW win32 message the application to be processed in the next main thread update interval.

This function can be called from any thread. It is also used by the windows procedure thread to dispatch messages to the main processing thread.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SendMessageToApp() [2/3]

virtual LRESULT ParaEngine::CParaEngineApp::SendMessageToApp ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
virtual

Send a RAW win32 message the application to be processed in the next main thread update interval.

This function can be called from any thread. It is also used by the windows procedure thread to dispatch messages to the main processing thread.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SendMessageToApp() [3/3]

LRESULT ParaEngine::CParaEngineApp::SendMessageToApp ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
virtual

Send a RAW win32 message the application to be processed in the next main thread update interval.

This function can be called from any thread. It is also used by the windows procedure thread to dispatch messages to the main processing thread.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetAllowWindowClosing() [1/3]

void CParaEngineApp::SetAllowWindowClosing ( bool  bAllowClosing)
virtual

whether the user can close the window (sending WM_CLOSE message).

Default to true. When set to false, the scripting interface will receive WM_CLOSE message via system event. And can use ParaEngine.Exit() to quit the application after user confirmation, etc.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetAllowWindowClosing() [2/3]

virtual void ParaEngine::CParaEngineApp::SetAllowWindowClosing ( bool  bAllowClosing)
inlinevirtual

whether the user can close the window (sending WM_CLOSE message).

Default to true. When set to false, the scripting interface will receive WM_CLOSE message via system event. And can use ParaEngine.Exit() to quit the application after user confirmation, etc.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetAllowWindowClosing() [3/3]

virtual void ParaEngine::CParaEngineApp::SetAllowWindowClosing ( bool  bAllowClosing)
inlinevirtual

whether the user can close the window (sending WM_CLOSE message).

Default to true. When set to false, the scripting interface will receive WM_CLOSE message via system event. And can use ParaEngine.Exit() to quit the application after user confirmation, etc.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetCoreUsage()

void CParaEngineApp::SetCoreUsage ( DWORD  dwUsage)
virtual

Set the current ParaEngine app usage.

[main thread only]

Parameters
dwUsagebitwise of PE_USAGE

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetFullScreenMode() [1/3]

void CParaEngineApp::SetFullScreenMode ( bool  bFullscreen)
virtual

whether to use full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetFullScreenMode() [2/3]

virtual void ParaEngine::CParaEngineApp::SetFullScreenMode ( bool  bFullscreen)
inlinevirtual

whether to use full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetFullScreenMode() [3/3]

virtual void ParaEngine::CParaEngineApp::SetFullScreenMode ( bool  bFullscreen)
inlinevirtual

whether to use full screen mode, it does not immediately change the device, call UpdateScreenMode() to update the device.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetHasNewConfig() [1/3]

void ParaEngine::CParaEngineApp::SetHasNewConfig ( bool  bHasNewConfig)
virtual

set whether ParaEngine is loaded from config/config.new.txt.

if this is true, we need to ask the user to save to config/config.txt. This is usually done at start up.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetHasNewConfig() [2/3]

virtual void ParaEngine::CParaEngineApp::SetHasNewConfig ( bool  bHasNewConfig)
virtual

set whether ParaEngine is loaded from config/config.new.txt.

if this is true, we need to ask the user to save to config/config.txt. This is usually done at start up.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetHasNewConfig() [3/3]

virtual void ParaEngine::CParaEngineApp::SetHasNewConfig ( bool  bHasNewConfig)
virtual

set whether ParaEngine is loaded from config/config.new.txt.

if this is true, we need to ask the user to save to config/config.txt. This is usually done at start up.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetIgnoreWindowSizeChange()

void CParaEngineApp::SetIgnoreWindowSizeChange ( bool  bIgnoreSizeChange)
virtual

switch to ignore windows size change.

default to false. if false, the user is allowed to adjust window size in windowed mode.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetMainWindow() [1/3]

virtual void ParaEngine::CParaEngineApp::SetMainWindow ( HWND  hWnd,
bool  bIsExternalWindow = true 
)
inlinevirtual

set the hWnd on to which we will render and process window messages.

this function should be called prior to Create().

Note
: the rendering device size will use the client area of the input window
Parameters
hWndthe Window on to which we will render.
bIsExternalWindowthis is always true, unless for the default window used by ParaEngine when no window is created by the user.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetMainWindow() [2/3]

virtual void ParaEngine::CParaEngineApp::SetMainWindow ( HWND  hWnd,
bool  bIsExternalWindow = true 
)
virtual

set the hWnd on to which we will render and process window messages.

this function should be called prior to Create().

Note
: the rendering device size will use the client area of the input window
Parameters
hWndthe Window on to which we will render.
bIsExternalWindowthis is always true, unless for the default window used by ParaEngine when no window is created by the user.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetMainWindow() [3/3]

void ParaEngine::CParaEngineApp::SetMainWindow ( HWND  hWnd,
bool  bIsExternalWindow = true 
)
virtual

set the hWnd on to which we will render and process window messages.

this function should be called prior to Create().

Note
: the rendering device size will use the client area of the input window
Parameters
hWndthe Window on to which we will render.
bIsExternalWindowthis is always true, unless for the default window used by ParaEngine when no window is created by the user.

let us find the top-level window which should be the foreground window.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetMinUIResolution() [1/3]

virtual void ParaEngine::CParaEngineApp::SetMinUIResolution ( int  nWidth,
int  nHeight,
bool  bAutoUIScaling = true 
)
inlinevirtual

set the minimum UI resolution size.

if the backbuffer is smaller than this, we will use automatically use UI scaling for example, if minimum width is 1024, and backbuffer it 800, then m_fUIScalingX will be automatically set to 1024/800. calling this function will cause OnSize() and UpdateBackbufferSize() to be called. Actually it calls SetUIScale() [main thread only]

Parameters
nWidththe new width.
nHeightthe new height.
bAutoUIScalingdefault to true. whether we will automatically recalculate the UI scaling accordingly with regard to current backbuffer size.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetMinUIResolution() [2/3]

virtual void ParaEngine::CParaEngineApp::SetMinUIResolution ( int  nWidth,
int  nHeight,
bool  bAutoUIScaling = true 
)
inlinevirtual

set the minimum UI resolution size.

if the backbuffer is smaller than this, we will use automatically use UI scaling for example, if minimum width is 1024, and backbuffer it 800, then m_fUIScalingX will be automatically set to 1024/800. calling this function will cause OnSize() and UpdateBackbufferSize() to be called. Actually it calls SetUIScale() [main thread only]

Parameters
nWidththe new width.
nHeightthe new height.
bAutoUIScalingdefault to true. whether we will automatically recalculate the UI scaling accordingly with regard to current backbuffer size.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetMinUIResolution() [3/3]

void CParaEngineApp::SetMinUIResolution ( int  nWidth,
int  nHeight,
bool  bAutoUIScaling = true 
)
virtual

set the minimum UI resolution size.

if the backbuffer is smaller than this, we will use automatically use UI scaling for example, if minimum width is 1024, and backbuffer it 800, then m_fUIScalingX will be automatically set to 1024/800. calling this function will cause OnSize() and UpdateBackbufferSize() to be called. Actually it calls SetUIScale() [main thread only]

Parameters
nWidththe new width.
nHeightthe new height.
bAutoUIScalingdefault to true. whether we will automatically recalculate the UI scaling accordingly with regard to current backbuffer size.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetRefreshTimer() [1/2]

virtual void ParaEngine::CParaEngineApp::SetRefreshTimer ( float  fTimeInterval,
int  nFrameRateControl = 0 
)
virtual

Set the frame rate timer interval.

Parameters
fTimeIntervalvalue in seconds. such as 0.033f or 0.01667f Passing a value <= 0 to render in idle time.
nFrameRateControl0 for real time, 1 for ideal frame rate at 30 FPS no matter whatever time interval is set.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetRefreshTimer() [2/2]

void ParaEngine::CParaEngineApp::SetRefreshTimer ( float  fTimeInterval,
int  nFrameRateControl = 0 
)
virtual

Set the frame rate timer interval.

Parameters
fTimeIntervalvalue in seconds. such as 0.033f or 0.01667f Passing a value <= 0 to render in idle time.
nFrameRateControl0 for real time, 1 for ideal frame rate at 30 FPS no matter whatever time interval is set.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetWindowedMode() [1/3]

bool CParaEngineApp::SetWindowedMode ( bool  bWindowed)
virtual

switch to either windowed mode or full screen mode.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetWindowedMode() [2/3]

virtual bool ParaEngine::CParaEngineApp::SetWindowedMode ( bool  bWindowed)
inlinevirtual

switch to either windowed mode or full screen mode.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ SetWindowedMode() [3/3]

virtual bool ParaEngine::CParaEngineApp::SetWindowedMode ( bool  bWindowed)
inlinevirtual

switch to either windowed mode or full screen mode.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ StartApp() [1/3]

virtual HRESULT ParaEngine::CParaEngineApp::StartApp ( const char *  sCommandLine = 0)
virtual

This is the first function that should be called when acquiring the IParaEngineApp interface.

call this function to start the application. Rendering window and devices are not created, one need to call Create() instead.

Parameters
sCommandLinethe command line parameter

Reimplemented from ParaEngine::CParaEngineAppBase.

§ StartApp() [2/3]

virtual HRESULT ParaEngine::CParaEngineApp::StartApp ( const char *  sCommandLine = 0)
virtual

This is the first function that should be called when acquiring the IParaEngineApp interface.

call this function to start the application. Rendering window and devices are not created, one need to call Create() instead.

Parameters
sCommandLinethe command line parameter

Reimplemented from ParaEngine::CParaEngineAppBase.

§ StartApp() [3/3]

HRESULT ParaEngine::CParaEngineApp::StartApp ( const char *  sCommandLine = 0)
virtual

call this function to create the ParaEngine main rendering device based on the current window.

If no window is specified using SetMainWindow(), it will create a default window using the default config settings.

Parameters
sCommandLinethe command line parameter

Reimplemented from ParaEngine::CParaEngineAppBase.

§ StopApp() [1/3]

virtual HRESULT ParaEngine::CParaEngineApp::StopApp ( )
virtual

This is the last function that should be called.

It is usually called just before process exit.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ StopApp() [2/3]

virtual HRESULT ParaEngine::CParaEngineApp::StopApp ( )
virtual

This is the last function that should be called.

It is usually called just before process exit.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ StopApp() [3/3]

HRESULT ParaEngine::CParaEngineApp::StopApp ( )
virtual

This is the last function that should be called.

It is usually called just before process exit.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ UpdateScreenMode() [1/3]

bool CParaEngineApp::UpdateScreenMode ( )
virtual

call this function to update changes of FullScreen Mode and Screen Resolution.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ UpdateScreenMode() [2/3]

virtual bool ParaEngine::CParaEngineApp::UpdateScreenMode ( )
inlinevirtual

call this function to update changes of FullScreen Mode and Screen Resolution.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ UpdateScreenMode() [3/3]

virtual bool ParaEngine::CParaEngineApp::UpdateScreenMode ( )
inlinevirtual

call this function to update changes of FullScreen Mode and Screen Resolution.

Reimplemented from ParaEngine::CParaEngineAppBase.

§ WriteConfigFile() [1/3]

void ParaEngine::CParaEngineApp::WriteConfigFile ( const char *  sFileName)
virtual

write the current setting to config file.

Such as graphics mode and whether full screen, etc. config file at ./config.txt will be automatically loaded when the game engine starts.

Parameters
sFileNameif this is "", it will be the default config file at ./config.txt

Reimplemented from ParaEngine::CParaEngineAppBase.

§ WriteConfigFile() [2/3]

virtual void ParaEngine::CParaEngineApp::WriteConfigFile ( const char *  sFileName)
virtual

write the current setting to config file.

Such as graphics mode and whether full screen, etc. config file at ./config.txt will be automatically loaded when the game engine starts.

Parameters
sFileNameif this is "", it will be the default config file at ./config.txt

Reimplemented from ParaEngine::CParaEngineAppBase.

§ WriteConfigFile() [3/3]

virtual void ParaEngine::CParaEngineApp::WriteConfigFile ( const char *  sFileName)
virtual

write the current setting to config file.

Such as graphics mode and whether full screen, etc. config file at ./config.txt will be automatically loaded when the game engine starts.

Parameters
sFileNameif this is "", it will be the default config file at ./config.txt

Reimplemented from ParaEngine::CParaEngineAppBase.

§ WriteRegDWORD() [1/2]

bool ParaEngine::CParaEngineApp::WriteRegDWORD ( const string &  root_key,
const string &  sSubKey,
const string &  name,
DWORD  value 
)

Write a DWORD to the registry.

see WriteRegStr() for more info

§ WriteRegDWORD() [2/2]

bool ParaEngine::CParaEngineApp::WriteRegDWORD ( const string &  root_key,
const string &  sSubKey,
const string &  name,
DWORD  value 
)

Write a DWORD to the registry.

see WriteRegStr() for more info

§ WriteRegStr() [1/2]

bool ParaEngine::CParaEngineApp::WriteRegStr ( const string &  root_key,
const string &  sSubKey,
const string &  name,
const string &  value 
)

Write a string to the registry.

e.g. WriteRegStr("HKLM", "Software\My Company\My Software", "string Value", "string Name");

Parameters
root_keymust be HKCR or HKEY_CLASSES_ROOT HKLM or HKEY_LOCAL_MACHINE HKCU or HKEY_CURRENT_USER HKU or HKEY_USERS

§ WriteRegStr() [2/2]

bool ParaEngine::CParaEngineApp::WriteRegStr ( const string &  root_key,
const string &  sSubKey,
const string &  name,
const string &  value 
)

Write a string to the registry.

e.g. WriteRegStr("HKLM", "Software\My Company\My Software", "string Value", "string Name");

Parameters
root_keymust be HKCR or HKEY_CLASSES_ROOT HKLM or HKEY_LOCAL_MACHINE HKCU or HKEY_CURRENT_USER HKU or HKEY_USERS

Member Data Documentation

§ m_bAppHasFocus

bool ParaEngine::CParaEngineApp::m_bAppHasFocus
protected

whether app has focus.

§ m_dwCoreUsage

DWORD ParaEngine::CParaEngineApp::m_dwCoreUsage
protected

the Core usage.

See also
PE_USAGE

§ m_dwWinThreadID

DWORD ParaEngine::CParaEngineApp::m_dwWinThreadID
protected

the thread id of the main window thread.

It is used when doing the PostWinThreadMessage().

§ m_nInitialGameEffectSet

int ParaEngine::CParaEngineApp::m_nInitialGameEffectSet
protected

initial game effect setting to be loaded from the config file.

default value it 0

§ m_nWindowedDesired

int ParaEngine::CParaEngineApp::m_nWindowedDesired
protected

1 window mode desired, 0 full screen mode desired, -1 if unknown.

§ m_pWinRawMsgQueue

CWinRawMsgQueue * ParaEngine::CParaEngineApp::m_pWinRawMsgQueue
protected

The thread safe message queue target for receiving messages from window thread.

They are processed in the main game thread though.


The documentation for this class was generated from the following files: