this is my fragment shader from shader/frag.glsl
#version 330 core
out vec4 aColor;
void main(){
aColor = vec4(1.0, 0.0, 0.0, 1.0);
}
there are no errors in program compiling but on running the “app.exe” i am getting this error
ERROR::SHADER::COMPILATION_FAILED
ERROR: 0:1: ‘’ : illegal character (0x1)
ERROR: 0:1: ‘’ : illegal non-ASCII character (0xb6)
ERROR: 0:1: ‘’ : illegal non-ASCII character (0xc4)
ERROR: 0:1: ‘’ : illegal character (0x2)
WARNING: 0:1: ‘’ : #version directive missing
ERROR: 0:1: ‘PZ’ : syntax error syntax error
This is my loadShader program:
std::string loadShader(const std::string& path){
std::string result;
std::string line;
std::ifstream myFile(path.c_str());
if (myFile.is_open()) {
while (std::getline(myFile, line)) {
result += line + "\\n";
}
myFile.close();
} else {
std::cerr << "Could not read file " << path << ". File does not exist.\\n";
}
return result;
};
this is working fine for vert.glsl .
i also tried to load vert.glsl from file and fragemt shader using
“#version 330 core\n”
"out vec4 aColor;\\n"
"void main()\\n"
"{\\n"
" aColor = vec4(1.0f, 0.0, 0.0, 1.0);\\n"
"}\\0";
this combo is working file .
help me where i am wrong in loading fragment shader from frag.glsl .