libgdxshaderspritebatch

Does a Spritebatch need to be flushed every time a uniform is set on the shader?


If uniforms are set on a shader used by a spritebatch does the spritebatch need to be flushed before resetting the uniform for the next draw call?

Eg. Is this correct?

batch begin

set uniform for texture one
draw texture 1
set uniform for texture two
draw texture 2
...
set uniform for texture N
draw texture N

batch end

or does the batch need to be flush after each draw call?


Solution

  • Since the shader needs a source, you have to flush it. Only when flushing the batch, the texture gets drawn and the shader is applied.