本文整理汇总了C++中StringStream::rdbuf方法的典型用法代码示例。如果您正苦于以下问题:C++ StringStream::rdbuf方法的具体用法?C++ StringStream::rdbuf怎么用?C++ StringStream::rdbuf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringStream
的用法示例。
在下文中一共展示了StringStream::rdbuf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createGpuProgram
//-----------------------------------------------------------------------------
GpuProgramPtr ProgramManager::createGpuProgram(Program* shaderProgram,
ProgramWriter* programWriter,
const String& language,
const String& profiles,
const StringVector& profilesList,
const String& cachePath)
{
stringstream sourceCodeStringStream;
// Generate source code.
programWriter->writeSourceCode(sourceCodeStringStream, shaderProgram);
String source = sourceCodeStringStream.str();
// Generate program name.
String programName = generateHash(source);
if (shaderProgram->getType() == GPT_VERTEX_PROGRAM)
{
programName += "_VS";
}
else if (shaderProgram->getType() == GPT_FRAGMENT_PROGRAM)
{
programName += "_FS";
}
// Try to get program by name.
HighLevelGpuProgramPtr pGpuProgram =
HighLevelGpuProgramManager::getSingleton().getByName(
programName, ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
if(pGpuProgram) {
return static_pointer_cast<GpuProgram>(pGpuProgram);
}
// Case the program doesn't exist yet.
// Create new GPU program.
pGpuProgram = HighLevelGpuProgramManager::getSingleton().createProgram(programName,
ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME, language, shaderProgram->getType());
// Case cache directory specified -> create program from file.
if (!cachePath.empty())
{
const String programFullName = programName + "." + language;
const String programFileName = cachePath + programFullName;
std::ifstream programFile;
// Check if program file already exist.
programFile.open(programFileName.c_str());
// Case we have to write the program to a file.
if (!programFile)
{
std::ofstream outFile(programFileName.c_str());
if (!outFile)
return GpuProgramPtr();
outFile << source;
outFile.close();
}
else
{
// use program file version
StringStream buffer;
programFile >> buffer.rdbuf();
source = buffer.str();
}
}
pGpuProgram->setSource(source);
pGpuProgram->setParameter("entry_point", shaderProgram->getEntryPointFunction()->getName());
if (language == "hlsl")
{
// HLSL program requires specific target profile settings - we have to split the profile string.
StringVector::const_iterator it = profilesList.begin();
StringVector::const_iterator itEnd = profilesList.end();
for (; it != itEnd; ++it)
{
if (GpuProgramManager::getSingleton().isSyntaxSupported(*it))
{
pGpuProgram->setParameter("target", *it);
break;
}
}
pGpuProgram->setParameter("enable_backwards_compatibility", "true");
pGpuProgram->setParameter("column_major_matrices", StringConverter::toString(shaderProgram->getUseColumnMajorMatrices()));
}
pGpuProgram->setParameter("profiles", profiles);
pGpuProgram->load();
// Case an error occurred.
if (pGpuProgram->hasCompileError())
{
//! [debug_break]
//.........这里部分代码省略.........