I have been running into an error while trying to create and link a GLSL program. Whenever I try to link the program, I encounter an error.
Output:
ERROR: definition for "void main()" not found
Vertex shader:
#version 330 core
layout(location = 0) in vec3 vertex_modelspace;
void main()
{
gl_Position.xyz = vertex_modelspace;
gl_Position.w = 1.0;
}
Fragment shader:
#version 330 core
out vec3 color;
void main()
{
color = vec3(1, 0, 0);
}
Shader program creation code:
ifstream vertStream(vertPath);
ifstream fragStream(fragPath);
string line;
while (!getline(vertStream, line))
{
vertexShaderSource.append(line).append("\n");
}
vertStream.close();
while (!getline(fragStream, line))
{
fragmentShaderSource.append(line).append("\n");
}
fragStream.close();
vertexShaderSourcePointer = vertexShaderSource.c_str();
fragmentShaderSourcePointer = fragmentShaderSource.c_str();
vertexShaderLength = vertexShaderSource.length();
fragmentShaderLength = fragmentShaderSource.length();
vertexShaderID = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShaderID, 1, &vertexShaderSourcePointer, &vertexShaderLength);
glCompileShader(vertexShaderID);
checkShader(vertexShaderID);
fragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShaderID, 1, &fragmentShaderSourcePointer, &fragmentShaderLength);
glCompileShader(fragmentShaderID);
checkShader(fragmentShaderID);
programID = glCreateProgram();
glAttachShader(programID, vertexShaderID);
glAttachShader(programID, fragmentShaderID);
glLinkProgram(programID);
checkProgram(programID);
The checkShader and checkProgram functions are simple error checks using glGetShaderiv and glGetProgramiv and printing the error log into stderr. I've checked whether the shader and program names are valid, and they are. I have also checked the compilation status of both shaders, and they compiled without a problem. This code has worked for me before (Using different bindings), and I have no clue why it isn't working.
By my understanding, this error message is meant to be shown when a shader doesn't have a main() function, but mine do. I'm pretty sure it's something stupid, but I've been staring at this all day to no avail. Help?
main()function. - Reto Koradiwis 1.0 in this case. There is a reason the output ofgl_Positionis called clip-space ;) - Andon M. Coleman