LWJGL Forum

Programming => OpenGL => Topic started by: Danjb on September 14, 2018, 16:20:13

Title: Element exceeds maximum supported number of combined texture image units
Post by: Danjb on September 14, 2018, 16:20:13
Hello,

I have just set up a debug message callback, and I'm seeing lots of these errors:

[LWJGL] OpenGL debug message
ID: 0x501
Source: API
Type: ERROR
Severity: HIGH
Message: GL_INVALID_VALUE error generated. Element exceeds maximum supported number of combined texture image units.


I have only created 6 textures, and I am only binding 1 at a time. When I print the value of glGetInteger(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS) I get 192, so I don't understand what limit I am hitting here.

Can anyone please offer some insight?

Thanks,
Dan

Title: Re: Element exceeds maximum supported number of combined texture image units
Post by: KaiHH on September 14, 2018, 17:54:02
The first step is to identify, which GL call caused this error. If you are using LWJGL 3, then the easiest way is to start your JVM with the LWJGLX/debug agent: https://github.com/LWJGLX/debug
You can download it directly from here: https://build.lwjgl.org/addons/lwjglx-debug/lwjglx-debug-1.0.0.jar
Then start the JVM with the JVM argument -javaagent:/path/to/lwjglx-debug-1.0.0.jar and you should see a stack trace when you hit the error.
Title: Re: Element exceeds maximum supported number of combined texture image units
Post by: Danjb on September 14, 2018, 19:38:27
Thank you so much, that was really helpful.

The problem was that I was doing this:

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureId);
glUniform1i(uniformLoc, GL_TEXTURE0);


Instead of this:

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureId);
glUniform1i(uniformLoc, 0);


GL_TEXTURE0 has the value 33984, whereas samplers have to have a value in the value [0, GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS).
(Source: https://www.khronos.org/opengl/wiki/Texture#Samplers)

Thanks again.
Dan