You can update uniforms between drawing calls so that they are used.
Having looked at the inserted code and, as indicated in the comments, lines 167..169 should work randomly for small texIds, but you really have to change
glUniform1i(textureUnif, model.texId)
glActiveTexture(GL_TEXTURE0+model.texId)
glBindTexture(GL_TEXTURE_2D, model.texId)
to
glUniform1i(textureUnif, 0)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, model.texId)
, , , GL_TEXTURE0, glBindTexture() . , id .
, OpenGL, . ? .
, - OpenGL , , , .