I have this bit of OpenGL/Python code:
import sys
from OpenGL.GL import *
from OpenGL.GL import shaders
from OpenGL.GLU import *
from OpenGL.GLUT import *
glutInit(sys.argv)
glutInitDisplayMode(GLUT_RGBA)
glutInitWindowSize(640, 480)
window = glutCreateWindow("Test")
print glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS)
print glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS)
print glGetIntegerv(0x8872)
print glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS)
fs = (
"""
#version 130
uniform sampler2D foo;
uniform samplerCube bar;
void main()
{
vec4 c1 = texture2D(foo, vec2(0, 0));
vec4 c2 = textureCube(bar, vec3(0, 0, 0));
gl_FragColor = c1 + c2;
}
"""
)
shader = shaders.compileShader(fs, GL_FRAGMENT_SHADER)
program = shaders.compileProgram(shader)
print program
When I run it, the fragment shader fails to compile:
$ python tex.py
16
16
16
48
Traceback (most recent call last):
File "tex.py", line 35, in <module>
program = shaders.compileProgram(shader)
File "/usr/local/lib/python2.7/dist-packages/OpenGL/GL/shaders.py", line 196, in compileProgram
program.check_validate()
File "/usr/local/lib/python2.7/dist-packages/OpenGL/GL/shaders.py", line 108, in check_validate
glGetProgramInfoLog( self ),
RuntimeError: Validation failure (0): Texture unit 0 is accessed both as sampler2D and samplerCube
I don't see why the two sampler objects would bind to the same texture units? Using GLSL 1.30, I don't even see how I can specify texture units before compiling the program. And it should be possible to use multiple samplers and texture units.
What am I doing wrong?