I'm not exactly experienced with OpenGL but from what I have seen in BlitzMax so far, if you are going to mess with glBindtexture GL_TEXTURE_2D then you need to save and restore the current state like this:
and to save and restore the matrix transformation I beleive you need to use the glPushMatrix and glPopMatrix commands.
glGetIntegerv GL_TEXTURE_BINDING_2D,VarPtr old_name .. your code here glBindTexture GL_TEXTURE_2D,old_name
and to save and restore the matrix transformation I beleive you need to use the glPushMatrix and glPopMatrix commands.