GLSL and framerate

Dear forum,

I have a question which I hope you can answer. I have a scene which draws elements with 60 frame per second by using the function: glutTimerFunc(100.0 / 6.0, idle, 0), in which idle does the following:

void idle(int value) {
  /* Calculate the time between frames */
  new_time = glutGet(GLUT_ELAPSED_TIME);
  double difference = (new_time - old_time) / 1000.0;
  old_time = new_time;
  
  /* Generate new positions for the objects */
  scene.handle_collisions();
  scene.update_positions(difference);
  
  glutTimerFunc(100.0 / 6.0, idle, 0);
  glutPostRedisplay();
}

In the main function I bind the created shader, draw the objects and unbind the shader. The problem is that when I do not use the shader, the idle function does get called every 0.016 seconds (60 FPS), but when I’m using GLSL, the idle function is called every 0.232 seconds, which is like 4 FPS.

This is my vertex and fragment shader:

varying vec3 normal;
varying vec3 light_pos;

/* This is the main-function of the fragment shader */
void main() {
  vec3 norm_light = normalize(light_pos);

  float diffuse_value = max(dot(normal, norm_light), 0.0);
  gl_FragColor = gl_Color * diffuse_value;
}
varying vec3 normal;
varying vec3 light_pos;

/* This is the main-function of the vertex shader */
void main() {
  normal = normalize(gl_NormalMatrix * gl_Normal);
  
  light_pos = (gl_LightSource[0].position - gl_ModelViewMatrix * gl_Vertex).xyz;

  gl_FrontColor = gl_Color;
  
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

MY question is, does anybody know why the framerate drops when using GLSL?

Regards,
PascalM123

What is your video card, driver version, OS version ?

I’ve found out the problem. The recommended drivers for my videocard have never been installed, so no wonder why it didn’t work.

Thanks for your help!

Regards,
PascalM123

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.