Jonathan.
Jonathan.

Reputation: 55604

OpenGL shader built in variables replacement

I have an old vertex shader that used the 150 compatibility GLSL version:

#version 150 compatibility

out vertexData
{
    vec3 v;
    vec3 n;
} vertex;

void main()
{
    vertex.v = gl_Vertex.xyz;
    vertex.n = normalize(gl_NormalMatrix * gl_Normal);
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

However I want to use this on OSX. How can I have access to both the built in variables like gl_ModelViewProjectionMatrix as well as syntax like out uniforms?

If I don't use glutInitDisplayMode(GLUT_3_2_CORE_PROFILE) then I get an old version of OpenGL that uses GLSL version 120 which uses all the old varying syntax, and can't support Geometry shaders apparently, if I do use the 3.2 core profile, then I have to manage all the matrices all myself and frankly I can't be bothered to do a bunch of boilerplate code that didn't need to be done previously.

Upvotes: 1

Views: 762

Answers (1)

derhass
derhass

Reputation: 45362

However I want to use this on OSX. How can I have access to both the built in variables like gl_ModelViewProjectionMatrix as well as syntax like out uniforms?

You simply can't. Either you use legacy GL, which will limit you to GL2.1 / GLSL 1.20 on that platform, or you use a core profile, where none of those builtins are present.

if I do use the 3.2 core profile, then I have to manage all the matrices all myself and frankly I can't be bothered to do a bunch of boilerplate code that didn't need to be done previously.

You might not like it, but that is just what you have to do. The only profile required to be implemented according to the spec is core profile, so one can't rely on finding an implementation where old legacy GL and modern features like the geomerty shader might be mixed.

Upvotes: 3

Related Questions