I have a small class that allows me to load shaders and use them in my program. I can compile the shaders, but when it is time to link them, they just don't want to do this. Using glGetProgramInfoLog, I got the following error log. I don’t understand why he is telling me that there is no program, since compilation works fine ...
Vertex info
-----------
(0) : error C3001: no program defined
Fragment info
-------------
(0) : error C3001: no program defined
The following is the GLSL code:
program_ = glCreateProgramObjectARB();
if (vertex_) {
glAttachObjectARB(program_, vertex_);
}
if (fragment_) {
glAttachObjectARB(program_, fragment_);
}
glLinkProgramARB(program_);
vertex_ and fragment_ are vertex and fragment shaders, and program_ is ProgramObjectARB.
I would like to know what necessary changes I need to make to complete this run.
Vertex shader:
varying vec4 OCPosition; // surface positon in world coordinates
varying vec4 ECposition; // surface position in eye coordinates
varying vec4 ECballCenter; // ball center in eye coordinates
uniform vec4 BallCenter; // ball center in modelling coordinates
void main()
{
OCPosition = gl_Vertex;
ECposition = gl_ModelViewMatrix * OCPosition;
ECballCenter = gl_ModelViewMatrix * BallCenter;
gl_Position = gl_ProjectionMatrix * ECposition;
}
Fragment Shader:
varying vec4 OCPosition;
varying vec4 ECposition;
varying vec4 ECballCenter;
uniform vec4 LightDir;
uniform vec4 HVector;
uniform vec4 SpecularColor;
uniform vec4 BaseColor, StripeColor;
uniform float StripeWidth;
uniform float FWidth;
void main()
{
vec3 normal;
vec4 p;
vec4 surfColor;
float intensity;
vec4 distance;
float inorout;
p.xyz = normalize(OCPosition.xyz);
p.w = 1.0;
distance.y = StripeWidth - abs(p.z);
distance.xy = smoothstep(-FWidth, FWidth, distance.xy);
surfColor = mix(BaseColor, StripeColor, distance.y);
normal = normalize(ECposition.xyz - ECballCenter.xyz);
intensity = 0.2;
intensity += 0.8 * clamp(dot(LightDir.xyz, normal), 0.0, 1.0);
surfColor *= intensity;
intensity = clamp(dot(HVector.xyz, normal), 0.0, 1.0);
intensity = pow(intensity, SpecularColor.a);
surfColor += SpecularColor * intensity;
gl_FragColor = surfColor;
}
-
, , , . , . , :
char *textFileRead(char *fn) {
FILE *fp;
char *content = NULL;
int count=0;
if (fn != NULL) {
fp = fopen(fn,"rt");
if (fp != NULL) {
fseek(fp, 0, SEEK_END);
count = ftell(fp);
rewind(fp);
if (count > 0) {
content = (char *)malloc(sizeof(char) * (count+1));
count = fread(content,sizeof(char),count,fp);
content[count] = '\0';
}
fclose(fp);
}
}
return content;
}