#include #include #include #include #include #include #include unsigned int loadShader(std::string path) { std::ifstream file(path); if (file.is_open()) { std::string line; std::string code = ""; while (std::getline(file, line)) { code += line + "\n"; } file.close(); unsigned int shader = glCreateShader(GL_FRAGMENT_SHADER); const char* code_cstr = code.c_str(); glShaderSource(shader, 1, &code_cstr, NULL); glCompileShader(shader); int success; char infoLog[512]; glGetShaderiv(shader, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(shader, 512, NULL, infoLog); std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl; } return shader; } else { std::cout << "ERROR::SHADER::VERTEX::FILE_NOT_SUCCESFULLY_READ" << std::endl; return 0; } }