Ejemplo n.º 1
0
GLuint Shaders::loadShadersFromFile(const std::string& vertexFilePath, const std::string& fragmentFilePath)
{
    try {
        return loadShaderFromString(contentsOfFile(vertexFilePath),
                                    contentsOfFile(fragmentFilePath));
    } catch (std::exception& e) {
        std::cout << e.what() << std::endl;
    }

    return 0;
}
Ejemplo n.º 2
0
GLuint ShaderProgram::loadShaderFromFile(const std::string &shaderFile, GLenum type) {
	//Open a file stream with the file name
	std::ifstream infile(shaderFile);

	if (infile.fail()) {
		std::cout << "Error opening shader file:" << shaderFile << std::endl;
	}

	//Create a string buffer and stream the file to it
	std::stringstream buffer;
	buffer << infile.rdbuf();

	// Load the shader from the contents of the file
	return loadShaderFromString(buffer.str(), type);
}