New tutorial code

Added code of new tutorials to the repository
This commit is contained in:
Joey de Vries
2015-07-15 11:48:45 +02:00
parent 05b24d9268
commit eac76c9a50
16 changed files with 1039 additions and 415 deletions

View File

@@ -19,11 +19,18 @@ public:
std::string vertexCode;
std::string fragmentCode;
std::string geometryCode;
std::ifstream vShaderFile;
std::ifstream fShaderFile;
std::ifstream gShaderFile;
// ensures ifstream objects can throw exceptions:
vShaderFile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
fShaderFile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
gShaderFile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
try
{
// Open files
std::ifstream vShaderFile(vertexPath);
std::ifstream fShaderFile(fragmentPath);
vShaderFile.open(vertexPath);
fShaderFile.open(fragmentPath);
std::stringstream vShaderStream, fShaderStream;
// Read file's buffer contents into streams
vShaderStream << vShaderFile.rdbuf();
@@ -37,14 +44,14 @@ public:
// If geometry shader path is present, also load a geometry shader
if(geometryPath != nullptr)
{
std::ifstream gShaderFile(geometryPath);
gShaderFile.open(geometryPath);
std::stringstream gShaderStream;
gShaderStream << gShaderFile.rdbuf();
gShaderFile.close();
geometryCode = gShaderStream.str();
}
}
catch (std::exception e)
catch (std::ifstream::failure e)
{
std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl;
}