Lnux环境下,用opencv加载纹理贴图

void makeTexImageCV(string imageName,GLuint &texName)
{
// printf("%s\n",imageName.c_str());
//creating a texture image by OpenCV functions
string temp="/home/sunbaigui/文档/MyTraining/OBJ_Loader_Candle/build/bin/";
temp=temp+imageName;
temp.erase(temp.end()-1);
IplImage* imgGrey = cvLoadImage(temp.c_str(),1);
if (imgGrey==NULL){
printf("imageName=%s\n",imageName.c_str());
exit(0);
}
//printf("cv yes\n");
glGenTextures(1, &texName);
glBindTexture(GL_TEXTURE_2D, texName);
//设置纹理参数
texImage = (unsigned char *)malloc(sizeof(unsigned char)*imgGrey->imageSize);
memcpy(texImage,imgGrey->imageData,sizeof(unsigned char)*imgGrey->imageSize);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8,imgGrey->width ,imgGrey->height , 0,
GL_BGR_EXT, GL_UNSIGNED_BYTE,texImage );


}
至于怎么在Linux下使用OpenCV,这个大家可以自己到网上搜搜

你可能感兴趣的:(linux,image,String,filter,文档,byte)