I'm trying to create a single compute a shader program computeProgram and attach two source codes on it. Here are my codes:
unsigned int computeProgram = glCreateProgram(); glAttachShader(computeProgram, MyFirstComputeShaderSourceCode); glAttachShader(computeProgram, MySecondComputeShaderSourceCode); glLinkProgram(computeProgram); glGetProgramiv(computeProgram, GL_LINK_STATUS, &success); if (!success) { glGetProgramInfoLog(computeProgram, 512, NULL, infoLog); std::cout << "ERROR::SHADER::COMPUTE_PROGRAM::LINKING_FAILED\n" << infoLog << std::endl; exit(1); } I get this type of linking error information:
ERROR::SHADER::COMPUTE_PROGRAM::LINKING_FAILED ERROR: Duplicate function definitions for "main"; prototype: "main()" found. I do have main functions in both shader source codes, and I understand why this is not gonna work cause there is only one main function expected in one program. But here comes my question: If I'm trying to link a vertex shader source and a fragment shader source to a single program, say, renderProgram, there are also two main functions, one in vertex shader, one in fragment shader. However, if I link these two, it somehow works fine.
Why is this difference happen? And if I want to use these two compute shaders, am I supposed to create two compute programs in order to avoid duplication of the main function?
Any help is appreciated!!