Better handling for glGenerateMipmap