PVRShell.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /******************************************************************************
  2. @File PVRShell.h
  3. @Title PVRShell
  4. @Version
  5. @Copyright Copyright (C) Imagination Technologies Limited.
  6. @Platform Independent
  7. @Description Makes programming for 3D APIs easier by wrapping surface
  8. initialization, Texture allocation and other functions for use by a demo.
  9. ******************************************************************************/
  10. #ifndef __PVRSHELL_H_
  11. #define __PVRSHELL_H_
  12. /*****************************************************************************/
  13. /*! @mainpage PVRShell
  14. ******************************************************************************
  15. @section _a_ Overview
  16. *****************************
  17. PVRShell is a C++ class used to make programming for PowerVR platforms easier and more portable.
  18. PVRShell takes care of all API and OS initialisation for the user and handles adapters, devices, screen/windows modes,
  19. resolution, buffering, depth-buffer, viewport creation & clearing, etc...
  20. PVRShell consists of 3 files: PVRShell.cpp, PVRShellOS.cpp and PVRShellAPI.cpp.
  21. PVRShellOS.cpp and PVRShellAPI.cpp are supplied per platform and contain all the code to initialise the specific
  22. API (OpenGL ES, Direct3D Mobile, etc.) and the OS (Windows, Linux, WinCE, etc.).
  23. PVRShell.cpp is where the common code resides and it interacts with the user application through an abstraction layer.
  24. A new application must link to these three files and must create a class that will inherit the PVRShell class.
  25. This class will provide five virtual functions to interface with the user.
  26. The user also needs to register his application class through the NewDemo function:
  27. @code
  28. class MyApplication: public PVRShell
  29. {
  30. public:
  31. virtual bool InitApplication();
  32. virtual bool InitView();
  33. virtual bool ReleaseView();
  34. virtual bool QuitApplication();
  35. virtual bool RenderScene();
  36. };
  37. PVRShell* NewDemo()
  38. {
  39. return new MyApplication();
  40. }
  41. @endcode
  42. @section _b_ Interface
  43. ******************************
  44. There are two functions for initialisation, two functions to release allocated resources and a render function:
  45. InitApplication() will be called by PVRShell once per run, before the graphic context is created.
  46. It is used to initialise variables that are not dependant on the rendering context (e.g. external modules, loading user data, etc.).
  47. QuitApplication() will be called by PVRShell once per run, just before exiting the program.
  48. If the graphic context is lost, QuitApplication() will not be called.
  49. InitView() will be called by PVRShell upon creation or change in the rendering context.
  50. It is used to initialise variables that are dependant on the rendering context (e.g. textures, vertex buffers, etc.).
  51. ReleaseView() will be called by PVRShell before changing to a new rendering context or
  52. when finalising the application (before calling QuitApplication).
  53. RenderScene() is the main rendering loop function of the program. This function must return FALSE when the user wants to terminate the application.
  54. PVRShell will call this function every frame and will manage relevant OS events.
  55. There are other PVRShell functions which allow the user to set his preferences and get data back from the devices:
  56. PVRShellSet() and PVRShellGet() are used to pass data to and from PVRShell. PVRShellSet() is recommended to be used
  57. in InitApplication() so the user preferences are applied at the API initialisation.
  58. There is a definition of these functions per type of data passed or returned. Please check the prefNameBoolEnum, prefNameFloatEnum,
  59. prefNameIntEnum, prefNamePtrEnum and prefNameConstPtrEnum enumerations for a full list of the data available.
  60. This is an example:
  61. @code
  62. bool MyApplication::InitApplication()
  63. {
  64. PVRShellSet (prefFullScreen, true);
  65. }
  66. bool MyApplication::RenderScene()
  67. {
  68. int dwCurrentWidth = PVRShellGet (prefHeight);
  69. int dwCurrentHeight = PVRShellGet (prefWidth);
  70. return true;
  71. }
  72. @endcode
  73. @section _c_ Helper functions
  74. *************************************
  75. The user input is abstracted with the PVRShellIsKeyPressed() function. It will not work in all devices, but we have tried to map the most
  76. relevant keys when possible. See PVRShellKeyName enumeration for the list of keys supported. This function will return true or false depending on
  77. the specified key being pressed.
  78. There are a few other helper functions supplied by PVRShell as well. These functions allow you to read the timer, to output debug information and to
  79. save a screen-shot of the current frame:
  80. PVRShellGetTime() returns time in milliseconds.
  81. PVRShellOutputDebug() will write a debug string (same format as printf) to the platform debug output.
  82. PVRShellScreenCaptureBuffer() and PVRShellWriteBMPFile() will be used to save the current frame as a BMP file. PVRShellScreenCaptureBuffer()
  83. receives a pointer to an area of memory containing the screen buffer. The memory should be freed with free() when not needed any longer.
  84. Example of screenshot:
  85. @code
  86. bool MyApplication::RenderScene()
  87. {
  88. [...]
  89. unsigned char *pLines;
  90. PVRShellScreenCaptureBuffer(PVRShellGet (prefWidth), PVRShellGet (prefHeight), &pLines);
  91. PVRShellScreenSave("myfile", pLines, NULL);
  92. free (pLines);
  93. return true;
  94. }
  95. @endcode
  96. @section _d_ Command-line
  97. *************************************
  98. Across all platforms, PVRShell takes a set of command-line arguments which allow things like the position and size of the demo
  99. to be controlled. The list below shows these options.
  100. \b -width=N Sets the horizontal viewport width to N.
  101. \b -height=N Sets the vertical viewport height to N.
  102. \b -posx=N Sets the x coordinate of the viewport.
  103. \b -posy=N Sets the y coordinate of the viewport.
  104. \b -FSAAMode=N Sets full screen antialiasing. N can be: 0=No AA , 1=2x AA , 2=4x AA.
  105. \b -fullscreen=N Enable/Disable fullscreen mode. N can be: 0=Windowed 1=Fullscreen.
  106. \b -qat=N Quits after N seconds.
  107. \b -qaf=N Quits after N frames.
  108. \b -powersaving=N Where available enable/disable power saving. N can be: 0=Disable power saving 1=Enable power saving.
  109. \b -vsync=N Where available modify the apps vsync parameters.
  110. \b -version Output the SDK version to the debug output.
  111. \b -info Output setup information (e.g. window width) to the debug output.
  112. \b -rotatekeys=N Sets the orientation of the keyboard input. N can be: 0-3, 0 is no rotation.
  113. \b -c=N Save a single screenshot or a range. e.g. -c=1-10, -c=14.
  114. \b -priority=N EGL only. Sets the priority of the EGL context.
  115. \b -colourbpp=N EGL only. When choosing an EGL config N will be used as the value for EGL_BUFFER_SIZE.
  116. \b -depthbpp=N EGL only. When choosing an EGL config N will be used as the value for EGL_DEPTH_SIZE.
  117. \b -config=N EGL only. Force the shell to use the EGL config with ID N.
  118. Example:
  119. @code
  120. Demo -width=160 -height=120 -qaf=300
  121. @endcode
  122. ******************************************************************************/
  123. // Uncomment to enable the -fps command-line option
  124. // #define PVRSHELL_FPS_OUTPUT
  125. /*****************************************************************************
  126. ** Includes
  127. *****************************************************************************/
  128. #include <stdlib.h>
  129. #define EXIT_NOERR_CODE 0
  130. #define EXIT_ERR_CODE (!EXIT_NOERR_CODE)
  131. // avoid warning about unused parameter
  132. #define PVRSHELL_UNREFERENCED_PARAMETER(x) ((void) x)
  133. /*!***********************************************************************
  134. * Keyboard mapping.
  135. ************************************************************************/
  136. enum PVRShellKeyName
  137. {
  138. PVRShellKeyNameNull,
  139. PVRShellKeyNameQUIT,
  140. PVRShellKeyNameSELECT,
  141. PVRShellKeyNameACTION1,
  142. PVRShellKeyNameACTION2,
  143. PVRShellKeyNameUP,
  144. PVRShellKeyNameDOWN,
  145. PVRShellKeyNameLEFT,
  146. PVRShellKeyNameRIGHT,
  147. PVRShellKeyNameScreenshot
  148. };
  149. enum PVRShellKeyRotate
  150. {
  151. PVRShellKeyRotateNone=0,
  152. PVRShellKeyRotate90,
  153. PVRShellKeyRotate180,
  154. PVRShellKeyRotate270
  155. };
  156. /*!***********************************************************************
  157. * Pointer button mapping.
  158. ************************************************************************/
  159. enum EPVRShellButtonState
  160. {
  161. ePVRShellButtonLeft = 0x1,
  162. ePVRShellButtonRight = 0x2,
  163. ePVRShellButtonMiddle = 0x4
  164. };
  165. /*!***********************************************************************
  166. * @Enum prefNameBoolEnum
  167. * @Brief Boolean Shell preferences.
  168. ************************************************************************/
  169. enum prefNameBoolEnum
  170. {
  171. prefFullScreen, /*!< Set to: 1 for full-screen rendering; 0 for windowed */
  172. prefIsRotated, /*!< Query this to learn whether screen is rotated */
  173. prefPBufferContext, /*!< 1 if you need pbuffer support (default is pbuffer not needed) */
  174. prefPixmapContext, /*!< 1 to use a pixmap as a render-target (default off) */
  175. prefPixmapDisableCopy, /*!< 1 to disable the copy if pixmaps are used */
  176. prefZbufferContext, /*!< 1 if you wish to have zbuffer support (default to on) */
  177. prefLockableBackBuffer, /*!< DX9 only: true to use D3DPRESENTFLAG_LOCKABLE_BACKBUFFER (default: false) */
  178. prefSoftwareRendering, /*!< 1 to select software rendering (default: off, i.e. use hardware) */
  179. prefStencilBufferContext, /*!< 1 if you wish to have stencil support (default: off) */
  180. prefOpenVGContext, /*!< EGL only: 1 to initialize OpenVG instead of OpenGL ES (default: off) */
  181. prefAlphaFormatPre, /*!< EGL only: 1 to create the EGL surface with EGL_ALPHA_FORMAT_PRE (default: 0) */
  182. prefPowerSaving, /*!< If true then the app will go into powersaving mode (if available) when not in use. */
  183. #ifdef PVRSHELL_FPS_OUTPUT
  184. prefOutputFPS, /*!< If true then the FPS are output using PVRShellOutputdebug */
  185. #endif
  186. prefOutputInfo, /*!< If true then the app will output helpful information such as colour buffer format via PVRShellOutputDebug. */
  187. prefNoShellSwapBuffer /*!< EGL: If true then the shell won't call eglswapbuffers at the end of each frame. */
  188. };
  189. /*!***********************************************************************
  190. * @Enum prefNameFloatEnum
  191. * @Brief Float Shell preferences.
  192. ************************************************************************/
  193. enum prefNameFloatEnum
  194. {
  195. prefQuitAfterTime /*!< Shell will quit after this number of seconds (-1 to disable) */
  196. };
  197. /*!***********************************************************************
  198. * @Enum prefNameIntEnum
  199. * @Brief Integer Shell preferences.
  200. ************************************************************************/
  201. enum prefNameIntEnum
  202. {
  203. prefEGLMajorVersion, /*!< EGL: returns the major version as returned by eglInitialize() */
  204. prefEGLMinorVersion, /*!< EGL: returns the minor version as returned by eglInitialize() */
  205. prefWidth, /*!< Width of render target */
  206. prefHeight, /*!< Height of render target */
  207. prefPositionX, /*!< X position of the window */
  208. prefPositionY, /*!< Y position of the window */
  209. prefQuitAfterFrame, /*!< Shell will quit after this number of frames (-1 to disable) */
  210. prefSwapInterval, /*!< 0 to preventing waiting for monitor vertical syncs */
  211. prefInitRepeats, /*!< Number of times to reinitialise (if >0 when app returns false from RenderScene(), shell will ReleaseView(), InitView() then re-enter RenderScene() loop). Decrements on each initialisation. */
  212. prefFSAAMode, /*!< Set to: 0 to disable full-screen anti-aliasing; 1 for 2x; 2 for 4x. */
  213. prefCommandLineOptNum, /*!< Returns the length of the array returned by prefCommandLineOpts */
  214. prefColorBPP, /*!< Allows you to specify a desired color buffer size e.g. 16, 32. */
  215. prefDepthBPP, /*!< Allows you to specify a desired depth buffer size e.g. 16, 24. */
  216. prefRotateKeys, /*!< Allows you to specify and retrieve how the keyboard input is transformed */
  217. prefButtonState, /*!< pointer button state */
  218. prefCaptureFrameStart, /*!< The frame to start capturing screenshots from */
  219. prefCaptureFrameStop, /*!< The frame to stop capturing screenshots at */
  220. prefPriority, /*!< EGL: If supported will set the egl context priority; 0 for low, 1 for med and 2 for high. */
  221. prefConfig, /*!< EGL: Get the chosen EGL config. */
  222. prefRequestedConfig, /*!< EGL: Force the shell to use a particular EGL config. */
  223. prefNativeDisplay /*!< EGL: Allows you to specify the native display to use if the device has more that one. */
  224. };
  225. /*!***********************************************************************
  226. * @Enum prefNamePtrEnum
  227. * @Brief Pointers/Handlers Shell preferences.
  228. ************************************************************************/
  229. enum prefNamePtrEnum
  230. {
  231. prefD3DDevice, /*!< D3D: returns the device pointer */
  232. prefEGLDisplay, /*!< EGL: returns the EGLDisplay */
  233. prefEGLSurface, /*!< EGL: returns the EGLSurface */
  234. prefHINSTANCE, /*!< Windows: returns the application instance handle */
  235. prefNativeWindowType, /*!< Returns the window handle */
  236. prefAccelerometer, /*!< Accelerometer values */
  237. prefPointerLocation, /*!< Mouse pointer/touch location values */
  238. prefPVR2DContext /*!< PVR2D: returns the PVR2D context */
  239. };
  240. /*!***********************************************************************
  241. * @Enum prefNameConstPtrEnum
  242. * @Brief Constant pointers Shell preferences.
  243. ************************************************************************/
  244. enum prefNameConstPtrEnum
  245. {
  246. prefAppName, /*!< ptrValue is char* */
  247. prefReadPath, /*!< ptrValue is char*; will include a trailing slash */
  248. prefWritePath, /*!< ptrValue is char*; will include a trailing slash */
  249. prefCommandLine, /*!< used to retrieve the entire application command line */
  250. prefCommandLineOpts, /*!< ptrValue is SCmdLineOpt*; retrieves an array of arg/value pairs (parsed from the command line) */
  251. prefExitMessage, /*!< ptrValue is char*; gives the shell a message to show on exit, typically an error */
  252. prefVersion /*!< ptrValue is char* */
  253. };
  254. /****************************************************************************
  255. PVRShell implementation Prototypes and definitions
  256. *****************************************************************************/
  257. struct PVRShellData;
  258. /*!***************************************************************************
  259. * @Class PVRShellInit
  260. *****************************************************************************/
  261. class PVRShellInit;
  262. /*!***********************************************************************
  263. * @Struct SCmdLineOpt
  264. * @Brief Stores a variable name/value pair for an individual command-line option.
  265. ************************************************************************/
  266. struct SCmdLineOpt
  267. {
  268. const char *pArg, *pVal;
  269. };
  270. /*!***************************************************************************
  271. * @Class PVRShell
  272. * @Brief Inherited by the application; responsible for abstracting the OS and API.
  273. * @Description
  274. * PVRShell is the main Shell class that an application uses. An
  275. * application should supply a class which inherits PVRShell and supplies
  276. * implementations of the virtual functions of PVRShell (InitApplication(),
  277. * QuitApplication(), InitView(), ReleaseView(), RenderScene()). Default stub
  278. * functions are supplied; this means that an application is not
  279. * required to supply a particular function if it does not need to do anything
  280. * in it.
  281. * The other, non-virtual, functions of PVRShell are utility functions that the
  282. * application may call.
  283. *****************************************************************************/
  284. class PVRShell
  285. {
  286. private:
  287. friend class PVRShellInitOS;
  288. friend class PVRShellInit;
  289. PVRShellData *m_pShellData;
  290. PVRShellInit *m_pShellInit;
  291. public:
  292. /*!***********************************************************************
  293. @Function PVRShell
  294. @Description Constructor
  295. *************************************************************************/
  296. PVRShell();
  297. /*!***********************************************************************
  298. @Function ~PVRShell
  299. @Description Destructor
  300. *************************************************************************/
  301. virtual ~PVRShell();
  302. /*
  303. PVRShell functions that the application should implement.
  304. */
  305. /*!***********************************************************************
  306. @Function InitApplication
  307. @Return true for success, false to exit the application
  308. @Description This function can be overloaded by the application. It
  309. will be called by PVRShell once only at the beginning of
  310. the PVRShell WinMain()/main() function. This function
  311. enables the user to perform any initialisation before the
  312. render API is initialised. From this function the user can
  313. call PVRShellSet() to change default values, e.g.
  314. requesting a particular resolution or device setting.
  315. *************************************************************************/
  316. virtual bool InitApplication() { return true; };
  317. /*!***********************************************************************
  318. @Function QuitApplication
  319. @Return true for success, false to exit the application
  320. @Description This function can be overloaded by the application. It
  321. will be called by PVRShell just before finishing the
  322. program. It enables the application to release any
  323. memory/resources acquired in InitApplication().
  324. *************************************************************************/
  325. virtual bool QuitApplication() { return true; };
  326. /*!***********************************************************************
  327. @Function InitView
  328. @Return true for success, false to exit the application
  329. @Description This function can be overloaded by the application. It
  330. will be called by PVRShell after the OS and rendering API
  331. are initialised, before entering the RenderScene() loop.
  332. It is called any time the rendering API is initialised,
  333. i.e. once at the beginning, and possibly again if the
  334. resolution changes, or a power management even occurs, or
  335. if the app requests a reinialisation.
  336. The application should check here the configuration of
  337. the rendering API; it is possible that requests made in
  338. InitApplication() were not successful.
  339. Since everything is initialised when this function is
  340. called, you can load textures and perform rendering API
  341. functions.
  342. *************************************************************************/
  343. virtual bool InitView() { return true; };
  344. /*!***********************************************************************
  345. @Function ReleaseView
  346. @Return true for success, false to exit the application
  347. @Description This function can be overloaded by the application. It
  348. will be called after the RenderScene() loop, before
  349. shutting down the render API. It enables the application
  350. to release any memory/resources acquired in InitView().
  351. *************************************************************************/
  352. virtual bool ReleaseView() { return true; };
  353. /*!***********************************************************************
  354. @Function RenderScene
  355. @Return true for success, false to exit the application
  356. @Description This function can be overloaded by the application.
  357. It is main application function in which you have to do your own rendering. Will be
  358. called repeatedly until the application exits.
  359. *************************************************************************/
  360. virtual bool RenderScene() { return true; };
  361. /*
  362. PVRShell functions available for the application to use.
  363. */
  364. /*!***********************************************************************
  365. @Function PVRShellSet
  366. @Input prefName Name of preference to set to value
  367. @Input value Value
  368. @Return true for success
  369. @Description This function is used to pass preferences to the PVRShell.
  370. If used, it must be called from InitApplication().
  371. *************************************************************************/
  372. bool PVRShellSet(const prefNameBoolEnum prefName, const bool value);
  373. /*!***********************************************************************
  374. @Function PVRShellSet
  375. @Input prefName Name of preference to set to value
  376. @Input value Value
  377. @Return true for success
  378. @Description This function is used to pass preferences to the PVRShell.
  379. If used, it must be called from InitApplication().
  380. *************************************************************************/
  381. bool PVRShellSet(const prefNameFloatEnum prefName, const float value);
  382. /*!***********************************************************************
  383. @Function PVRShellSet
  384. @Input prefName Name of preference to set to value
  385. @Input value Value
  386. @Return true for success
  387. @Description This function is used to pass preferences to the PVRShell.
  388. If used, it must be called from InitApplication().
  389. *************************************************************************/
  390. bool PVRShellSet(const prefNameIntEnum prefName, const int value);
  391. /*!***********************************************************************
  392. @Function PVRShellSet
  393. @Input prefName Name of preference to set to value
  394. @Input ptrValue Value
  395. @Return true for success
  396. @Description This function is used to pass preferences to the PVRShell.
  397. If used, it must be called from InitApplication().
  398. *************************************************************************/
  399. bool PVRShellSet(const prefNamePtrEnum prefName, const void * const ptrValue);
  400. /*!***********************************************************************
  401. @Function PVRShellSet
  402. @Input prefName Name of preference to set to value
  403. @Input ptrValue Value
  404. @Return true for success
  405. @Description This function is used to pass preferences to the PVRShell.
  406. If used, it must be called from InitApplication().
  407. *************************************************************************/
  408. bool PVRShellSet(const prefNameConstPtrEnum prefName, const void * const ptrValue);
  409. /*!***********************************************************************
  410. @Function PVRShellGet
  411. @Input prefName Name of preference to set to value
  412. @Return Value asked for.
  413. @Description This function is used to get parameters from the PVRShell
  414. It can be called from any where in the program.
  415. *************************************************************************/
  416. bool PVRShellGet(const prefNameBoolEnum prefName) const;
  417. /*!***********************************************************************
  418. @Function PVRShellGet
  419. @Input prefName Name of preference to set to value
  420. @Return Value asked for.
  421. @Description This function is used to get parameters from the PVRShell
  422. It can be called from any where in the program.
  423. *************************************************************************/
  424. float PVRShellGet(const prefNameFloatEnum prefName) const;
  425. /*!***********************************************************************
  426. @Function PVRShellGet
  427. @Input prefName Name of preference to set to value
  428. @Return Value asked for.
  429. @Description This function is used to get parameters from the PVRShell
  430. It can be called from any where in the program.
  431. *************************************************************************/
  432. int PVRShellGet(const prefNameIntEnum prefName) const;
  433. /*!***********************************************************************
  434. @Function PVRShellGet
  435. @Input prefName Name of preference to set to value
  436. @Return Value asked for.
  437. @Description This function is used to get parameters from the PVRShell
  438. It can be called from any where in the program.
  439. *************************************************************************/
  440. void *PVRShellGet(const prefNamePtrEnum prefName) const;
  441. /*!***********************************************************************
  442. @Function PVRShellGet
  443. @Input prefName Name of preference to set to value
  444. @Return Value asked for.
  445. @Description This function is used to get parameters from the PVRShell
  446. It can be called from any where in the program.
  447. *************************************************************************/
  448. const void *PVRShellGet(const prefNameConstPtrEnum prefName) const;
  449. /*!***********************************************************************
  450. @Function PVRShellScreenCaptureBuffer
  451. @Input Width size of image to capture (relative to 0,0)
  452. @Input Height size of image to capture (relative to 0,0)
  453. @Modified pLines receives a pointer to an area of memory containing the screen buffer.
  454. @Return true for success
  455. @Description It will be stored as 24-bit per pixel, 8-bit per chanel RGB. The
  456. memory should be freed with free() when no longer needed.
  457. *************************************************************************/
  458. bool PVRShellScreenCaptureBuffer(const int Width, const int Height, unsigned char **pLines);
  459. /*!***********************************************************************
  460. @Function PVRShellScreenSave
  461. @Input fname base of file to save screen to
  462. @Modified pLines image data to write out (24bpp, 8-bit per channel RGB)
  463. @Output ofname If non-NULL, receives the filename actually used
  464. @Return true for success
  465. @Description Writes out the image data to a BMP file with basename
  466. fname. The file written will be fname suffixed with a
  467. number to make the file unique.
  468. For example, if fname is "abc", this function will attempt
  469. to save to "abc0000.bmp"; if that file already exists, it
  470. will try "abc0001.bmp", repeating until a new filename is
  471. found. The final filename used is returned in ofname.
  472. *************************************************************************/
  473. int PVRShellScreenSave(
  474. const char * const fname,
  475. const unsigned char * const pLines,
  476. char * const ofname = NULL);
  477. /*!***********************************************************************
  478. @Function PVRShellWriteBMPFile
  479. @Input pszFilename file to save screen to
  480. @Input uWidth the width of the data
  481. @Input uHeight the height of the data
  482. @Input pImageData image data to write out (24bpp, 8-bit per channel RGB)
  483. @Return 0 on success
  484. @Description Writes out the image data to a BMP file with name fname.
  485. *************************************************************************/
  486. int PVRShellWriteBMPFile(
  487. const char * const pszFilename,
  488. const unsigned long uWidth,
  489. const unsigned long uHeight,
  490. const void * const pImageData);
  491. /*!***********************************************************************
  492. @Function PVRShellOutputDebug
  493. @Input format printf style format followed by arguments it requires
  494. @Description Writes the resultant string to the debug output (e.g. using
  495. printf(), OutputDebugString(), ...). Check the SDK release notes for
  496. details on how the string is output.
  497. *************************************************************************/
  498. void PVRShellOutputDebug(char const * const format, ...) const;
  499. /*!***********************************************************************
  500. @Function PVRShellGetTime
  501. @Returns A value which increments once per millisecond.
  502. @Description The number itself should be considered meaningless; an
  503. application should use this function to determine how much
  504. time has passed between two points (e.g. between each
  505. frame).
  506. *************************************************************************/
  507. unsigned long PVRShellGetTime();
  508. /*!***********************************************************************
  509. @Function PVRShellIsKeyPressed
  510. @Input key Code of the key to test
  511. @Return true if key was pressed
  512. @Description Check if a key was pressed. The keys on various devices
  513. are mapped to the PVRShell-supported keys (listed in @a PVRShellKeyName) in
  514. a platform-dependent manner, since most platforms have different input
  515. devices. Check the SDK release notes for details on how the enum values
  516. map to your device's input device.
  517. *************************************************************************/
  518. bool PVRShellIsKeyPressed(const PVRShellKeyName key);
  519. };
  520. /****************************************************************************
  521. ** Declarations for functions that the scene file must supply
  522. ****************************************************************************/
  523. /*!***************************************************************************
  524. @Function NewDemo
  525. @Return The demo supplied by the user
  526. @Description This function must be implemented by the user of the shell.
  527. The user should return its PVRShell object defining the
  528. behaviour of the application
  529. *****************************************************************************/
  530. PVRShell* NewDemo();
  531. #endif /* __PVRSHELL_H_ */
  532. /*****************************************************************************
  533. End of file (PVRShell.h)
  534. *****************************************************************************/