i'm trying to read vertex and fragment shader from files that look like this
#version 330 core
in vec3 ourColor;
out vec4 color;
void main()
{
color = vec4(ourColor, 1.0f);
}
but when i'm compiling shader i get the error like 'bad syntax'.
code that read shader code from file
const GLchar* readFromFile(const GLchar* pathToFile)
{
std::string content;
std::ifstream fileStream(pathToFile, std::ios::in);
if(!fileStream.is_open()) {
std::cerr << "Could not read file " << pathToFile << ". File does not exist." << std::endl;
return "";
}
std::string line = "";
while(!fileStream.eof()) {
std::getline(fileStream, line);
content.append(line + "\n");
}
fileStream.close();
std::cout << "'" << content << "'" << std::endl;
return content.c_str();
}