Problems with textures

Hi there,

Im having some problems with creating textures.
Im trying to load the textures with this procedure

void  setTextureToObject(char* textureFilename, int obj)
  Mesh::Texture texture; 
  // this one works fine
  Mesh::loadTexture(textureFilename, texture);
  // glGenTextures returns the same IDs on different calls
  glGenTextures(1, &(Objects[obj].gTextureAccessor));
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  glBindTexture(GL_TEXTURE_2D, Objects[obj].gTextureAccessor);
  gluBuild2DMipmaps(GL_TEXTURE_2D, 3, texture.width, texture.height, GL_RGB, GL_UNSIGNED_BYTE, texture.pTextureData);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texture.width, texture.height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture.pTextureData);

(Objects is a Vector of a struct with the object data; Mesh::texture is a struct to hold the temporary texture on loading)

the funny thing is I call this procedure twice in my initialization and it works just fine there, but as soon as Im in the main loop glGenTextures start setting gTextureAccessor to 1 again.
I tried replacing this line with a global counter but although the texture-ids are correct now its not working.

Sometimes this results in the correct texture, sometimes the objects have no texture and sometimes they disapear completely

Has the structure stored within the Objects vector a destructor that destroys the texture? When new elements are added to stl vector, the entire content is sometimes copied to new memory which will cause call of destructor on objects in the old memory.

Thanks for the hint but unfortunately the structure has no destructor and there is (until now) no line of code that says “glDeleteTextures”

ohh I think I just found the problem: forgot to initialize gTextureAccessor … stupid
thanks agian