IplImage* imgBGR = cvLoadImage(szPathName);
IplImage* imgRGB = cvCreateImage(cvGetSize(imgBGR), 8, 3);
cvCvtColor(imgBGR,imgRGB,CV_BGR2RGB); //Opencv默认是BGR
int width = imgRGB->width;
int height = imgRGB->height;
glGenTextures(1, &texid);
glBindTexture(GL_TEXTURE_2D, texid);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE,imgRGB->imageData); //数据保存在显存中
cvReleaseImage(&imgBGR);
cvReleaseImage(&imgRGB);
IplImage* imgRGB = cvCreateImage(cvGetSize(imgBGR), 8, 3);
cvCvtColor(imgBGR,imgRGB,CV_BGR2RGB); //Opencv默认是BGR
int width = imgRGB->width;
int height = imgRGB->height;
glGenTextures(1, &texid);
glBindTexture(GL_TEXTURE_2D, texid);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE,imgRGB->imageData); //数据保存在显存中
cvReleaseImage(&imgBGR);
cvReleaseImage(&imgRGB);