//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(); } }