/*!**************************************************************************** @file Shell/PVRShellImpl.h @copyright Copyright (c) Imagination Technologies Limited. @brief Makes programming for 3D APIs easier by wrapping surface initialization, texture allocation and other functions for use by a demo. ******************************************************************************/ #ifndef __PVRSHELLIMPL_H_ #define __PVRSHELLIMPL_H_ /***************************************************************************** ** Build options *****************************************************************************/ /***************************************************************************** ** Macros *****************************************************************************/ #define FREE(X) { if(X) { free(X); (X)=0; } } #ifndef _ASSERT #define _ASSERT(X) /**/ #endif /***************************************************************************** ** Defines *****************************************************************************/ #define STR_WNDTITLE (" - Build ") /*!*************************************************************************** @struct PVRShellData @brief Holds PVRShell internal data. *****************************************************************************/ struct PVRShellData { // Shell Interface Data char *pszAppName; /*!< Application name string. */ char *pszExitMessage; /*!< Exit message string. */ int nShellDimX; /*!< Width in pixels. */ int nShellDimY; /*!< Height in pixels. */ int nShellPosX; /*!< X position of the window. */ int nShellPosY; /*!< Y position of the window. */ bool bFullScreen; /*!< Fullscreen boolean. */ bool bLandscape; /*!< Landscape orientation boolean. false = portrait orientation. */ bool bNeedPbuffer; /*!< True if pixel buffer is needed. */ bool bNeedZbuffer; /*!< True if Z buffer is needed. */ bool bNeedStencilBuffer; /*!< True if stencil buffer is needed. */ bool bNeedPixmap; /*!< True if pixmap is needed. */ bool bNeedPixmapDisableCopy; /*!< Disables copy if true, because pixmaps are used. */ bool bLockableBackBuffer; /*!< DX9 only. Enable the use of D3DPRESENTFLAG_LOCKABLE_BACKBUFFER. */ bool bSoftwareRender; /*!< Enable the use of software rendering. */ bool bNeedAlphaFormatPre; /*!< EGL only: If true, creates the EGL surface with EGL_ALPHA_FORMAT_PRE. */ bool bUsingPowerSaving; /*!< Use power saving mode when device is not in use. */ bool bOutputInfo; /*!< Enable information to be output via PVRShellOutputDebug. For example, the depth of the colour surface created, extenstions supported and dimensions of the surface created. */ bool bNoShellSwapBuffer; /*!< Disable eglswapbuffers at the end of each frame. */ int nSwapInterval; /*!< Interval to wait for monitor vertical sync. */ int nInitRepeats; /*!< Number of times to reinitialise. */ int nDieAfterFrames; /*!< Set shell to quit after this number of frames (-1 to disable) */ float fDieAfterTime; /*!< Set shell to quit after this number of seconds (-1 to disable). */ int nAASamples; /*!< Number of anti-aliasing samples to have. 0 disables anti-aliasing. */ int nColorBPP; /*!< Color buffer size. */ int nDepthBPP; /*!< Depth buffer size. */ int nCaptureFrameStart; /*!< The frame to start capturing screenshots from. */ int nCaptureFrameStop; /*!< The frame to stop capturing screenshots from. */ int nCaptureFrameScale; /*!< Save screenshots scale factor. 1 for no scaling. */ int nPriority; /*!< EGL: If supported sets the egl context priority; 0 for low, 1 for med and 2 for high. */ bool bForceFrameTime; /*!< Overrides PVRShellGetTime to force specified frame time. May cause problems if PVRShellGetTime is called multiple times in a frame. */ int nFrameTime; /*!< How long for each frame time to last (in ms). */ bool bDiscardFrameColor; /*!< Discard color data at the end of a render. */ bool bDiscardFrameDepth; /*!< Discard depth data at the end of a render. */ bool bDiscardFrameStencil; /*!< Discard stencil data at the end of a render. */ // Internal Data bool bShellPosWasDefault; /*!< Internal. Default position for the shell was used. */ int nShellCurFrameNum; /*!< Internal. Current frame number. */ #ifdef PVRSHELL_FPS_OUTPUT bool bOutputFPS; /*!< Output frames per second. */ #endif }; /*!*************************************************************************** @class PVRShellCommandLine @brief Command-line interpreter *****************************************************************************/ class PVRShellCommandLine { public: char *m_psOrig, *m_psSplit; SCmdLineOpt *m_pOpt; int m_nOptLen, m_nOptMax; public: /*!*********************************************************************** @brief Constructor *************************************************************************/ PVRShellCommandLine(); /*!*********************************************************************** @brief Destructor *************************************************************************/ ~PVRShellCommandLine(); /*!*********************************************************************** @brief Set command-line options to pStr @param[in] pStr Input string *************************************************************************/ void Set(const char *pStr); /*!*********************************************************************** @brief Prepend command-line options to m_psOrig @param[in] pStr Input string *************************************************************************/ void Prefix(const char *pStr); /*!*********************************************************************** @brief Prepend command-line options to m_psOrig from a file @param[in] pFileName Input string *************************************************************************/ bool PrefixFromFile(const char *pFileName); /*!*********************************************************************** @brief Parse m_psOrig for command-line options and store them in m_pOpt *************************************************************************/ void Parse(); /*!*********************************************************************** @brief Apply the command-line options to shell @param[in] shell *************************************************************************/ void Apply(PVRShell &shell); }; /*!**************************************************************************** @enum EPVRShellState @brief Current Shell state *****************************************************************************/ enum EPVRShellState { ePVRShellInitApp, /*!< Initialise app */ ePVRShellInitInstance, /*!< Initialise instance */ ePVRShellRender, /*!< Render */ ePVRShellReleaseView, /*!< Release View */ ePVRShellReleaseAPI, /*!< Release API */ ePVRShellReleaseOS, /*!< Release Operating System */ ePVRShellQuitApp, /*!< Quit App */ ePVRShellExit /*!< Exit */ }; /*!*************************************************************************** @class PVRShellInit @brief The PVRShell initialisation class ****************************************************************************/ class PVRShellInit : public PVRShellInitAPI, public PVRShellInitOS { public: friend class PVRShell; friend class PVRShellInitOS; friend class PVRShellInitAPI; PVRShell *m_pShell; /*!< Our PVRShell class */ PVRShellCommandLine m_CommandLine; /*!< Our Command-line class */ bool gShellDone; /*!< Indicates that the application has finished */ EPVRShellState m_eState; /*!< Current PVRShell state */ // Key handling PVRShellKeyName nLastKeyPressed; /*!< Holds the last key pressed */ PVRShellKeyName m_eKeyMapLEFT; /*!< Holds the value to be returned when PVRShellKeyNameLEFT is requested */ PVRShellKeyName m_eKeyMapUP; /*!< Holds the value to be returned when PVRShellKeyNameUP is requested */ PVRShellKeyName m_eKeyMapRIGHT; /*!< Holds the value to be returned when PVRShellKeyNameRIGHT is requested */ PVRShellKeyName m_eKeyMapDOWN; /*!< Holds the value to be returned when PVRShellKeyNameDOWN is requested */ // Read and Write path char *m_pReadPath; /*!