5 #include "platform/mac/ParaEngineApp.h" 9 #include "ParaEngineAppBase.h" 10 #include "common/d3dapp.h" 11 #include "ITouchInputTranslator.h" 18 struct SpriteFontEntity;
19 class CDirectKeyboard;
23 class CParaWorldAsset;
25 class CWinRawMsgQueue;
26 class CViewportManager;
110 virtual int Run(HINSTANCE hInstance);
138 virtual bool IsFullScreenMode();
148 virtual bool IsWindowClosingAllowed();
155 virtual void SetScreenResolution(
const Vector2& vSize);
158 virtual void SetResolution(
float x,
float y);
162 virtual void SetMultiSampleType(
int nType);
166 virtual void SetMultiSampleQuality(
int nType);
182 virtual void FixWindowSize(
bool fixed);
189 virtual void GetStats(
string& output, DWORD dwFields=0);
199 bool WriteRegStr(
const string& root_key,
const string& sSubKey,
const string& name,
const string&
value);
204 const char*
ReadRegStr(
const string& root_key,
const string& sSubKey,
const string& name);
209 bool WriteRegDWORD(
const string& root_key,
const string& sSubKey,
const string& name, DWORD value);
214 DWORD
ReadRegDWORD(
const string& root_key,
const string& sSubKey,
const string& name);
228 virtual void GameToClient(
int& inout_x,
int & inout_y,
bool bInBackbuffer =
true);
235 virtual void ClientToGame(
int& inout_x,
int & inout_y,
bool bInBackbuffer =
true);
268 HRESULT
ConfirmDevice( LPDIRECT3D9 pD3d, D3DCAPS9*, DWORD, D3DFORMAT, D3DFORMAT );
271 HRESULT
Init(HWND* pHWND);
345 virtual void SetMainWindow(HWND hWnd,
bool bIsExternalWindow=
true);
346 virtual HWND GetMainWindow();
352 virtual HRESULT
StartApp(
const char* sCommandLine = 0);
354 void InitSystemModules();
360 void BootStrapAndLoadConfig();
362 void InitApp(
const char* sCommandLine);
364 bool CheckClientLicense();
366 void LoadAndApplySettings();
370 virtual LRESULT
MsgProcWinThread( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
bool bCallDefProcedure =
true);
372 virtual LRESULT MsgProcWinThreadCustom( UINT uMsg, WPARAM wParam, LPARAM lParam);
374 virtual LRESULT
SendMessageToApp( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
389 virtual LRESULT
MsgProcApp( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
392 virtual HRESULT
Create( HINSTANCE hInstance = 0 );
394 virtual HRESULT CreateFromD3D9Device(IDirect3DDevice9* pD3dDevice, IDirect3DSwapChain9* apSwapChain);
397 virtual float GetFPS();
398 void UpdateFrameStats(
double fTime);
406 virtual void SetRefreshTimer(
float fTimeInterval,
int nFrameRateControl = 0);
451 virtual void Exit(
int nReturnCode = 0);
456 virtual bool HasFocus(HWND hWnd = 0);
459 virtual bool IsSlateMode();
463 virtual int32 GetTouchPointY(){
return m_touchPointY; }
471 bool GetAutoLowerFrameRateWhenNotFocused();
475 bool GetToggleSoundWhenNotFocused();
484 bool UpdateScreenDevice();
487 const char* GetTouchEventSCodeFromMessage(
const char * event_type, HWND hWnd, WPARAM wParam, LPARAM lParam);
490 void SetAppWndRect(
const RECT& rect);
492 HINSTANCE m_hInstance;
504 float m_fAspectRatio;
507 bool m_bDrawReflection:1;
508 bool m_bDisplayText:1;
509 bool m_bDisplayHelp:1;
510 bool m_bServerMode:1;
512 bool m_bHasNewConfig:1;
513 bool m_bAllowWindowClosing:1;
515 bool m_bAutoLowerFrameRateWhenNotFocused:1;
517 bool m_bToggleSoundWhenNotFocused:1;
526 bool m_bUpdateScreenDevice;
virtual void ShowMenu(bool bShow)
turn on/off menu
Definition: ParaEngineApp.cpp:1473
virtual bool HasFocus(HWND hWnd=0)
this returns true if the main window or one of its child window has key focus.
Definition: ParaEngineApp.cpp:2209
virtual void Enable3DRendering(bool bEnable)
disable 3D rendering, do not present the scene.
Definition: ParaEngineApp.cpp:2076
virtual float GetRefreshTimer()
get the refresh timer.
Definition: ParaEngineApp.cpp:2111
virtual void GetStats(string &output, DWORD dwFields=0)
get the render engine stats to output.
Definition: ParaEngineApp.cpp:1337
bool AppHasFocus()
return true if app has focus.
Definition: ParaEngineApp.cpp:1079
HRESULT ConfirmDevice(LPDIRECT3D9 pD3d, D3DCAPS9 *, DWORD, D3DFORMAT, D3DFORMAT)
Called during device initialization, this code checks the device for some minimum set of capabilities...
Definition: ParaEngineApp.cpp:493
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...
Definition: ParaEngineApp.cpp:2247
virtual void SetMainWindow(HWND hWnd, bool bIsExternalWindow=true)
set the hWnd on to which we will render and process window messages.
Definition: ParaEngineApp.cpp:424
bool IsDebugBuild()
whether it is debug build.
Definition: ParaEngineApp.cpp:1301
virtual void ActivateApp(bool bActivate)
this function is called whenever the application is disabled or enabled.
Definition: ParaEngineApp.cpp:2134
virtual HINSTANCE GetModuleHandle()
change the cursor to indicate a movie recording state
Definition: ParaEngineApp.cpp:419
virtual DWORD GetCoreUsage()
Get the current ParaEngine app usage.
Definition: ParaEngineApp.cpp:2185
virtual int32 GetTouchPointX()
obsoleted function:
Definition: ParaEngineApp.h:462
virtual void WriteConfigFile(const char *sFileName)
write the current setting to config file.
Definition: ParaEngineApp.cpp:1557
CWinRawMsgQueue * m_pWinRawMsgQueue
The thread safe message queue target for receiving messages from window thread.
Definition: ParaEngineApp.h:532
virtual void EnablePassiveRendering(bool bEnable)
passive rendering, it will not render the scene, but simulation and time remains the same...
Definition: ParaEngineApp.cpp:2067
HRESULT OnCreateWindow()
this function should be called when the application is created.
Definition: ParaEngineApp.cpp:483
Definition: ParaEngineAppBase.h:11
virtual bool GetMessageFromApp(CWinRawMsg *pMsg)
get a message from the application message queue and remove it from the queue.
Definition: ParaEngineApp.cpp:2257
HRESULT Init(HWND *pHWND)
init application
Definition: ParaEngineApp.cpp:558
different physics engine has different winding order.
Definition: EventBinding.h:32
virtual void SetAppState(ParaEngine::PEAppState state)
set application state
Definition: ParaEngineApp.cpp:2129
virtual void SetMinUIResolution(int nWidth, int nHeight, bool bAutoUIScaling=true)
set the minimum UI resolution size.
Definition: ParaEngineApp.cpp:2195
virtual HRESULT Create(HINSTANCE hInstance=0)
create instance
Definition: ParaEngineApp.cpp:465
Class: CAudioEngine.
Definition: AudioEngine.h:49
void GenerateD3DDebugString()
Output text information to console, for debugging only.
Definition: ParaEngineApp.cpp:1156
Definition: ManagedDef.h:18
virtual void GameToClient(int &inout_x, int &inout_y, bool bInBackbuffer=true)
translate a position from game coordination system to client window position.
Definition: ParaEngineApp.cpp:1666
virtual void SetHasNewConfig(bool bHasNewConfig)
set whether ParaEngine is loaded from config/config.new.txt.
Definition: ParaEngineApp.cpp:1639
virtual bool ForceRender()
render the current frame and does not return until everything is presented to screen.
Definition: ParaEngineApp.cpp:3227
HWND m_hwndTopLevelWnd
set foreground window
Definition: ParaEngineApp.h:547
virtual void GetCursorPosition(int *pX, int *pY, bool bInBackbuffer=true)
get the current mouse cursor position.
Definition: ParaEngineApp.cpp:1644
int m_nInitialGameEffectSet
initial game effect setting to be loaded from the config file.
Definition: ParaEngineApp.h:520
virtual LRESULT MsgProcWinThread(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool bCallDefProcedure=true)
the window message processor.
Definition: ParaEngineApp.cpp:2371
virtual const char * GetWindowText()
get the window title when at windowed mode
Definition: ParaEngineApp.cpp:1548
Definition: GUIDirectInput.h:106
virtual void GetResolution(float *pX, float *pY)
change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to up...
Definition: ParaEngineApp.cpp:1401
bool WriteRegDWORD(const string &root_key, const string &sSubKey, const string &name, DWORD value)
Write a DWORD to the registry.
Definition: ParaEngineApp.cpp:1937
virtual bool HasNewConfig()
get whether ParaEngine is loaded from config/config.new.txt.
Definition: ParaEngineApp.cpp:1634
virtual void SetIgnoreWindowSizeChange(bool bIgnoreSizeChange)
switch to ignore windows size change.
Definition: ParaEngineApp.cpp:1511
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
virtual HRESULT FrameMove()
This callback function will be called once at the beginning of every frame.
Definition: ParaEngineApp.cpp:918
virtual HRESULT RestoreDeviceObjects()
This callback function will be called immediately after the Direct3D device has been reset...
Definition: ParaEngineApp.cpp:759
std::string m_sTitleString
for debugging display
Definition: ParaEngineApp.h:544
virtual PEAppState GetAppState()
get application state
Definition: ParaEngineApp.cpp:2124
virtual void GetWindowCreationSize(int *pWidth, int *pHeight)
get the window creation size in default application config.
Definition: ParaEngineApp.cpp:2116
void SetToggleSoundWhenNotFocused(bool bEnabled)
if true, sound volume will be set to 0, when not focused.
Definition: ParaEngineApp.cpp:2237
raw win32 message
Definition: OSWindows.h:27
DWORD m_dwWinThreadID
the thread id of the main window thread.
Definition: ParaEngineApp.h:535
virtual bool Is3DRenderingEnabled()
whether 3D rendering is enabled, do not present the scene.
Definition: ParaEngineApp.cpp:2083
virtual bool IsAppActive()
whether the application is active or not.
Definition: ParaEngineApp.cpp:2178
const char * ReadRegStr(const string &root_key, const string &sSubKey, const string &name)
Read string from the registry.
Definition: ParaEngineApp.cpp:1858
HRESULT OneTimeSceneInit()
This function should be called only once when the application start, one can initialize game objects ...
Definition: ParaEngineApp.cpp:721
The ref_ptr class template stores a pointer to a dynamically allocated (AssetEntity|CRefCounted|BaseA...
Definition: PERefPtr.h:13
bool m_bAppHasFocus
whether app has focus.
Definition: ParaEngineApp.h:541
virtual HRESULT DoWork()
this function is called per frame, in most cases, it will render the 3d scene and frame move...
Definition: ParaEngineApp.cpp:2088
A base class for creating D3D device based application.
Definition: d3dapp.h:13
virtual HRESULT DeleteDeviceObjects()
This callback function will be called immediately after the Direct3D device has been destroyed...
Definition: ParaEngineApp.cpp:844
virtual void SetRefreshTimer(float fTimeInterval, int nFrameRateControl=0)
Set the frame rate timer interval.
Definition: ParaEngineApp.cpp:2098
virtual bool IsServerMode()
server mode has no user interface
Definition: ParaEngineApp.cpp:199
virtual void ClientToGame(int &inout_x, int &inout_y, bool bInBackbuffer=true)
translate a position from client window position to game coordination system.
Definition: ParaEngineApp.cpp:1684
virtual HRESULT InitDeviceObjects()
This callback function will be called immediately after the Direct3D device has been created...
Definition: ParaEngineApp.cpp:732
virtual bool IsWindowedMode()
return true if it is currently under windowed mode.
Definition: ParaEngineApp.cpp:1457
Definition: enum_maker.hpp:46
ref_ptr< CViewportManager > m_pViewportManager
viewport
Definition: ParaEngineApp.h:499
virtual void Exit(int nReturnCode=0)
Send the exit message, so that the game engine will prepare to exit in the next frame.
Definition: ParaEngineApp.cpp:3155
virtual int GetMultiSampleQuality()
anti-aliasing for both windowed and full screen mode.
Definition: ParaEngineApp.cpp:1431
DWORD m_dwCoreUsage
the Core usage.
Definition: ParaEngineApp.h:538
CParaEngineApp()
One needs to manually start the application.
Definition: ParaEngineApp.cpp:153
CViewportManager * GetViewportManager()
managing multiple 3d views
Definition: ParaEngineApp.cpp:175
the message queue.
Definition: OSWindows.h:53
virtual void BringWindowToTop()
The BringWindowToTop current window to the top of the Z order.
Definition: ParaEngineApp.cpp:1728
virtual int GetMultiSampleType()
anti-aliasing for both windowed and full screen mode.
Definition: ParaEngineApp.cpp:1420
void HandleUserInput()
process game input.
Definition: ParaEngineApp.cpp:1360
virtual void SetAllowWindowClosing(bool bAllowClosing)
whether the user can close the window (sending WM_CLOSE message).
Definition: ParaEngineApp.cpp:473
virtual bool IsTouchInputting()
whether the last mouse input is from touch or mouse.
Definition: ParaEngineApp.h:458
ref_ptr< CSceneObject > m_pRootScene
3d scene root object
Definition: ParaEngineApp.h:497
virtual HRESULT Render3DEnvironment(bool bForceRender=false)
Frame move and render a frame during idle time (no messages are waiting).
Definition: ParaEngineApp.cpp:2093
virtual bool GetIgnoreWindowSizeChange()
return true if it is currently under windowed mode.
Definition: ParaEngineApp.cpp:1516
virtual int Run(HINSTANCE hInstance)
only call this function if one does not want to manage game loop externally.
Definition: ParaEngineApp.cpp:1310
void SetAutoLowerFrameRateWhenNotFocused(bool bEnabled)
default to false. if true, we will lower frame rate when the window is not focused.
Definition: ParaEngineApp.cpp:2227
virtual HRESULT StartApp(const char *sCommandLine=0)
call this function to create the ParaEngine main rendering device based on the current window...
Definition: ParaEngineApp.cpp:353
virtual void SetWindowText(const char *pChar)
set the window title when at windowed mode
Definition: ParaEngineApp.cpp:1541
virtual void SetFullScreenMode(bool bFullscreen)
whether to use full screen mode, it does not immediately change the device, call UpdateScreenMode() t...
Definition: ParaEngineApp.cpp:1462
PEAppState
ParaEngine application state.
Definition: IParaEngineApp.h:40
virtual HRESULT Render()
This callback function will be called at the end of every frame to perform all the rendering calls fo...
Definition: ParaEngineApp.cpp:1235
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.
Definition: ParaEngineApp.cpp:2274
int m_nWindowedDesired
1 window mode desired, 0 full screen mode desired, -1 if unknown.
Definition: ParaEngineApp.h:524
virtual void SetCoreUsage(DWORD dwUsage)
Set the current ParaEngine app usage.
Definition: ParaEngineApp.cpp:2190
virtual HRESULT InvalidateDeviceObjects()
This callback function will be called immediately after the Direct3D device has entered a lost state ...
Definition: ParaEngineApp.cpp:829
virtual bool SetWindowedMode(bool bWindowed)
switch to either windowed mode or full screen mode.
Definition: ParaEngineApp.cpp:1448
virtual HRESULT StopApp()
This is the last function that should be called.
Definition: ParaEngineApp.cpp:376
manager multiple viewport
Definition: ViewportManager.h:18
virtual Vector2 GetScreenResolution()
change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to up...
Definition: ParaEngineApp.cpp:429
virtual HRESULT FinalCleanup()
This function should be called only once when the application end, one can destroy game objects here...
Definition: ParaEngineApp.cpp:861
This class demonstrate how to initialize, destroy and drive the game loop of ParaEngine through the C...
Definition: ParaEngineApp.h:96
ref_ptr< CParaWorldAsset > m_pParaWorldAsset
asset manager
Definition: ParaEngineApp.h:501
virtual bool UpdateScreenMode()
call this function to update changes of FullScreen Mode and Screen Resolution.
Definition: ParaEngineApp.cpp:1442
ref_ptr< CGUIRoot > m_pGUIRoot
2d gui root
Definition: ParaEngineApp.h:495
virtual bool IsPassiveRenderingEnabled()
passive rendering, it will not render the scene, but simulation and time remains the same...
Definition: ParaEngineApp.cpp:2071
virtual LRESULT MsgProcApp(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Before handling window messages, application should pass incoming windows messages to the application...
Definition: ParaEngineApp.cpp:2781
void InitWin3DSettings()
Definition: ParaEngineApp.cpp:242
bool WriteRegStr(const string &root_key, const string &sSubKey, const string &name, const string &value)
Write a string to the registry.
Definition: ParaEngineApp.cpp:1833
DWORD ReadRegDWORD(const string &root_key, const string &sSubKey, const string &name)
Read DWORD from the registry.
Definition: ParaEngineApp.cpp:1969