123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497 |
- /******************************************************************************
- @File PVRShellImpl.h
- @Title PVRShellImpl
- @Version
- @Copyright Copyright (C) Imagination Technologies Limited.
- @Platform Independent
- @Description 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;
- char *pszExitMessage;
- int nShellDimX;
- int nShellDimY;
- int nShellPosX;
- int nShellPosY;
- bool bFullScreen;
- bool bLandscape;
- bool bNeedPbuffer;
- bool bNeedZbuffer;
- bool bNeedStencilBuffer;
- bool bNeedPixmap;
- bool bNeedPixmapDisableCopy;
- bool bLockableBackBuffer;
- bool bSoftwareRender;
- bool bNeedOpenVG;
- bool bNeedAlphaFormatPre;
- bool bUsingPowerSaving;
- bool bOutputInfo;
- bool bNoShellSwapBuffer;
- int nSwapInterval;
- int nInitRepeats;
- int nDieAfterFrames;
- float fDieAfterTime;
- int nFSAAMode;
- int nColorBPP;
- int nDepthBPP;
- int nCaptureFrameStart;
- int nCaptureFrameStop;
- int nPriority;
- // Internal Data
- bool bShellPosWasDefault;
- int nShellCurFrameNum;
- #ifdef PVRSHELL_FPS_OUTPUT
- bool bOutputFPS;
- #endif
- };
- /*!***************************************************************************
- @Class PVRShellCommandLine
- @Brief Command-line interpreter
- *****************************************************************************/
- class PVRShellCommandLine
- {
- public:
- char *m_psOrig, *m_psSplit;
- SCmdLineOpt *m_pOpt;
- int m_nOptLen, m_nOptMax;
- public:
- /*!***********************************************************************
- @Function PVRShellCommandLine
- @Description Constructor
- *************************************************************************/
- PVRShellCommandLine();
- /*!***********************************************************************
- @Function PVRShellCommandLine
- @Description Destructor
- *************************************************************************/
- ~PVRShellCommandLine();
- /*!***********************************************************************
- @Function Set
- @Input pStr Input string
- @Description Set command-line options to pStr
- *************************************************************************/
- void Set(const char *pStr);
- /*!***********************************************************************
- @Function Set
- @Input pStr Input string
- @Description Prepend command-line options to m_psOrig
- *************************************************************************/
- void Prefix(const char *pStr);
- /*!***********************************************************************
- @Function PrependFromFile
- @Input pFileName Input string
- @Description Prepend command-line options to m_psOrig from a file
- *************************************************************************/
- bool PrefixFromFile(const char *pFileName);
- /*!***********************************************************************
- @Function Parse
- @Description Parse m_psOrig for command-line options and store them in m_pOpt
- *************************************************************************/
- void Parse();
- /*!***********************************************************************
- @Function Apply
- @Input shell
- @Description Apply the command-line options to shell
- *************************************************************************/
- void Apply(PVRShell &shell);
- };
- /*!****************************************************************************
- * @Enum EPVRShellState
- * @Brief Current Shell state
- *****************************************************************************/
- enum EPVRShellState {
- ePVRShellInitApp,
- ePVRShellInitInstance,
- ePVRShellRender,
- ePVRShellReleaseView,
- ePVRShellReleaseAPI,
- ePVRShellReleaseOS,
- ePVRShellQuitApp,
- ePVRShellExit
- };
- /*!***************************************************************************
- * @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; /*!<Holds the path where the application will read the data from */
- char *m_pWritePath; /*!<Holds the path where the application will write the data to */
- unsigned long m_u32ShellStartTime; /*!<Holds the time when the PVRShell instance was created */
- #ifdef PVRSHELL_FPS_OUTPUT
- // Frames per second (FPS)
- int m_i32FpsFrameCnt, m_i32FpsTimePrev;
- #endif
- public:
- /*!***********************************************************************
- @Function PVRShellInit
- @description Constructor
- *************************************************************************/
- PVRShellInit();
- /*!***********************************************************************
- @Function ~PVRShellInit
- @description Destructor
- *************************************************************************/
- ~PVRShellInit();
- /*!***********************************************************************
- @Function Init
- @Returns True on success and false on failure
- @description PVRShell Initialisation.
- *************************************************************************/
- bool Init();
- /*!***********************************************************************
- @Function Deinit
- @Description PVRShell Deinitialisation.
- *************************************************************************/
- void Deinit();
- /*!***********************************************************************
- @Function CommandLine
- @Input str A string containing the command-line
- @description Receives the command-line from the application.
- *************************************************************************/
- void CommandLine(char *str);
- /*!***********************************************************************
- @Function CommandLine
- @Input argc Number of strings in argv
- @Input argv An array of strings
- @description Receives the command-line from the application.
- *************************************************************************/
- void CommandLine(int argc, char **argv);
- /*!***********************************************************************
- @Function DoIsKeyPressed
- @Input key The key we're querying for
- @description Return 'true' if the specific key has been pressed.
- *************************************************************************/
- bool DoIsKeyPressed(const PVRShellKeyName key);
- /*!***********************************************************************
- @Function KeyPressed
- @Input key The key that has been pressed
- @description Used by the OS-specific code to tell the Shell that a key has been pressed.
- *************************************************************************/
- void KeyPressed(PVRShellKeyName key);
- /*!***********************************************************************
- @Function GetReadPath
- @Returns A path the application is capable of reading from
- @description Used by the OS-specific code to tell the Shell where to read external files from
- *************************************************************************/
- const char *GetReadPath() const;
- /*!***********************************************************************
- @Function GetWritePath
- @Returns A path the applications is capable of writing to
- @description Used by the OS-specific code to tell the Shell where to write to
- *************************************************************************/
- const char *GetWritePath() const;
- /*!******************************************************************************
- @Function SetAppName
- @Input str The application name
- @Description Sets the default app name (to be displayed by the OS)
- *******************************************************************************/
- void SetAppName(const char * const str);
- /*!***********************************************************************
- @Function SetReadPath
- @Input str The read path
- @description Set the path to where the application expects to read from.
- *************************************************************************/
- void SetReadPath(const char * const str);
- /*!***********************************************************************
- @Function SetWritePath
- @Input str The write path
- @description Set the path to where the application expects to write to.
- *************************************************************************/
- void SetWritePath(const char * const str);
- /*!***********************************************************************
- @Function Run
- @description Called from the OS-specific code to perform the render.
- When this fucntion fails the application will quit.
- *************************************************************************/
- bool Run();
- /*!***********************************************************************
- @Function OutputInfo
- @description When prefOutputInfo is set to true this function outputs
- various pieces of non-API dependent information via
- PVRShellOutputDebug.
- *************************************************************************/
- void OutputInfo();
- /*!***********************************************************************
- @Function OutputAPIInfo
- @description When prefOutputInfo is set to true this function outputs
- various pieces of API dependent information via
- PVRShellOutputDebug.
- *************************************************************************/
- void OutputAPIInfo();
- #ifdef PVRSHELL_FPS_OUTPUT
- /*!****************************************************************************
- @Function FpsUpdate
- @Description Calculates a value for frames-per-second (FPS).
- *****************************************************************************/
- void FpsUpdate();
- #endif
- /*
- OS functionality
- */
- /*!***********************************************************************
- @Function OsInit
- @description Initialisation for OS-specific code.
- *************************************************************************/
- void OsInit();
- /*!***********************************************************************
- @Function OsInitOS
- @description Saves instance handle and creates main window
- In this function, we save the instance handle in a global variable and
- create and display the main program window.
- *************************************************************************/
- bool OsInitOS();
- /*!***********************************************************************
- @Function OsReleaseOS
- @description Destroys main window
- *************************************************************************/
- void OsReleaseOS();
- /*!***********************************************************************
- @Function OsExit
- @description Destroys main window
- *************************************************************************/
- void OsExit();
- /*!***********************************************************************
- @Function OsDoInitAPI
- @description Perform API initialization and bring up window / fullscreen
- *************************************************************************/
- bool OsDoInitAPI();
- /*!***********************************************************************
- @Function OsDoReleaseAPI
- @description Clean up after we're done
- *************************************************************************/
- void OsDoReleaseAPI();
- /*!***********************************************************************
- @Function OsRenderComplete
- @description Main message loop / render loop
- *************************************************************************/
- void OsRenderComplete();
- /*!***********************************************************************
- @Function OsPixmapCopy
- @description When using pixmaps, copy the render to the display
- *************************************************************************/
- bool OsPixmapCopy();
- /*!***********************************************************************
- @Function OsGetNativeDisplayType
- @description Called from InitAPI() to get the NativeDisplayType
- *************************************************************************/
- void *OsGetNativeDisplayType();
- /*!***********************************************************************
- @Function OsGetNativePixmapType
- @description Called from InitAPI() to get the NativePixmapType
- *************************************************************************/
- void *OsGetNativePixmapType();
- /*!***********************************************************************
- @Function OsGetNativeWindowType
- @description Called from InitAPI() to get the NativeWindowType
- *************************************************************************/
- void *OsGetNativeWindowType();
- /*!***********************************************************************
- @Function OsGet
- @Input prefName Name of value to get
- @Modified pn A pointer set to the value asked for
- @Returns true on success
- @Description Retrieves OS-specific data
- *************************************************************************/
- bool OsGet(const prefNameIntEnum prefName, int *pn);
- /*!***********************************************************************
- @Function OsGet
- @Input prefName Name of value to get
- @Modified pp A pointer set to the value asked for
- @Returns true on success
- @Description Retrieves OS-specific data
- *************************************************************************/
- bool OsGet(const prefNamePtrEnum prefName, void **pp);
- /*!***********************************************************************
- @Function OsSet
- @Input prefName Name of value to set
- @Input i32Value The value to set our named value to
- @Returns true on success
- @Description Sets OS-specific data
- *************************************************************************/
- bool OsSet(const prefNameIntEnum prefName, const int i32Value);
- /*!***********************************************************************
- @Function OsDisplayDebugString
- @Input str The debug string to display
- @Description Prints a debug string
- *************************************************************************/
- void OsDisplayDebugString(char const * const str);
- /*!***********************************************************************
- @Function OsGetTime
- @Description Gets the time in milliseconds
- *************************************************************************/
- unsigned long OsGetTime();
- /*
- API functionality
- */
- /*!***********************************************************************
- @Function ApiInitAPI
- @description Initialisation for API-specific code.
- *************************************************************************/
- bool ApiInitAPI();
- /*!***********************************************************************
- @Function ApiReleaseAPI
- @description Releases all resources allocated by the API.
- *************************************************************************/
- void ApiReleaseAPI();
- /*!***********************************************************************
- @Function ApiScreenCaptureBuffer
- @Input Width Width of the region to capture
- @Input Height Height of the region to capture
- @Modified pBuf A buffer to put the screen capture into
- @description API-specific function to store the current content of the
- FrameBuffer into the memory allocated by the user.
- *************************************************************************/
- bool ApiScreenCaptureBuffer(int Width,int Height,unsigned char *pBuf);
- /*!***********************************************************************
- @Function ApiRenderComplete
- @description Perform API operations required after a frame has finished (e.g., flipping).
- *************************************************************************/
- void ApiRenderComplete();
- /*!***********************************************************************
- @Function ApiSet
- @Input prefName Name of value to set
- @Modified i32Value Value to set it to
- @description Set parameters which are specific to the API.
- *************************************************************************/
- bool ApiSet(const prefNameIntEnum prefName, const int i32Value);
- /*!***********************************************************************
- @Function ApiGet
- @Input prefName Name of value to get
- @Modified pn A pointer set to the value asked for
- @description Get parameters which are specific to the API.
- *************************************************************************/
- bool ApiGet(const prefNameIntEnum prefName, int *pn);
- /*!***********************************************************************
- @Function ApiGet
- @Input prefName Name of value to get
- @Modified pp A pointer set to the value asked for
- @description Get parameters which are specific to the API.
- *************************************************************************/
- bool ApiGet(const prefNamePtrEnum prefName, void **pp);
- /*!***********************************************************************
- @Function ApiActivatePreferences
- @description Run specific API code to perform the operations requested in preferences.
- *************************************************************************/
- void ApiActivatePreferences();
- };
- #endif /* __PVRSHELLIMPL_H_ */
- /*****************************************************************************
- End of file (PVRShellImpl.h)
- *****************************************************************************/
|