本文整理汇总了C++中CPVRTString类的典型用法代码示例。如果您正苦于以下问题:C++ CPVRTString类的具体用法?C++ CPVRTString怎么用?C++ CPVRTString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPVRTString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PVRTStringStripWhiteSpaceFromStartOf
/*!***********************************************************************
@Function PVRTStringStripWhiteSpaceFromStartOf
@Input strLine A string
@Returns Result of the white space stripping
@Description strips white space characters from the beginning of a CPVRTString.
************************************************************************/
CPVRTString PVRTStringStripWhiteSpaceFromStartOf(const CPVRTString& strLine)
{
size_t start = strLine.find_first_not_of(" \t ");
if(start!=strLine.npos)
return strLine.substr(start,strLine.length()-start+1);
return strLine;
}
示例2: InitApplication
/*!****************************************************************************
@Function InitApplication
@Return bool true if no error occured
@Description Code in InitApplication() will be called by PVRShell once per
run, before the rendering context is created.
Used to initialize variables that are not dependant on it
(e.g. external modules, loading meshes, etc.)
If the rendering context is lost, InitApplication() will
not be called again.
******************************************************************************/
bool OGLESRenderToTexture::InitApplication()
{
// Get and set the read path for content files
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
// Get and set the load/release functions for loading external files.
// In the majority of cases the PVRShell will return NULL function pointers implying that
// nothing special is required to load external files.
CPVRTResourceFile::SetLoadReleaseFunctions(PVRShellGet(prefLoadFileFunc), PVRShellGet(prefReleaseFileFunc));
/*
Loads the scene from the .pod file into a CPVRTModelPOD object.
We could also export the scene as a header file and
load it with ReadFromMemory().
*/
if(m_Scene.ReadFromFile(c_szSceneFile) != PVR_SUCCESS)
{
CPVRTString ErrorStr = "ERROR: Couldn't load '" + CPVRTString(c_szSceneFile) + "'.";
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
return true;
}
示例3: InitApplication
/*!****************************************************************************
@Function InitApplication
@Return bool true if no error occurred
@Description Code in InitApplication() will be called by PVRShell once per
run, before the rendering context is created.
Used to initialize variables that are not dependant on it
(e.g. external modules, loading meshes, etc.)
If the rendering context is lost, InitApplication() will
not be called again.
******************************************************************************/
bool OGLES2FilmTV::InitApplication()
{
// Get and set the read path for content files
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
// Get and set the load/release functions for loading external files.
// In the majority of cases the PVRShell will return NULL function pointers implying that
// nothing special is required to load external files.
CPVRTResourceFile::SetLoadReleaseFunctions(PVRShellGet(prefLoadFileFunc), PVRShellGet(prefReleaseFileFunc));
// Load the scene
if(m_Scene.ReadFromFile(c_szSceneFile) != PVR_SUCCESS)
{
CPVRTString ErrorStr = "ERROR: Couldn't load '" + CPVRTString(c_szSceneFile) + "'.";
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
// The cameras are stored in the file. We check it contains at least one.
if(m_Scene.nNumCamera == 0)
{
PVRShellSet(prefExitMessage, "ERROR: The scene does not contain a camera. Please add one and re-export.\n");
return false;
}
// We also check that the scene contains at least one light
if(m_Scene.nNumLight == 0)
{
PVRShellSet(prefExitMessage, "ERROR: The scene does not contain a light. Please add one and re-export.\n");
return false;
}
return true;
}
示例4: InitView
/*!****************************************************************************
@Function InitView
@Return bool true if no error occurred
@Description Code in InitView() will be called by PVRShell upon
initialization or after a change in the rendering context.
Used to initialize variables that are dependent on the rendering
context (e.g. textures, vertex buffers, etc.)
******************************************************************************/
bool OGLESPVRScopeRemote::InitView()
{
CPPLProcessingScoped PPLProcessingScoped(m_psSPSCommsData,
__FUNCTION__, static_cast<unsigned int>(strlen(__FUNCTION__)), m_i32FrameCounter);
CPVRTString ErrorStr;
/*
Initialize Print3D
*/
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n");
return false;
}
// Sets the clear color
glClearColor(0.6f, 0.8f, 1.0f, 1.0f);
// Enables texturing
glEnable(GL_TEXTURE_2D);
// Initialize VBO data
if(!LoadVbos(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
/*
Load textures
*/
if(!LoadTextures(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
/*
Calculate the projection and view matrices
*/
m_mProjection = PVRTMat4::PerspectiveFovRH(PVRT_PIf/6, (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight), CAM_NEAR, CAM_FAR, PVRTMat4::OGL, bRotate);
m_mView = PVRTMat4::LookAtRH(PVRTVec3(0, 0, 75.0f), PVRTVec3(0, 0, 0), PVRTVec3(0, 1, 0));
// Enable the depth test
glEnable(GL_DEPTH_TEST);
// Enable culling
glEnable(GL_CULL_FACE);
// Initialise variables used for the animation
m_fFrame = 0;
m_iTimePrev = PVRShellGetTime();
return true;
}
示例5: InitView
/*!****************************************************************************
@Function InitView
@Return bool true if no error occured
@Description Code in InitView() will be called by PVRShell upon
initialization or after a change in the rendering context.
Used to initialize variables that are dependant on the rendering
context (e.g. textures, vertex buffers, etc.)
******************************************************************************/
bool OGLES3TextureStreaming::InitView()
{
CPVRTString ErrorStr;
// Initialize VBO data
if(!LoadVbos(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
// Load textures
if(!LoadTextures(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
// Load and compile the shaders & link programs
if(!LoadShaders(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
/*
Initialize the textures used by Print3D.
To properly display text, Print3D needs to know the viewport dimensions
and whether the text should be rotated. We get the dimensions using the
shell function PVRShellGet(prefWidth/prefHeight). We can also get the
rotate parameter by checking prefIsRotated and prefFullScreen.
*/
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
if(m_Print3D.SetTextures(0, PVRShellGet(prefWidth), PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n");
return false;
}
//Set OpenGL ES render states needed for this demo
// Enable backface culling and depth test
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
// Sets the clear color
glClearColor(0.6f, 0.8f, 1.0f, 1.0f);
// Setup the AV capture
if(!m_Camera.InitialiseSession(ePVRTHWCamera_Front))
return false;
return true;
}
示例6: InitView
/*!****************************************************************************
@Function InitView
@Return bool true if no error occured
@Description Code in InitView() will be called by PVRShell upon
initialization or after a change in the rendering context.
Used to initialize variables that are dependant on the rendering
context (e.g. textures, vertex buffers, etc.)
******************************************************************************/
bool OGLES2ChameleonMan::InitView()
{
CPVRTString ErrorStr;
/*
Initialize VBO data
*/
LoadVbos();
/*
Load textures
*/
if (!LoadTextures(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
/*
Load and compile the shaders & link programs
*/
if (!LoadShaders(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
/*
Initialize Print3D
*/
// Is the screen rotated?
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n");
return false;
}
/*
Set OpenGL ES render states needed for this training course
*/
// Enable backface culling and depth test
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
// Use black as our clear colour
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
// Initialise variables used for the animation
m_iTimePrev = PVRShellGetTime();
return true;
}
示例7: PVRTStringGetFileExtension
/*!***********************************************************************
@Function PVRTStringGetFileExtension
@Input strFilePath A string
@Returns Extension
@Description Extracts the file extension from a file path.
Returns an empty CPVRTString if no extension is found.
************************************************************************/
CPVRTString PVRTStringGetFileExtension(const CPVRTString& strFilePath)
{
CPVRTString::size_type idx = strFilePath.find_last_of ( '.' );
if (idx == CPVRTString::npos)
return CPVRTString("");
else
return strFilePath.substr(idx);
}
示例8: InitApplication
/*!****************************************************************************
@Function InitApplication
@Return bool true if no error occured
@Description Code in InitApplication() will be called by PVRShell once per
run, before the rendering context is created.
Used to initialize variables that are not dependant on it
(e.g. external modules, loading meshes, etc.)
If the rendering context is lost, InitApplication() will
not be called again.
******************************************************************************/
bool OGLES3TextureStreaming::InitApplication()
{
m_i32Frame = 0;
m_puiVbo = 0;
m_puiIndexVbo = 0;
m_ulGlowTime = 0;
m_iNoiseCoordIdx = 0;
m_uiTVScreen = -1;
m_bGlowState = false;
/*
CPVRTResourceFile is a resource file helper class. Resource files can
be placed on disk next to the executable or in a platform dependent
read path. We need to tell the class where that read path is.
Additionally, it is possible to wrap files into cpp modules and
link them directly into the executable. In this case no path will be
used. Files on disk will override "memory files".
*/
// Get and set the read path for content files
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
// Get and set the load/release functions for loading external files.
// In the majority of cases the PVRShell will return NULL function pointers implying that
// nothing special is required to load external files.
CPVRTResourceFile::SetLoadReleaseFunctions(PVRShellGet(prefLoadFileFunc), PVRShellGet(prefReleaseFileFunc));
// Load the scene
if(m_Scene.ReadFromFile(c_pszSceneFile) != PVR_SUCCESS)
{
CPVRTString ErrorStr = "ERROR: Couldn't load '" + CPVRTString(c_pszSceneFile) + "'.\n";
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
// The cameras are stored in the file. We check it contains at least one.
if(m_Scene.nNumCamera == 0)
{
PVRShellSet(prefExitMessage, "ERROR: The scene does not contain a camera. Please add one and re-export.\n");
return false;
}
// We also check that the scene contains at least one light
if(m_Scene.nNumLight == 0)
{
PVRShellSet(prefExitMessage, "ERROR: The scene does not contain a light. Please add one and re-export.\n");
return false;
}
// Initialize variables used for the animation.
m_fFrame = 0.0f;
m_fBandScroll = -c_fBandWidth;
m_ulTimePrev = PVRShellGetTime();
return true;
}
示例9: PVRTStringGetFileExtension
/*!****************************************************************************
@Function LoadTextures
@Return bool true if no error occured
@Description Loads the textures required for this training course
******************************************************************************/
bool OGLES2FilmTV::LoadTextures(CPVRTString* pErrorStr)
{
/*
Loads the textures.
For a more detailed explanation, see Texturing and IntroducingPVRTools
*/
/*
Initialises an array to lookup the textures
for each material in the scene.
*/
m_puiTextureIDs = new GLuint[m_Scene.nNumMaterial];
if(!m_puiTextureIDs)
{
*pErrorStr = "ERROR: Insufficient memory.";
return false;
}
for(unsigned int i = 0; i < m_Scene.nNumMaterial; ++i)
{
m_puiTextureIDs[i] = 0;
SPODMaterial* pMaterial = &m_Scene.pMaterial[i];
if(pMaterial->nIdxTexDiffuse != -1)
{
/*
Using the tools function PVRTTextureLoadFromPVR load the textures required by the pod file.
Note: This function only loads .pvr files. You can set the textures in 3D Studio Max to .pvr
files using the PVRTexTool plug-in for max. Alternatively, the pod material properties can be
modified in PVRShaman.
*/
CPVRTString sTextureName = m_Scene.pTexture[pMaterial->nIdxTexDiffuse].pszName;
if(sTextureName == "TV.pvr")
m_uiTVScreen = i;
if(PVRTTextureLoadFromPVR(sTextureName.c_str(), &m_puiTextureIDs[i]) != PVR_SUCCESS)
{
*pErrorStr = "ERROR: Failed to load " + sTextureName + ".";
// Check to see if we're trying to load .pvr or not
CPVRTString sFileExtension = PVRTStringGetFileExtension(sTextureName);
if(sFileExtension.toLower() != "pvr")
*pErrorStr += "Note: FilmTV can only load .pvr files.";
return false;
}
}
}
return true;
}
示例10: PVRTStringGetContainingDirectoryPath
/*!***********************************************************************
@Function PVRTStringGetContainingDirectoryPath
@Input strFilePath A string
@Returns Directory
@Description Extracts the directory portion from a file path.
************************************************************************/
CPVRTString PVRTStringGetContainingDirectoryPath(const CPVRTString& strFilePath)
{
size_t i32sep = strFilePath.find_last_of('/');
if(i32sep == strFilePath.npos)
{
i32sep = strFilePath.find_last_of('\\');
if(i32sep == strFilePath.npos)
{ // can't find an actual \ or / so leave it be
return strFilePath;
}
}
return strFilePath.substr(0,i32sep);
}
示例11: PVRTStringGetFileName
/*!***********************************************************************
@Function PVRTStringGetFileName
@Input strFilePath A string
@Returns FileName
@Description Extracts the name and extension portion from a file path.
************************************************************************/
CPVRTString PVRTStringGetFileName(const CPVRTString& strFilePath)
{
size_t i32sep = strFilePath.find_last_of('/');
if(i32sep == strFilePath.npos)
{
i32sep = strFilePath.find_last_of('\\');
if(i32sep == strFilePath.npos)
{ // can't find an actual \ or / so leave it be
return strFilePath;
}
}
return strFilePath.substr(i32sep+1,strFilePath.length());
}
示例12: InitApplication
/*!****************************************************************************
@Function InitApplication
@Return bool true if no error occured
@Description Code in InitApplication() will be called by PVRShell once per
run, before the rendering context is created.
Used to initialize variables that are not dependant on it
(e.g. external modules, loading meshes, etc.)
If the rendering context is lost, InitApplication() will
not be called again.
******************************************************************************/
bool OGLESPVRScopeExample::InitApplication()
{
// At the time of writing, this counter is the USSE load for vertex + pixel processing
m_i32Counter = 46;
m_i32Group = 0;
m_i32Interval = 0;
// Get and set the read path for content files
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
// Get and set the load/release functions for loading external files.
// In the majority of cases the PVRShell will return NULL function pointers implying that
// nothing special is required to load external files.
CPVRTResourceFile::SetLoadReleaseFunctions(PVRShellGet(prefLoadFileFunc), PVRShellGet(prefReleaseFileFunc));
/*
Loads the scene from the .pod file into a CPVRTModelPOD object.
We could also export the scene as a header file and
load it with ReadFromMemory().
*/
if(m_Scene.ReadFromFile(c_szSceneFile) != PVR_SUCCESS)
{
CPVRTString ErrorStr = "ERROR: Couldn't load '" + CPVRTString(c_szSceneFile) + "'.";
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
// Process the command line
{
const unsigned int nOptNum = PVRShellGet(prefCommandLineOptNum);
const SCmdLineOpt * const psOpt = (const SCmdLineOpt*)PVRShellGet(prefCommandLineOpts);
for(unsigned int i = 0; i < nOptNum; ++i)
{
if(_stricmp(psOpt[i].pArg, "-counter") == 0 && psOpt[i].pVal)
{
m_i32Counter = atoi(psOpt[i].pVal);
}
else if(_stricmp(psOpt[i].pArg, "-group") == 0 && psOpt[i].pVal)
{
m_i32Group = atoi(psOpt[i].pVal);
}
else if(_stricmp(psOpt[i].pArg, "-interval") == 0 && psOpt[i].pVal)
{
m_i32Interval = atoi(psOpt[i].pVal);
}
}
}
return true;
}
示例13: shader
/*!***************************************************************************
@Function PVRTShaderLoadFromFile
@Input pszBinFile binary shader filename
@Input pszSrcFile source shader filename
@Input Type type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER)
@Input Format shader binary format, or 0 for source shader
@Output pObject the resulting shader object
@Output pReturnError the error message if it failed
@Input pContext Context
@Input aszDefineArray Array of defines to be pre-appended to shader string
@Input uiDefArraySize Size of the define array
@Return PVR_SUCCESS on success and PVR_FAIL on failure (also fills pReturnError)
@Description Loads a shader file into memory and passes it to the GL.
It also passes defines that need to be pre-appended to the shader before compilation.
*****************************************************************************/
EPVRTError PVRTShaderLoadFromFile( const char* const pszBinFile,
const char* const pszSrcFile,
const GLenum Type,
const GLenum Format,
GLuint* const pObject,
CPVRTString* const pReturnError,
const SPVRTContext* const pContext,
const char* const* aszDefineArray, GLuint uiDefArraySize)
{
PVRT_UNREFERENCED_PARAMETER(pContext);
*pReturnError = "";
/*
Prepending defines relies on altering the source file that is loaded.
For this reason, the function calls the source loader instead of the binary loader if defines have
been passed in.
*/
if(Format && pszBinFile && uiDefArraySize == 0)
{
CPVRTResourceFile ShaderFile(pszBinFile);
if (ShaderFile.IsOpen())
{
if(PVRTShaderLoadBinaryFromMemory(ShaderFile.DataPtr(), ShaderFile.Size(), Type, Format, pObject, pReturnError) == PVR_SUCCESS)
return PVR_SUCCESS;
}
*pReturnError += CPVRTString("Failed to open shader ") + pszBinFile + "\n";
}
CPVRTResourceFile ShaderFile(pszSrcFile);
if (!ShaderFile.IsOpen())
{
*pReturnError += CPVRTString("Failed to open shader ") + pszSrcFile + "\n";
return PVR_FAIL;
}
CPVRTString ShaderFileString;
const char* pShaderData = (const char*) ShaderFile.DataPtr();
// Is our shader resource file data null terminated?
if(pShaderData[ShaderFile.Size()-1] != '\0')
{
// If not create a temporary null-terminated string
ShaderFileString.assign(pShaderData, ShaderFile.Size());
pShaderData = ShaderFileString.c_str();
}
return PVRTShaderLoadSourceFromMemory(pShaderData, Type, pObject, pReturnError, aszDefineArray, uiDefArraySize);
}
示例14: InitView
/*!****************************************************************************
@Function InitView
@Return bool true if no error occured
@Description Code in InitView() will be called by PVRShell upon
initialization or after a change in the rendering context.
Used to initialize variables that are dependant on the rendering
context (e.g. textures, vertex buffers, etc.)
******************************************************************************/
bool OGLES2Coverflow::InitView()
{
CPVRTString ErrorStr;
// Get and set the read path for content files
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
// Get and set the load/release functions for loading external files.
// In the majority of cases the PVRShell will return NULL function pointers implying that
// nothing special is required to load external files.
CPVRTResourceFile::SetLoadReleaseFunctions(PVRShellGet(prefLoadFileFunc), PVRShellGet(prefReleaseFileFunc));
if (!LoadTextures(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
if (!LoadShaders(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n");
return false;
}
PVRTVECTOR3 vFrom = {0.0f, 0.0f, 15.0f },
vTo = { 0, 0, 0 },
vUp = { 0, 1, 0 };
PVRTMatrixPerspectiveFovRH(m_mProjection, g_FOV, f2vt((float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight)), f2vt(g_fCameraNear), f2vt(g_fCameraFar), bRotate);
PVRTMatrixLookAtRH(m_mView, vFrom, vTo, vUp);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
//this must be called after InitApplication
CreateCover();
// Enable culling
glEnable(GL_CULL_FACE);
return true;
}
示例15: InitView
/*!****************************************************************************
@Function InitView
@Return bool true if no error occured
@Description Code in InitView() will be called by PVRShell upon
initialization or after a change in the rendering context.
Used to initialize variables that are dependant on the rendering
context (e.g. textures, vertex buffers, etc.)
******************************************************************************/
bool OGLES3AlphaBlend::InitView()
{
CPVRTString ErrorStr;
/*
Initialize VBO data
*/
LoadVbos();
/*
Load textures
*/
if (!LoadTextures(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
/*
Load and compile the shaders & link programs
*/
if (!LoadShaders(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
/*
Get screen rotation state
*/
m_bRotateScreen = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
/*
Initialize Print3D
*/
if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), m_bRotateScreen) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n");
return false;
}
// Disable the depth test
glDisable(GL_DEPTH_TEST);
// Enable culling
glEnable(GL_CULL_FACE);
return true;
}