I assumeUPDATE I no longer get the above error originates in one of the following functionsafter fixing a mistake. I now get a complain after glCompileShader():
"Error: 0:3 'location' : syntax error parse error"
So I imagine it has to do with my shader files (will add them below). The shader files are taken from a tutorial, so I assumed they would work.
Shader files:
Vertex shader:
#version 330 layout (location = 0) in vec3 Position; void main() { gl_Position = vec4(0.5*Position.x, 0.5*Position.y, Position.z, 1.0); }
Fragment shader:
#version 330 out vec4 FragColor; void main() { FragColor = vec4(1.0, 0.0, 0.0, 1.0); }
static void AddShader(GLuint ShaderProgram, GLenum ShaderType, std::string filePath){ //create shader object GLuint ShaderObj = glCreateShader(ShaderType); //error if no shader if (ShaderObj === 0){ fprintf(stderr, "Error creating shader type %d\n", ShaderType); exit(0); } //"specify source code" //readShaderFile returns the shader file as a string std::string shaderFile = readShaderFile(filePath); const char* shaderFilePointer = shaderFile.c_str(); GLint ShaderFileLength[1]; ShaderFileLength[0] = strlen(shaderFilePointer); glShaderSource(ShaderObj, 1, &shaderFilePointer, ShaderFileLength); //compile the shader glCompileShader(ShaderObj); //check if compile successful GLint success; glGetShaderiv(ShaderObj, GL_COMPILE_STATUS, &success); if (!success){ GLchar InfoLog[1024]; glGetShaderInfoLog(ShaderObj, sizeof(InfoLog), NULL, InfoLog); fprintf(stderr, "Error compiling shader type %d: '%s'\n", ShaderType, InfoLog); exit(1); } glAttachShader(ShaderProgram, ShaderObj); }