The argument val in
setTexUniform(String name, int val) stands for the texture unit (0, 1, 2,...), which is different from the opengl ID of the texture object bound to the texture unit. However, the opengl ID might take the values 1, 2, 3, etc (but not zero) so this might lead to confusion.
You first set the uniform to the appropriate texture unit to sample from, and then you bind a texture object to the texture unit by using
glBindTexture(). Something like this:
- GLGraphics renderer = (GLGraphics) g;
- GL gl = renderer.gl;
- renderer.beginGL();
- shader.start();
- shader.setFloatUniform("BaseRadius", 10);
- shader.setTexUniform("permTexture", 0);
- gl.glActiveTexture(GL.GL_TEXTURE0);
- gl.glBindTexture(tex.getTextureTarget(),
tex.getTextureID());
- renderer.model(model);
- shader.stop();
- renderer.endGL();