Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const char* read_from_file(const GLchar* shader_path)
- {
- std::string shader_code;
- std::ifstream shader_file;
- shader_file.exceptions (std::ifstream::failbit | std::ifstream::badbit);
- try
- {
- // open files
- shader_file.open(shader_path);
- std::stringstream shader_stream;
- // read file's buffer contents into streams
- shader_stream << shader_file.rdbuf();
- shader_file.close();
- // convert stream into string
- shader_code = shader_stream.str();
- }
- catch(std::ifstream::failure &e)
- {
- std::cout << "ERROR: Shader file not succesfully read. Check path to shader source file!" << std::endl;
- };
- const char* final_shader_code = shader_code.c_str();
- return final_shader_code;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement