|
Documentation
|
|||||||||||||||||||||||||||||||||||||||||||
|
CGapiApplicationOverviewCGapiApplication is a helper class you can use to quickly create new games and applications. This document has been updated for use with GapiDraw 4.0 or later.
CGapiApplication::CGapiApplicationCreates a CGapiApplication instance based on the configuration specified.
Parameters
|
|
virtual HRESULT Run(); |
If this method succeeds, the return value is S_OK.
If the method fails, the return value may be one of the following return values:
E_FAIL
GDERR_INVALIDMODE
GDERR_INVALIDPARAMS
GDERR_LOCKEDSURFACES
GDERR_NOGAPI
GDERR_OUTOFMEMORY
GDERR_UNSUPPORTEDMODE
GDERR_PRIMARYSURFACEALREADYEXISTS
Use CGapiApplication::Run to start a CGapiApplication. When CGapiApplication::Run is called, the following steps are performed:
CGapiApplication::Run does not return until CGapiApplication::Shutdown is called. When it is called, the following steps are performed by CGapiApplication::Run:
Shuts down the CGapiApplication and exits the CGapiApplication::Run operation.
|
virtual HRESULT Shutdown(); |
The return value is S_OK.
Minimize CGapiApplication and suspend the update thread. On mobile devices the application can be restored by the user by clicking on the application icon on the today screen.
|
virtual HRESULT Minimize(); |
The return value is S_OK.
Toggle between windowed mode and fullscreen display on Windows Mobile 5.0 and later devices.
virtual HRESULT ToggleFullscreen(); |
The return value is S_OK.
Pauses the application and skips the call to CGapiApplication::ProcessNextFrame in the subclass.
|
virtual HRESULT Pause(DWORD dwNumFrames); |
The return value is S_OK.
Changes the number of calls to CGapiApplication::ProcessNextFrame during each second.
|
virtual HRESULT ChangeFPS(DWORD dwFPS); |
If this method succeeds, the return value is GD_OK.
If the method fails, the return value may be one of the following return values:
E_FAIL
Changes the display orientation.
|
virtual HRESULT SetDisplayMode(DWORD dwDisplayMode); |
The return value is S_OK.
The display orientation can be changed at any time ("normal" and two landscape modes are supported). The orientation will change before the next frame is processed.
After the display mode has changed, CGapiApplication will call CGapiApplication::CreateSysMemSurfaces and CGapiApplication::CreateVidMemSurfaces in the subclass to re-create all surfaces so they match the new display orientation. Please make sure that you set both the display coordinates and surfaces dynamically in CGapiApplication::CreateSysMemSurfaces and CGapiApplication::CreateVidMemSurfaces if you want to support dynamic change of the display orientation.
Sets an error description and error code to be displayed before CGapiApplication exits.
|
virtual HRESULT SetError(const TCHAR* pErrorDesc, HRESULT hr = 0); |
If this method succeeds, the return value is GD_OK.
If the method fails, the return value may be one of the following return values:
E_FAIL
Returns TRUE if the application is running full screen.
|
BOOL IsFullscreen(); |
Returns TRUE if the application is running full screen, or FALSE if the application is running in windowed mode.
Returns a pointer to the global CGapiDraw object used in all class constructors.
CGapiDraw* GetGlobal() |
Returns a pointer to the global CGapiDraw object.
Returns a pointer to the display object.
|
CGapiDisplay* GetDisplay(); |
Returns a pointer to the display object.
Returns a pointer to the backbuffer object.
|
CGapiSurface* GetBackBuffer(); |
Returns a pointer to the backbuffer object.
It is recommended that you use this operation instead of GetDisplay()->GetBackBuffer() since the backbuffer might be of a different size than the display back buffer.
Returns a pointer to the input object.
|
CGapiInput* GetInput(); |
Returns a pointer to the input object.
Returns a pointer to the timer object.
|
CGapiTimer* GetTimer(); |
Returns a pointer to the timer object.
Override CGapiApplication::InitInstance to perform memory allocations before the application is started.
|
virtual HRESULT InitInstance(); |
If this method succeeds, the return value should be S_OK or GD_OK.
If the return value is not S_OK or GD_OK the application will call CGapiApplication::ExitInstance and exit.
Override CGapiApplication::ExitInstance to free memory in your application.
|
virtual HRESULT ExitInstance(); |
If this method succeeds, the return value should be S_OK or GD_OK.
Override CGapiApplication::CreateSysMemSurfaces to create all your surfaces and coordinates.
|
virtual HRESULT CreateSysMemSurfaces(CGapiDisplay* pDisplay, HINSTANCE hInstance); |
If this method succeeds, the return value should be S_OK or GD_OK.
CGapiApplication::CreateSysMemSurfaces is called when the application starts or when the display mode changes. Please see CGapiApplication::SetDisplayMode for more details. It is recommended that you add the code to create all your surfaces in this function.
If the return value is not S_OK or GD_OK the application will call CGapiApplication::ExitInstance and exit.
Override CGapiApplication::CreateVidMemSurfaces to create all your video surfaces and coordinates.
|
virtual HRESULT CreateVidMemSurfaces(CGapiDisplay* pDisplay, HINSTANCE hInstance) |
If this method succeeds, the return value should be S_OK or GD_OK.
CGapiApplication::CreateVidMemSurfaces is called when the application starts, the display mode changes, or if surfaces stored in video memory are lost. Please keep the initialization code and surfaces to be stored in video memory as small as possible. It is recommended that you add the code to create all your video surfaces in this function.
If the return value is not S_OK or GD_OK the application will call CGapiApplication::ExitInstance and exit.
Override CGapiApplication::ProcessNextFrame to draw the next frame to be displayed on screen.
|
virtual HRESULT ProcessNextFrame(CGapiSurface* pBackBuffer, DWORD dwFlags); |
| Type | Description |
|---|---|
|
GDAPP_FRAMETIMEOVERFLOW |
Indicates that the last frame took longer to draw than what is allowed to reach the target number of frame updates each second. |
|
GDAPP_LOSTSURFACES |
Indicates that one or more surfaces stored in video memory were lost, and that CGapiApplication has called CGapiDisplay::RestoreAllVideoSurfaces(), and CGapiApplication::CreateVidMemSurfaces() to restore them. |
|
GDAPP_RESTOREWINDOW |
Indicates that the window has recently been restored after being minimized. |
GDAPP_DISPLAYCHANGED |
Indicates that the display size or orientation was changed. |
If this method succeeds, the return value should be S_OK or GD_OK.
If the return value is not S_OK or GD_OK the application will call CGapiApplication::ExitInstance and exit.
Override CGapiApplication::OnMinimize to run code when the application window is minimized.
|
virtual HRESULT OnMinimize(); |
If this method succeeds, the return value should be S_OK or GD_OK.
Override this method to run application code when the window is minimized. Example usage is disabling sound output and sending network notifications.
Override CGapiApplication::OnRestore to run code when the application window is restored.
|
virtual HRESULT OnRestore(); |
If this method succeeds, the return value should be S_OK or GD_OK.
Override this method to run application code when the window is restored from being minimized. Example usage is enabling sound output and sending network notifications.
Override CGapiApplication::OnDisplayChanged to run code when the display size or orientation has changed.
virtual HRESULT OnDisplayChanged(CGapiSurface* pBackBuffer); |
If this method succeeds, the return value should be S_OK or GD_OK.
Override this method to run application code when the display size or orientation was changed.
Override CGapiApplication::KeyDown to receive information when a key is pressed down.
|
virtual HRESULT KeyDown(DWORD dwKey, GDKEYLIST& keylist); |
If this method succeeds, the return value should be S_OK or GD_OK.
To check if a specific key was pressed simply compare dwKey with any value in keylist. For example, to check if "key left" has been pressed simply enter "if (dwKey == keylist.vkLeft)".
CGapiApplication::KeyDown is only called once when a key is pressed down. CGapiApplication::KeyDown is not called when the "keyboard repeat" event is received.
Override CGapiApplication::KeyUp to receive information when a key is released.
|
virtual HRESULT KeyUp(DWORD dwKey, GDKEYLIST& keylist); |
If this method succeeds, the return value should be S_OK or GD_OK.
To check if a specific key was pressed simply compare dwKey with any value in keylist. For example, to check if "key left" has been released simply enter "if (dwKey == keylist.vkLeft)".
Override CGapiApplication::StylusDown to receive information when the stylus is pressed down.
|
virtual HRESULT StylusDown(POINT p); |
If this method succeeds, the return value should be S_OK or GD_OK.
Override CGapiApplication::StylusUp to receive information when the stylus is lifted from screen.
|
virtual HRESULT StylusUp(POINT p); |
If this method succeeds, the return value should be S_OK or GD_OK.
Override CGapiApplication::StylusDblClk to receive information when the stylus is double tapped. The flag bEnableDoubleClick must be set in m_config for this function to be called.
|
virtual HRESULT StylusDblClk(POINT p); |
If this method succeeds, the return value should be S_OK or GD_OK.
Override CGapiApplication::StylusMove to receive information when the stylus is moved across the display.
|
virtual HRESULT StylusMove(POINT p); |
If this method succeeds, the return value should be S_OK or GD_OK.
Override CGapiApplication::WindowProc to capture specific window messages.
|
virtual HRESULT WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); |
The return code depend on the value of the msg parameter.
You may want to override the default CGapiApplication::WindowProc if you want other actions to happen when a window message is received that is already captured by CGapiApplication. You may also want to capture additional window messages not already captured by CGapiApplication.
If you capture a message you are assumed to return the correct return code for that message. The return codes vary depending on the msg parameter. Always call the base class CGapiApplication::WindowProc for all messages you do not capture in your subclass.
The member variables provide additional support for advanced customization of CGapiApplication.
|