I am getting an odd behaviour using OpenGL on Windows 7.
The following pair of vertex/fragment shader is not supposed to link correctly (not matching in/out variables). Indeed, that is the case when I run this code on MacOS 10.9 . But for some reason, when running on windows 7, the linkage happens correctly (GL_TRUE is returned) the program info log is empty, but nothing is displayed on screen…
It is a CORE context, with debug message log enabled. Btw, I’ve also trying calling glValidateProgram and glGetProgramiv with GL_VALIDATE_STATUS, getting the same results (nothing)
VERTEX SHADER:
const char *vertex_shader_triangle_source = ""
"#version 330 core\n"
"\n"
"smooth out vec4 v_color;\n"
"uniform vec2 translate;\n"
"uniform int count;\n"
"void main(void) {\n"
"\n"
"const vec4 vertices[3] = vec4[3](\n"
" vec4(-0.1, -0.1, 0, 1), \n"
" vec4(0, 0.1, 0, 1), \n"
" vec4(0.1, -0.1, 0, 1));\n"
"\n"
"const vec4 colors[3] = vec4[3](\n"
" vec4(1.0, 0.0, 0.0, 1.0),\n"
" vec4(0.0, 1.0, 0.0, 1.0),\n"
" vec4(0.0, 0.0, 1.0, 1.0));\n"
"\n"
" gl_Position = vertices[(gl_VertexID+count)%3]+vec4(translate.x, translate.y, 0, 0);\n"
" v_color = colors[gl_VertexID];\n"
"\n"
"}\n";
FRAGMENT SHADER:
const char *frag_shader_triangle_source = ""
"#version 330 core\n"
"\n"
"smooth in vec4 in_color;\n"
"out vec4 color;\n"
"\n"
"void main(void) {\n"
" color = in_color;\n"
"// color = gl_FragCoord;\n"
"// color = vec4(1,1,1,1);\n"
"\n"
"}\n";
LINK PROGRAM:
GLuint new_program(GLuint vertex_shader, GLuint frag_shader) {
GLuint prog = glCreateProgram(); gl_errors();
glAttachShader(prog, vertex_shader); gl_errors();
glAttachShader(prog, frag_shader); gl_errors();
glLinkProgram(prog);
GLint prog_query;
glGetProgramiv(prog, GL_LINK_STATUS, &prog_query);
if (prog_query != GL_TRUE) {
_log_error("Error linking glProgram %d", prog);
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &prog_query);
assert(prog_query > 0 && "Wrong log size");
GLuint bufsize = (prog_query < 4096)?prog_query:4096;
char *link_log = (char *) calloc(bufsize, sizeof(char));
glGetProgramInfoLog(prog, bufsize, &prog_query, link_log);
_log_error("linker info log:\n%s", link_log);
return GL_FALSE;
}
gl_errors();
glUseProgram(prog); gl_errors();
return prog;
}