任何人都知道如何从我解析的xml循环不同的图像(我使用libxml2)然后加载它>在c ++中使用SOIL进行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;
}
答案 0 :(得分: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
);