Replace NextTexAvail with glGenTextures
Binding texture names not generated by glGenTextures
is nonstandard.
glGenTextures returns
n
texture names intextures
. There is no guarantee that the names form a contiguous set of integers; however, it is guaranteed that none of the returned names was in use immediately before the call to glGenTextures.