8
votes

I tried to run a simple OpenGL 3 app with the following vertex shader program:-

in vec4 vPosition;
out vec2 otexcoord;

uniform mat4 modelview;
uniform mat4 projection;

void main()
{
    gl_Position = projection * modelview * vPosition;
    otexcoord.s = vPosition.x;
    otexcoord.t = vPosition.y * -1.0;
};

I've run this code on 3 GPUs, from different company, and the results are different.

  • With Intel's driver, there's no error and it runs perfectly.
  • With Nvidia's driver, the error is 'out can't be used with non-varying otexcoord'.
  • With AMD's driver, the error is 'Implicit version number 110 not supported by GL3 forward compatible context'

The AMD's one seems to be the least obvious. In fact I don't have any idea about it.

Below is some query string

  • Intel: OpenGL 3.2.0 - Build 9.17.10.2932 GLSL 1.50 - Build 9.17.10.2932
  • Nvidia: OpenGL 3.2.0 GLSL 1.50 NVIDIA via Cg compiler
  • AMD: OpenGL 3.2.12002 Core Profile Context 9.12.0.0 GLSL 4.20

Intel's and Nvidia's are similar, it's a GLSL 1.50 compiler. The AMD's is GLSL 4.20

Below is the question:-

  1. Between Intel's and Nvidia's compilers, which one is working correctly in this case?
  2. What does the error message from AMD's compiler really mean ? And what do I need to correct the error.
1
Where's your #version directive?genpfault
There were none. I've just put it just as the suggestion below, and it works great now. Thank you.Wutipong Wongsakuldej

1 Answers

16
votes

You must always use a #version directive. If you do not, then the compiler will assume you mean GLSL version 1.10. Which means that out is not a valid keyword.