GLSL, interface block

Working with GLSL samples often gets tedious due to nasty version problems.

Some general debugging advice:

  • verify that you included the proper version tags in your shader source
  • verify that your OpenGL Driver actually supports that version by calling glGetString(GL_SHADING_LANGUAGE_VERSION)
  • create means of runtime shader-recompilation (e.g. by assigning that to a key event)
  • and FOREMOST: use glGetShaderInfoLog() and glGetProgramInfoLog()!

Create instance names for all interface blocks like:

FragData { /* ... */ } gs2fs; 

And then:

gs2fs.cameraCornerPos = vec4(vert[0].cameraSpherePos, 1.0);

The problem actually was with not using the latest driver.

I was running this on linux, and got the latest driver from Ubuntu's package manager: the Nvidia 310-experimental. But even though its experimental, it's rather old. With manually installing the 319 from nvidia's site the code worked fine without any change.

Moral of the story:

Always use the latest drivers.

Tags:

Opengl

Glsl