programObject = glCreateProgramObjectARB();
// Create the fragment program
fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
glShaderSourceARB(fragmentShader,1,&fragment_source,NULL);
glCompileShaderARB(fragmentShader);
glGetObjectParameterivARB(programObject,GL_OBJECT_COMPILE_STATUS_ARB,&CompileSuccess);
if (!CompileSuccess){
fprintf(stderr, "Compilation error
");
exit(1);
}
glAttachObjectARB(programObject,fragmentShader);
// Link the shader into a complete GLSL program.
glLinkProgramARB(programObject);
glGetObjectParameterivARB(programObject,GL_OBJECT_LINK_STATUS_ARB,&LinkSuccess);
if (!LinkSuccess){
fprintf(stderr, "Filter shader could not be linked
");
exit(1);
}
Well. When I run my program, I receive the message “Filter shader could not be linked”. How to check what is the error over there?
programObject = glCreateProgramObjectARB();
// Create the fragment program
fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
glShaderSourceARB(fragmentShader,1,&fragment_source,NULL);
glCompileShaderARB(fragmentShader);
glGetObjectParameterivARB(programObject,GL_OBJECT_COMPILE_STATUS_ARB,&CompileSuccess);
if (!CompileSuccess){
fprintf(stderr, "Compilation error
");
exit(1);
}
glAttachObjectARB(programObject,fragmentShader);
// Link the shader into a complete GLSL program.
glLinkProgramARB(programObject);
glGetObjectParameterivARB(programObject,GL_OBJECT_LINK_STATUS_ARB,&LinkSuccess);
int b,length;
char log[length];
glGetShaderInfoLog(fragmentShader,200,&length,log);
printf("Log file: ");
if(length>1)
printf("%s
",log);
if (!LinkSuccess){
fprintf(stderr, "Filter shader could not be linked
");
exit(1);
}
Well. I am not sure that the method i use that function correct or not. It returns me segmentation fault once I call the glGetShaderInfoLog() function.
I don’t see how that compiles. Even under C99 rules, where stack arrays can be “dynamic,” that might compile, but it certainly won’t execute. ‘length’ needs to have a value before you try to use it to size an array. Or, more likely, you intend the ‘log’ array to have 200 elements.
In general, you should call glGetShader with GL_INFO_LOG_LENGTH to get the size of the infolog. Then create a buffer to store the log and call glGetShaderInfoLog.
Also, you might want to reconsider mixing the ARB_shader_objects functions and objects with the core GL object functionality. That is, if you’re using glCreateShaderARB, then every function you use that object with needs to have an ARB suffix. It’s all or nothing; either you’re using ARB_shader_objects (for some reason), or you’re using the core GL version. Don’t mix them. Especially since ARB_shader_objects returns an opaque handle, rather than a 32-bit integer.
That’s not a string; that is an array (of length 1) of strings. That has the type “const char **”. If that works at all, it’s only because you got lucky.
Are you new to C/C++? If so, you may want to get some more programming experience before you start trying to deal with graphics work.