Adapted code after recent texture target changes.