如何在OpenGL c++中使用SOIL加载不同的图像(循环)

How to load different images (loop) using SOIL for OpenGL c++?

本文关键字:图像 循环 加载 SOIL OpenGL c++      更新时间:2023-10-16

有人知道如何从我解析的xml中循环不同的图像(我使用了libxml2(,然后在c++中使用SOIL for OpenGL加载它>吗?这是我的代码:

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;
}

这个怎么样?

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
);