Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void load3DTexFromPVM(const char* fileName,
- int xSize=64,
- int ySize=64,
- int zSize=64) {
- const int size = xSize*ySize*zSize;
- FILE *pFile = fopen(fileName,"rb");
- if(NULL == pFile) {
- cerr << "Fail to open texture file" << endl;
- exit(EXIT_FAILURE);
- }
- GLubyte* texels=new GLubyte[size];
- fread(texels,sizeof(GLubyte),size,pFile);
- fclose(pFile);
- //load data into a 3D texture
- glGenTextures(1, &texname);
- glBindTexture(GL_TEXTURE_3D, texname);
- // set the texture parameters
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexImage3D(GL_TEXTURE_3D,0,GL_INTENSITY,xSize,ySize,zSize,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,texels);
- //glTexImage3D(GL_TEXTURE_3D,0,GL_RGB8,xSize,ySize,zSize,0,GL_RGB,GL_UNSIGNED_BYTE,texels);
- delete[] texels;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement