0

Anyone knows how to loop different image from xml I parse (I used libxml2) then load it > using SOIL for OpenGL in c++? here's my code:

LoadImage *img[0];
File getFile;
int a;
string imge;
vector<char*> image3;
void getImageNode(File getFile){
    vector<Image> image = getFile.getChildrenImage();
    a = image.size();
    Image image2;
    while(image.size()){
        image2 = image.front();
        imge = image2.getthumb();
        char *fileImage = &imge[0];
        image3.push_back(fileImage);  
        image.erase(image.begin());
    }
}
int main(int argc,char **argv){
    GetRootNode getrootNode;
    string xmlFile = "educationalVideo.xml";
    Parser xmlObj(xmlFile);
    getFile = xmlObj.getNode();  
    getImageNode(getFile);
    for(int i=0; i<=a; i++){
        while(image3.size()){
            char *fileImage2 = image3.front();
            img[i]=new LoadImage(fileImage2); //getting last image 
            image3.erase(image3.begin());
        }
    }
    return 0;
}
joi
  • 307
  • 1
  • 2
  • 11
  • You already know how to feed a filename to SOIL to get an OpenGL texture. What you need is instructions on how to parse XML to get the filenames you want to pass to SOIL. And that has everything to do with XML parsing and nothing to do with SOIL or OpenGL. So what is your XML format and what are your XML parsing tools? And what code do you already have to read these XML files? – Nicol Bolas Oct 28 '11 at 09:47
  • Im done parsing the image. I get all the images I need. I'm using libxml2 for my xml. I save in a vector all the image. then I loop it and pass to SOIl. The output is always the last image. – joi Oct 28 '11 at 09:53
  • What does `LoadImage`'s constructor look like? Also, `img` is an array of _zero_ elements; I'm not even sure that compiles, but even if it does, it's not going to be particularly useful. You cannot store something in a zero-length array. Also, that's not LibXML2 code; LibXML2 is a C-library. You've got some library between LibXML2 and your code. What is it? – Nicol Bolas Oct 28 '11 at 10:38

1 Answers1

0

How about this?

GLuint tex_2d_1 = SOIL_load_OGL_texture
(
    "img1.png",
    SOIL_LOAD_AUTO,
    SOIL_CREATE_NEW_ID,
    SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
);

GLuint tex_2d_2 = SOIL_load_OGL_texture
(
    "img2.png",
    SOIL_LOAD_AUTO,
    SOIL_CREATE_NEW_ID,
    SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
);
Constantinius
  • 34,183
  • 8
  • 77
  • 85
  • it works if I set multiple GLuint. What I need is > from xml image I need to loop it and load it using SOIL – joi Oct 28 '11 at 09:05
  • If that is your question, you should ask it. Please update your question and also what XML library you are using. – Constantinius Oct 28 '11 at 09:27