本文整理汇总了C++中PString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ PString::c_str方法的具体用法?C++ PString::c_str怎么用?C++ PString::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PString
的用法示例。
在下文中一共展示了PString::c_str方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
pbool PIni::load(const pchar *filename)
{
//
// Look for the file in the specified path
//
const pchar* pathList[] =
{
".",
pPathGetApplicationDirectory(),
pPathGetExternalStoragePath(),
};
for (size_t i = 0; i < sizeof(pathList) / sizeof(pathList[0]); ++i)
{
if (pathList[i] != P_NULL)
{
PString cfgPath = PString(pathList[i]) + PString(pPathGetDelimiter()) + PString(filename);
PFile *fp = pfopen(cfgPath.c_str(), "rb");
if (fp != P_NULL)
{
if (ini_parse_file((FILE *)(fp), iniHandler_internal, this) < 0)
{
PLOG_ERROR("Failed to parse %s", cfgPath.c_str());
pfclose(fp);
return false;
}
pfclose(fp);
return true;
}
}
}
//
// Look for the ini file in asset
//
PAsset asset = pAssetOpen(filename);
if (pAssetIsValid(&asset))
{
PIniBufferObject iniBufferObject;
iniBufferObject.m_buffer = (const pchar*)pAssetGetBuffer(&asset);
iniBufferObject.m_bufferSize = pAssetGetSize(&asset);
iniBufferObject.m_position = 0;
if (ini_parse_buffer(&iniBufferObject, iniHandler_internal, this) < 0)
{
PLOG_ERROR("Failed to parse %s", filename);
pAssetClose(&asset);
return false;
}
pAssetClose(&asset);
return true;
}
PLOG_ERROR("Failed to find %s", filename);
return false;
}
示例2: createFramebuffer
pbool PFrameBuffer::createFramebuffer()
{
// Create framebuffer object.
m_framebufferObject = PNEW(PGlFramebuffer);
if (!m_framebufferObject->create(m_width,
m_height,
m_colorBufferFormat,
m_depthBufferFormat,
m_stencilBufferFormat))
{
PDELETE(m_framebufferObject);
PLOG_ERROR("Failed to create framebuffer object %s", m_id);
return false;
}
// Create texture
if (m_framebufferObject)
{
PString textureName;
if (m_framebufferObject->colorBuffer())
{
textureName = m_id;
textureName += ":color-texture";
m_colorTexture = PNEW(PTexture(textureName.c_str(), this));
}
}
return true;
}
示例3: random
MyScene::MyScene(PContext *context)
: PScene("my-scene", context)
{
PRandom random(1001);
const puint32 *rect = context->rect();
for (puint32 i = 0; i < NUM_LOGOS; ++i)
{
m_velocities[i][0] = (random.getFloat32() - 0.5f) * (pfloat32)rect[2] * 0.001f;
m_velocities[i][1] = (random.getFloat32() - 0.5f) * (pfloat32)rect[3] * 0.001f;
}
// --------------------------------------------------------------
// Add camera
// --------------------------------------------------------------
PCamera *camera = PNEW(PCamera("camera", this));
camera->setFixed(true);
camera->transform().setLookAt(0.0f, 0.0f, 10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
camera->projection().window((pfloat32)rect[2], (pfloat32)rect[3]);
setMainCamera(camera);
PResourceManager* resMgr = context->module<PResourceManager>("resource-manager");
// --------------------------------------------------------------
// Scene objects
// --------------------------------------------------------------
PMaterial *material = PNEW(PMaterial("texture.pmt", resMgr));
material->parameter("texture") = resMgr->getTexture("texture.png");
material->setTransparent(true);
PAbstractGeometry *geometry = PNEW(PGeometryPlane(resMgr));
for (puint32 i = 0; i < NUM_LOGOS; ++i)
{
PString name = PString::fromUint(i);
m_logos[i] = PNEW(PDrawable(name.c_str(), this));
m_logos[i]->setGeometry(geometry);
m_logos[i]->setMaterial(material);
m_logos[i]->transform().setTranslation(pVector3(0.0f, 0.0f, 0.0f));
m_logos[i]->transform().setScaling(pVector3(64.0f, 16.0f, 1.0f));
}
setBackgroundColor(pColorRGBA(1.0f, 1.0f, 1.0f, 0.0f));
}
示例4: setName
void PNode::setName(const pchar *name)
{
if (m_name.toString() == name)
{
return ;
}
PString oldName = m_name.toString();
PASSERT(name != P_NULL);
m_name.setValue(name);
// Remove from its parent.
PStringMap<PNode*>::iterator it = m_parent->m_children.find(oldName.c_str());
PASSERT(it != m_children.end());
m_parent->m_children.erase(it);
// and insert again
m_parent->m_children.insert(const_cast<pchar *>(m_name.toString().c_str()), this);
}