Open X-Ryl669 opened 7 years ago
To bind a location to a sampler, the OpenGL specification expects a signed integer (or a 64-bit unsigned integer for bindless textures).
Using globjects, uniforms can be added to a program by calling templates member functions. (e.g., program->addUniform<int>("mySampler", 0);
I use the explicit template parameter type to bypass any template parameter deduction that may lead to wrong/unexpected types.
This may help in your case.
More generally, we could introduce a user-defined type (e.g., a struct or enum) that encapsulates sampler locations and provide member function overrides on Uniform
that calls the integer variant internally.
Currently getting a high severity error reported while setting a uniform value for a sampler, I found this documentation on Khronos website:
I'm getting this message from NVidia's driver:
while calling this code:
The call stack is:
For this location, I suspect that setting the texture's sampler index (used 0) is being recorded as
Uniform<unsigned int>
and callsglProgramUniform1ui
while the standard clearly say we should callglProgramUniform1i
(see first note on this issue).This is a hard problem to solve, since globject deducts the type of the uniform from its type, so the deduction of
Uniform<unsigned int>
is correct when passed0
. I don't know how to solve it logically. I can force the type to int and it'll work, but I guess that force all client code to write a specific case when setting sampler types. I wonder if a specificProgram::setSamplerUniform
would not be more explicit ?In that case, the code for such method would be straightforward:
What do you think ?