PowerVR Software Development Kit |
00001 /*!*************************************************************************** 00002 @File PVRShellImpl.h 00003 00004 @Brief Shell to make programming 3D APIs easier. 00005 00006 @Date 26/01/2005 00007 00008 @Copyright Copyright (C) 2005 - 2006 by Imagination Technologies Limited. 00009 00010 @Platform Independant 00011 00012 @Description Makes programming for 3D APIs easier by wrapping surface initialization, 00013 Texture allocation and other functions for use by a demo. 00014 *****************************************************************************/ 00015 00016 #ifndef __PVRSHELLIMPL_H_ 00017 #define __PVRSHELLIMPL_H_ 00018 00019 /***************************************************************************** 00020 ** Build options 00021 *****************************************************************************/ 00022 00023 // Time, in milliseconds (ms) between reporting the FPS 00024 //#define PVRSHELL_FPS_OUTPUT (1000) 00025 00026 /***************************************************************************** 00027 ** Macros 00028 *****************************************************************************/ 00029 #define FREE(X) { if(X) { free(X); (X)=0; } } 00030 00031 #ifndef _ASSERT 00032 #define _ASSERT(X) 00033 #endif 00034 00035 /***************************************************************************** 00036 ** Defines 00037 *****************************************************************************/ 00038 #define STR_WNDTITLE (" - Build ") 00039 00040 /*!**************************************************************************** 00041 * @Struct PVRShellData 00042 * @Brief Holds PVRShell internal data. 00043 *****************************************************************************/ 00044 struct PVRShellData 00045 { 00046 // Shell Interface Data 00047 char *gAppName; 00048 char *gExitMessage; 00049 int gShellDimX; 00050 int gShellDimY; 00051 int gShellPosX; 00052 int gShellPosY; 00053 bool gFullScreen; 00054 bool gNeedPbuffer; 00055 bool gNeedZbuffer; 00056 bool gNeedStencilBuffer; 00057 bool gNeedPixmap; 00058 bool gNeedPixmapDisableCopy; 00059 bool gLockableBackBuffer; 00060 bool gSoftwareRender; 00061 bool gNeedOpenVG; 00062 int gSwapInterval; 00063 int gInitRepeats; 00064 int gDieAfterFrames; 00065 float gDieAfterTime; 00066 int gFSAAMode; 00067 00068 // Internal Data 00069 bool gIsRotated; 00070 bool gShellPosWasDefault; 00071 int gShellCurFrameNum; 00072 }; 00073 00074 /*!**************************************************************************** 00075 * @Class PVRShellCommandLine 00076 * @Brief Command-line interpreter 00077 *****************************************************************************/ 00078 class PVRShellCommandLine 00079 { 00080 public: 00081 char *m_psOrig, *m_psSplit; 00082 SCmdLineOpt *m_pOpt; 00083 int m_nOptLen, m_nOptMax; 00084 00085 public: 00086 PVRShellCommandLine(); 00087 ~PVRShellCommandLine(); 00088 00089 void Parse(const char *pStr); 00090 void Apply(PVRShell &shell); 00091 }; 00092 00093 /*!**************************************************************************** 00094 * @Enum EPVRShellState 00095 * @Brief Current Shell state 00096 *****************************************************************************/ 00097 enum EPVRShellState { 00098 ePVRShellInitApp, 00099 ePVRShellInitInstance, 00100 ePVRShellRender, 00101 ePVRShellReleaseView, 00102 ePVRShellReleaseAPI, 00103 ePVRShellReleaseOS, 00104 ePVRShellQuitApp, 00105 ePVRShellExit 00106 }; 00107 00108 /*!*************************************************************************** 00109 * @Enum EPVRShellState 00110 * @Brief Abstract API and OS code. 00111 ****************************************************************************/ 00112 class PVRShellInit : public PVRShellInitAPI, public PVRShellInitOS 00113 { 00114 public: 00115 friend class PVRShell; 00116 friend class PVRShellInitOS; 00117 friend class PVRShellInitAPI; 00118 00119 PVRShell *m_pShell; 00120 PVRShellCommandLine m_CommandLine; 00122 bool gShellDone; 00123 EPVRShellState m_eState; 00125 // Key handling 00126 PVRShellKeyName nLastKeyPressed; 00128 // Data path 00129 char *m_pDataPath; 00131 #ifdef PVRSHELL_FPS_OUTPUT 00132 // Frames per second (FPS) 00133 int m_nFpsFrameCnt, m_nFpsTimePrev; 00134 #endif 00135 00136 public: 00137 00138 /*!*********************************************************************** 00139 @Function PVRShellInit 00140 @description PVRShellInit Constructor 00141 *************************************************************************/ 00142 PVRShellInit(); 00143 00144 /*!*********************************************************************** 00145 @Function ~PVRShellInit 00146 @description PVRShellInit Destructor 00147 *************************************************************************/ 00148 ~PVRShellInit(); 00149 00150 /*!*********************************************************************** 00151 @Function Init 00152 @description PVRShell Initialisation. 00153 *************************************************************************/ 00154 void Init(PVRShell &Shell); 00155 00156 /*!*********************************************************************** 00157 @Function CommandLine 00158 @description Receives the command-line from the application. 00159 *************************************************************************/ 00160 void CommandLine(char *str); 00161 void CommandLine(int argc, char **argv); 00162 00163 /*!*********************************************************************** 00164 @Function DoIsKeyPressed 00165 @description Return 'true' if the specific key has been pressed. 00166 *************************************************************************/ 00167 bool DoIsKeyPressed(const PVRShellKeyName key); 00168 00169 /*!*********************************************************************** 00170 @Function KeyPressed 00171 @description Used by the OS-specific code to tell the Shell that a key has been pressed. 00172 *************************************************************************/ 00173 void KeyPressed(PVRShellKeyName key); 00174 00175 /*!*********************************************************************** 00176 @Function GetDataPath 00177 @description Used by the OS-specific code to tell the Shell where the actual application resides. 00178 *************************************************************************/ 00179 const char *GetDataPath() const; 00180 00181 /*!****************************************************************************** 00182 @Function SetAppName 00183 @Description Sets the default app name (to be displayed by the OS) 00184 *******************************************************************************/ 00185 void SetAppName(const char * const str); 00186 00187 /*!*********************************************************************** 00188 @Function SetDataPath 00189 @description Set the path to where the application expects the data. 00190 *************************************************************************/ 00191 void SetDataPath(const char * const str); 00192 00193 /*!*********************************************************************** 00194 @Function Run 00195 @description Called from the OS-specific code to perform the render. 00196 When this fucntion fails the application will quit. 00197 *************************************************************************/ 00198 bool Run(); 00199 00200 #ifdef PVRSHELL_FPS_OUTPUT 00201 /*!**************************************************************************** 00202 @Function FpsUpdate 00203 @Description Calculates a value for frames-per-second (FPS). 00204 *****************************************************************************/ 00205 void FpsUpdate(); 00206 #endif 00207 00208 /* 00209 OS functionality 00210 */ 00211 00212 /*!*********************************************************************** 00213 @Function OsInit 00214 @description Initialisation for OS-specific code. 00215 *************************************************************************/ 00216 void OsInit(); 00217 00218 /*!*********************************************************************** 00219 @Function OsInitOS 00220 @description Saves instance handle and creates main window 00221 In this function, we save the instance handle in a global variable and 00222 create and display the main program window. 00223 *************************************************************************/ 00224 bool OsInitOS(); 00225 00226 /*!*********************************************************************** 00227 @Function OsReleaseOS 00228 @description Destroys main window 00229 *************************************************************************/ 00230 void OsReleaseOS(); 00231 00232 /*!*********************************************************************** 00233 @Function OsExit 00234 @description Destroys main window 00235 *************************************************************************/ 00236 void OsExit(); 00237 00238 /*!*********************************************************************** 00239 @Function OsDoInitAPI 00240 @description Perform GL initialization and bring up window / fullscreen 00241 *************************************************************************/ 00242 bool OsDoInitAPI(); 00243 00244 /*!*********************************************************************** 00245 @Function OsDoReleaseAPI 00246 @description Clean up after we're done 00247 *************************************************************************/ 00248 void OsDoReleaseAPI(); 00249 00250 /*!*********************************************************************** 00251 @Function OsRenderComplete 00252 @description Main message loop / render loop 00253 *************************************************************************/ 00254 void OsRenderComplete(); 00255 00256 /*!*********************************************************************** 00257 @Function OsPixmapCopy 00258 @description When using pixmaps, copy the render to the display 00259 *************************************************************************/ 00260 bool OsPixmapCopy(); 00261 00262 /*!*********************************************************************** 00263 @Function OsGetNativeDisplayType 00264 @description Called from InitAPI() to get the NativeDisplayType 00265 *************************************************************************/ 00266 void *OsGetNativeDisplayType(); 00267 00268 /*!*********************************************************************** 00269 @Function OsGetNativePixmapType 00270 @description Called from InitAPI() to get the NativePixmapType 00271 *************************************************************************/ 00272 void *OsGetNativePixmapType(); 00273 00274 /*!*********************************************************************** 00275 @Function OsGetNativeWindowType 00276 @description Called from InitAPI() to get the NativeWindowType 00277 *************************************************************************/ 00278 void *OsGetNativeWindowType(); 00279 00280 /*!*********************************************************************** 00281 @Function OsGet 00282 @Description Retrieves OS-specific data 00283 *************************************************************************/ 00284 bool OsGet(const prefNamePtrEnum prefName, void **pp); 00285 00286 /*!*********************************************************************** 00287 @Function OsDisplayDebugString 00288 @Description Prints a debug string 00289 *************************************************************************/ 00290 void OsDisplayDebugString(char const * const str); 00291 00292 /*!*********************************************************************** 00293 @Function OsGetTime 00294 @Description Gets the time in milliseconds since the beginning of the application 00295 *************************************************************************/ 00296 unsigned long OsGetTime(); 00297 00298 /* 00299 API functionality 00300 */ 00301 /*!*********************************************************************** 00302 @Function ApiInitAPI 00303 @description Initialisation for API-specific code. 00304 *************************************************************************/ 00305 bool ApiInitAPI(); 00306 00307 /*!*********************************************************************** 00308 @Function ApiReleaseAPI 00309 @description Releases all resources allocated by the API. 00310 *************************************************************************/ 00311 void ApiReleaseAPI(); 00312 00313 /*!*********************************************************************** 00314 @Function ApiScreenCaptureBuffer 00315 @description API-specific function to store the current content of the 00316 FrameBuffer into the memory allocated by the user. 00317 *************************************************************************/ 00318 bool ApiScreenCaptureBuffer(int Width,int Height,unsigned char *pBuf); 00319 00320 /*!*********************************************************************** 00321 @Function ApiRenderComplete 00322 @description Perform API operations required after a frame has finished (e.g., flipping). 00323 *************************************************************************/ 00324 void ApiRenderComplete(); 00325 00326 /*!*********************************************************************** 00327 @Function ApiGet 00328 @description Get parameters which are specific of the API. 00329 *************************************************************************/ 00330 bool ApiGet(const prefNamePtrEnum prefName, void **pp); 00331 00332 /*!*********************************************************************** 00333 @Function ApiActivatePreferences 00334 @description Run specific API code to perform the operations requested in preferences. 00335 *************************************************************************/ 00336 void ApiActivatePreferences(); 00337 }; 00338 00339 #endif /* __PVRSHELLIMPL_H_ */ 00340 00341 /***************************************************************************** 00342 End of file (PVRShellImpl.h) 00343 *****************************************************************************/
Copyright © 1999-2006, PowerVR Technologies and partners. PowerVR Technologies is a division of Imagination Technologies Ltd.