I was trying to texture a cube in PyOpenGL when I ran into an issue. PyOpenGL only supports 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES. I need at least version 1.40 because in 1.40
PyOpenGL only supports 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES [...]
No. PyOpenGL supports OpenGL ES versions from 1.0 to 3.1 and all desktop OpenGL version from 1.1 to 4.4 (See About PyOpenGL). You confused (desktop) OpenGL and OpneGL ES. Compare OpenGL specification - Khronos OpenGL registry and OpenGL ES Specification - Khronos OpenGL ES Registry.
In any case, the "supported" version only refers to OpenGL API. The OpenGL context version only depends on the graphics card. You can use any GLSL version which is supported by the current OpenGL context. PyOpenGL guarantees, that the OpenGL API is implemented up to version 4.4, but you can also use a higher version. It just means that OpenGL functions added later may be missing from the PyOpenGL API.
Log current version after creating the OpenGL window and making the context current:
print(glGetString(GL_VENDOR))
print(glGetString(GL_RENDERER))
print(glGetString(GL_VERSION))
print(glGetString(GL_SHADING_LANGUAGE_VERSION))
Vertex shader input Layout Qualifier are not supported in OpenGL Shading Language 1.30. You have to switch to OpenGL Shading Language 1.40:
#version 130
#version 140
Anyway you've mentioned that in your question - "I need at least version 1.40 because in 1.40 layout was introduced [...]"
The glsl sampler type has to match the texture target. The proper sampler type for (floating point) GL_TEXTURE_2D_ARRAY
is sampler2Darray
(See Sampler types):
uniform sampler2D texture;
uniform sampler2Darray texture;
For 2 dimensional array textures, 3 dimensional texture coordinates are required (See texture):
FragColor = texture(texture, TexCoord);
FragColor = texture(texture, vec3(TexCoord.st, index));
index
is the index of the addressed texture in the array. You can provide the index by a Uniform variable or even by a 3rd component in the texture coordinate attribute.