本文整理汇总了C++中Shader::CreateFromString方法的典型用法代码示例。如果您正苦于以下问题:C++ Shader::CreateFromString方法的具体用法?C++ Shader::CreateFromString怎么用?C++ Shader::CreateFromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shader
的用法示例。
在下文中一共展示了Shader::CreateFromString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//Creates a shader with defines
void gfx::ShaderProgram::CreateShader ( ifstream* FileStream, GLenum shaderType, const rString& filename,bool print, ShaderDefineContainer& container )
{
rString line;
size_t found;
rString shaderText;
getline(*FileStream, line);
shaderText += line;
shaderText += "\n";
shaderText += container.GetAllDefineLines();
shaderText += container.GetDefinesShaderStage ( shaderType );
bool end = false;
while ( !end )
{
getline ( *FileStream, line );
//search for the end of the shader
found = line.find ( "#include " );
if ( found != rString::npos )
{
int i = static_cast<int> ( found ) + 9; //found + "#include "
rString s;
while ( i < static_cast<int> ( line.length() ) )
{
s += line[i];
i++;
}
rString str = GetDir ( rString ( filename.c_str() ) ) + s;
shaderText += LoadText ( str.c_str() );
shaderText += "\n";
}
else
{
found = line.find ( "#end_shader" );
if ( found != rString::npos )
{
//break loop
end = true;
break;
}
else if ( FileStream->eof() )
{
Logger::Log( "Could not find end of file " + filename, "ShaderProgram", LogSeverity::ERROR_MSG );
return;
}
else
{
shaderText += line;
shaderText += '\n';
}
}
}
if ( shaderText.length() > 0 )
{
Shader* shader = tNew( Shader );
shader->CreateFromString ( shaderText, shaderType, filename,print );
m_Shaders.push_back ( shader );
shaderText.clear();
}
}