I've been getting this error: basic_ios::clear: iostream error
. I don't know why this is occurring when I'm simply reading a file's buffer contents into streams and into strings. Why is it occurring?
vShaderFile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
fShaderfile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
try{
vShaderFile.open(vertexpath);
fShaderfile.open(fragmentpath);
std::stringstream vShaderStream, fShaderStream;
// read file's buffer contents into streams
vShaderStream << vShaderFile.rdbuf();
fShaderStream << fShaderfile.rdbuf();
// close file handlers
vShaderFile.close();
fShaderfile.close();
// convert stream into string
vertexCode = vShaderStream.str();
fragmentCode = fShaderStream.str();
}catch(std::ifstream::failure& e){
std::cout << "Shader file read error: " << e.what() << std::endl;
}
vShaderFile
and fShaderfile
are both std::ifstream
's.