本文共 1245 字,大约阅读时间需要 4 分钟。
void readCubeMapToHost_forTest(unsigned int cubeMapTexture, int width, int height, GLubyte *dataMap){ GLuint CarrierFBo; glGenFramebuffers(1, &CarrierFBo); glBindFramebuffer(GL_FRAMEBUFFER, CarrierFBo); //cout << "here 1" << endl; glBindTexture(GL_TEXTURE_CUBE_MAP, cubeMapTexture); for (int i = 0; i < 6; i++) { //cout << "here 2" << endl; //貌似是必须的,不然只能读取POSITIVE_X glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, cubeMapTexture, 0); //cout << "here 3" << endl; glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, &dataMap[i*width*height]); } //cout << "here 4" << endl; glBindTexture(GL_TEXTURE_2D, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);}int bmp_write_forTest(unsigned char *image, int xsize, int ysize, char *filename){#define BMP_Header_Length 54 FILE* pDummyFile; FILE* pWritingFile; GLubyte* pPixelData; GLubyte BMP_Header[BMP_Header_Length]; GLint i, j; GLint PixelDataLength; i = xsize * 3; while (i % 4 != 0) ++i; PixelDataLength = i * ysize; unsigned char * grayimage = (unsigned char *)malloc(sizeof(unsigned char)*xsize*ysize * 3); /*unsigned char f2c = (unsigned char)0.5f;*/ for (int i = 0; icubeMapTexture);}
转载地址:http://hjopi.baihongyu.com/