My Project
IParaEngineApp.h
1 #pragma once
2 //-----------------------------------------------------------------------------
3 // Copyright (C) 2007 - 2010 ParaEngine Corporation, All Rights Reserved.
4 // Author: LiXizhi
5 // Date: 2010.2
6 // Description: API for ParaEngine App windows management interface
7 //-----------------------------------------------------------------------------
8 #include <string>
9 #include "baseinterface.h"
10 #include <stdint.h>
11 
12 struct IDirect3DDevice9;
13 struct IDirect3DSwapChain9;
14 
15 namespace NPL{
16  class INPLRuntime;
17 }
18 
19 #ifndef WIN32
20 #ifndef WM_USER
21  #define WM_USER 0x0400
22 #endif
23 #ifndef LRESULT
24  #define LRESULT long*
25 #endif
26 #ifndef WPARAM
27  #define WPARAM int*
28 #endif
29 #ifndef LPARAM
30  #define LPARAM int*
31 #endif
32 #endif
33 namespace ParaEngine
34 {
35  struct CWinRawMsg;
36  class CRefCounted;
37  class Vector2;
38 
41  {
42  PEAppState_None = 0,
43  PEAppState_Started,
44  PEAppState_Device_Created,
45  PEAppState_Device_Error,
46  PEAppState_Ready,
47  PEAppState_SwitchedOut,
48  PEAppState_Stopped,
49  PEAppState_Exiting,
50  PEAppState_Exited,
51  PEAppState_Unknown,
52  };
53 
55  enum PE_USAGE
56  {
57  // standalone application
58  PE_USAGE_STANDALONE = 1,
59  // Used in web browser
60  PE_USAGE_WEB_BROWSER = 2,
61  // as a system service
62  PE_USAGE_SERVICE = 4,
63  // owns the d3d device, otherwise it is using external device.
64  PE_USAGE_OWN_D3D = 16,
65  // owns the main window, otherwise it renders to an external window.
66  PE_USAGE_OWN_WINDOW = 32,
67  };
68 
70 #define PE_WM_FIRST WM_USER+2301
71 
72 #define PE_WM_SHOWCURSOR WM_USER+2301
73 
74 #define PE_WM_QUIT WM_USER+2302
75 
76 #define PE_WM_SETCAPTURE WM_USER+2303
77 
78 #define PE_WM_RELEASECAPTURE WM_USER+2304
79 
80 #define PE_WM_SETFOCUS WM_USER+2305
81 
82 #define PE_IME_SETOPENSTATUS WM_USER+2306
83 
84 #define PE_IME_SETFOCUS WM_USER+2307
85 
86 #define PE_APP_SWITCH WM_USER+2308
87 
88 #define PE_APP_SHOW_ERROR_MSG WM_USER+2309
89 
90 #define PE_WM_LAST WM_USER+2399
91 
93 #define PE_TIMERID_HEARTBEAT 5602
94 
99  {
100  public:
105  virtual HRESULT StartApp(const char* sCommandLine = 0) = 0;
106 
109  virtual HRESULT StopApp() = 0;
110 
117  virtual void SetMainWindow(HWND hWnd, bool bIsExternalWindow=true) = 0;
118  virtual HWND GetMainWindow() = 0;
119 
121  virtual int Run(HINSTANCE hInstance) = 0;
122 
126  virtual HRESULT DoWork() = 0;
127 
131  virtual HRESULT CreateFromD3D9Device(IDirect3DDevice9* pD3dDevice, IDirect3DSwapChain9* apSwapChain) = 0;
132 
140  virtual HRESULT InitDeviceObjects() = 0;
141 
149  virtual HRESULT RestoreDeviceObjects() = 0;
150 
158  virtual HRESULT InvalidateDeviceObjects() = 0;
165  virtual HRESULT DeleteDeviceObjects() = 0;
166 
170  virtual HRESULT Create( HINSTANCE hInstance = 0 ) = 0;
171 
173  virtual HRESULT Init(HWND* pHWND = 0) = 0;
174 
180  virtual HRESULT Render3DEnvironment(bool bForceRender = false) = 0;
181 
187  virtual LRESULT MsgProcWinThread( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool bCallDefProcedure = true) = 0;
188 
189  /*** process win thread messages without a hWnd. Such messages are usually invoked by PostWinThreadMessage() from other threads. */
190  virtual LRESULT MsgProcWinThreadCustom( UINT uMsg, WPARAM wParam, LPARAM lParam) = 0;
191 
195  virtual LRESULT SendMessageToApp( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) = 0;
196 
198  virtual bool PostWinThreadMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) = 0;
199 
205  virtual bool GetMessageFromApp(CWinRawMsg* pMsg) = 0;
206 
210  virtual LRESULT MsgProcApp(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) = 0;
211 
213  virtual void EnablePassiveRendering( bool bEnable ) = 0;
214 
216  virtual bool IsPassiveRenderingEnabled( ) = 0;
217 
222  virtual void Enable3DRendering(bool bEnable) = 0;
223 
226  virtual bool Is3DRenderingEnabled() = 0;
227 
228 
230  virtual void SetFullScreenMode(bool bFullscreen) = 0;
231  virtual bool IsFullScreenMode() = 0;
232 
235  virtual void BringWindowToTop() = 0;
236 
240  virtual void SetAllowWindowClosing(bool bAllowClosing) = 0;
241  virtual bool IsWindowClosingAllowed() = 0;
242 
244  virtual void ShowMenu(bool bShow) = 0;
245 
247  virtual void GetResolution(float* pX, float* pY) = 0;
248  virtual void SetResolution(float x, float y) = 0;
249 
251  virtual int GetMultiSampleType() = 0;
252  virtual void SetMultiSampleType(int nType) = 0;
253 
255  virtual int GetMultiSampleQuality() = 0;
256  virtual void SetMultiSampleQuality(int nType) = 0;
257 
259  virtual bool UpdateScreenMode() = 0;
260 
261  // ParaEngine pipeline routines
263  virtual bool SetWindowedMode(bool bWindowed) = 0;
265  virtual bool IsWindowedMode() = 0;
267  virtual void SetWindowText(const char* pChar) = 0;
269  virtual const char* GetWindowText() = 0;
270 
276  virtual void GetCursorPosition(int* pX,int * pY, bool bInBackbuffer = true) = 0;
277 
283  virtual void GameToClient(int& inout_x,int & inout_y, bool bInBackbuffer = true) = 0;
284 
290  virtual void ClientToGame(int& inout_x,int & inout_y, bool bInBackbuffer = true) = 0;
291 
296  virtual void WriteConfigFile(const char* sFileName) = 0;
297 
299  virtual bool HasNewConfig() = 0;
300 
302  virtual void SetHasNewConfig(bool bHasNewConfig) = 0;
303 
306  virtual void SetIgnoreWindowSizeChange(bool bIgnoreSizeChange) = 0;
307 
309  virtual bool GetIgnoreWindowSizeChange() = 0;
310 
312  virtual HINSTANCE GetModuleHandle() = 0;
313 
320  virtual void SetRefreshTimer(float fTimeInterval, int nFrameRateControl=0) = 0;
321 
324  virtual float GetRefreshTimer() = 0;
325 
327  virtual void GetWindowCreationSize(int * pWidth, int * pHeight) = 0;
328 
330  virtual PEAppState GetAppState() = 0;
331 
333  virtual void SetAppState(ParaEngine::PEAppState state) = 0;
334 
338  virtual void ActivateApp(bool bActivate) = 0;
339 
341  virtual bool IsAppActive() = 0;
342 
347  virtual DWORD GetCoreUsage() = 0;
348 
353  virtual void SetCoreUsage(DWORD dwUsage) = 0;
354 
363  virtual void SetMinUIResolution(int nWidth, int nHeight, bool bAutoUIScaling = true) = 0;
364 
369  virtual void Exit(int nReturnCode = 0) = 0;
370 
374  virtual void SetReturnCode(int nReturnCode) = 0;
375  virtual int GetReturnCode() = 0;
376 
378  virtual NPL::INPLRuntime* GetNPLRuntime() = 0;
379 
381  virtual bool IsTouchInputting() = 0;
382 
383  virtual bool IsSlateMode() = 0;
384 
386  virtual int32 GetTouchPointX() = 0;
387  virtual int32 GetTouchPointY() = 0;
388 
390  virtual void WriteToLog(const char* sFormat, ...) = 0;
391 
393  virtual void AppLog(const char* sMessage) { WriteToLog(sMessage); };
394 
396  virtual void SetTouchInputting(bool bTouchInputting){};
397 
399  virtual void SystemMessageBox(const std::string& msg) {};
400 
405  virtual void SetAppCommandLine(const char* pCommandLine) {};
406 
412  virtual const char* GetAppCommandLineByParam(const char* pParam, const char* defaultValue){ return NULL; };
413 
415  virtual const char* GetAppCommandLine() { return NULL; };
416 
417 
419  virtual void GetScreenResolution(Vector2* pOut){ };
420 
421  virtual void SetScreenResolution(const Vector2& vSize){};
422 
423  virtual float GetFPS() { return 30.f; };
424 
428  virtual CRefCounted* AddToSingletonReleasePool(CRefCounted* pObject) { return pObject; };
429 
431  virtual bool IsServerMode() { return true; };
432 
433 
437  virtual bool HasClosingRequest() { return false; };
438  virtual void SetHasClosingRequest(bool val) {};
439 
446  virtual bool LoadNPLPackage(const char* sFilePath, std::string * pOutMainFile = NULL) { return false; };
447 
450  virtual bool ForceRender() { return false; };
451 
453  virtual const char* GetModuleDir() { return NULL; };
454 
455  /* whether the window size is fixed. */
456  virtual void FixWindowSize(bool fixed) = 0;
457  };
458 
459 }
virtual bool HasClosingRequest()
whether there is closing request in the message queue.
Definition: IParaEngineApp.h:437
define this to enable debugging of NPL code in visual studio
Definition: INPL.h:9
The base class for interfaces in ParaEngine.
Definition: baseinterface.h:29
virtual CRefCounted * AddToSingletonReleasePool(CRefCounted *pObject)
we will automatically release singleton object when app stops, in the verse order when object is adde...
Definition: IParaEngineApp.h:428
virtual bool IsServerMode()
server mode has no user interface
Definition: IParaEngineApp.h:431
different physics engine has different winding order.
Definition: EventBinding.h:32
virtual void GetScreenResolution(Vector2 *pOut)
change the full screen mode, it does not immediately change the device, call UpdateScreenMode() to up...
Definition: IParaEngineApp.h:419
virtual bool LoadNPLPackage(const char *sFilePath, std::string *pOutMainFile=NULL)
load NPL package from a disk folder.
Definition: IParaEngineApp.h:446
virtual const char * GetModuleDir()
get the NPL bin directory (main executable directory).
Definition: IParaEngineApp.h:453
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
Definition: PERef.h:11
virtual void AppLog(const char *sMessage)
write app log to file with time and code location.
Definition: IParaEngineApp.h:393
raw win32 message
Definition: OSWindows.h:27
virtual const char * GetAppCommandLineByParam(const char *pParam, const char *defaultValue)
return a specified parameter value in the command line of the application.
Definition: IParaEngineApp.h:412
virtual void SetAppCommandLine(const char *pCommandLine)
set string specifying the command line for the application, excluding the program name...
Definition: IParaEngineApp.h:405
PE_USAGE
how ParaEngine core is used.
Definition: IParaEngineApp.h:55
PEAppState
ParaEngine application state.
Definition: IParaEngineApp.h:40
virtual void SystemMessageBox(const std::string &msg)
show a system message box to the user.
Definition: IParaEngineApp.h:399
a table of virtual functions which are used by plug-ins to access the game engine ...
Definition: IParaEngineApp.h:98
virtual const char * GetAppCommandLine()
get string specifying the command line for the application, excluding the program name...
Definition: IParaEngineApp.h:415
virtual void SetTouchInputting(bool bTouchInputting)
whether the last mouse input is from touch or mouse.
Definition: IParaEngineApp.h:396
virtual bool ForceRender()
render the current frame and does not return until everything is presented to screen.
Definition: IParaEngineApp.h:450
NPL Runtime Environment interface.
Definition: INPLRuntime.h:30