From X-Plane SDK
XPLM_API void XPLMGenerateTextureNumbers( int * outTextureIDs, int inCount);This routine generates unused texture numbers that a plug-in can use to safely bind textures. Use this routine instead of glGenTextures; glGenTextures will allocate texture numbers in ranges that X-Plane reserves for its own use but does not always use; for example, it might provide an ID within the range of textures reserved for terrain...loading a new .env file as the plane flies might then cause X-Plane to use this texture ID. X-Plane will then overwrite the plug-ins texture. This routine returns texture IDs that are out of X-Plane's usage range.