[solved]Problem loading textures

I load two textures using this code:

  
      
flare.loadImage("flare.png");  
flareText.allocate(512,512,GL_RGBA);  
flareText.loadData(flare.getPixels(),512,512,GL_RGBA);  
cloud.loadImage("cloud.png");  
cloudText.allocate(512,512,GL_RGBA);  
cloudText.loadData(cloud.getPixels(),512,512,GL_RGBA);  

I then wanted to put the flare texture on a quad like this:

  
  
glEnable(flareText.getTextureData().textureTarget);  
   glBegin(GL_QUADS);  
       .... //vertices  
   glEnd();  

However it turned out the program had actually used the cloud texture. Appareantly the last loaded texture was used… Ofcourse, that’s not what I wanted.

Anybody have any ideas what I could be doing wrong?

After several days of trying I figured it out:

  
  
//Load the image and create a texture  
flare.loadImage("flare.png");  
flareText.allocate(512,512,GL_RGBA);  
flareText.loadData(flare.getPixels(),512,512,GL_RGBA);  
  
//Load the second image and create a texture  
cloud.loadImage("cloud.png");  
cloudText.allocate(512,512,GL_RGBA);  
cloudText.loadData(cloud.getPixels(),512,512,GL_RGBA);  
  
//Then bind and unbind the textures as needed  
flareText.bind();  
glBegin(GL_QUADS);  
   ...//Texture coordinates and vertices  
glEnd();  
flareText.unbind();  
  
cloudText.bind();  
glBegin(GL_QUADS);  
   ...//Texture coordinates and vertices  
glEnd();  
cloudText.unbind();