Hi there I am a beginner to OpenGL and had been trying to write a program that displays a few basic shapes on the screen but somehow only a window without the expected shapes showed up. After tracing it I realised the vertex shader and fragment shader failed to compile. Any help? much appreciated!
Thanks for the reply, I had altered my code to reading in the shaders glsl file instead, and checked using the compile log, it gives the error message:
ERROR: 0:2: ‘’ : syntax error #version
I had done a lot of searches online and many had said that this problem is caused by the shader source having no null-terminator in the end. so I had tried to add a null terminator like this
std::string VertexShaderCode;
std::ifstream VertexShaderStream(vertex_file_path, std::ios::in);
if(VertexShaderStream.is_open())
{
std::string Line = "";
while(getline(VertexShaderStream, Line))
VertexShaderCode += "
" + Line;
VertexShaderCode += "\0"; //<-- (THE ADDED LINE FOR NULL TERMINATOR)
VertexShaderStream.close();
}