Original Post
Hi! I have two questions... I'm having a problem with using 3d textures and multitexturing. I have a 3d texture and I am unable to rasterize it on the polygon using glMultiTexCoord3f(...); there's nothing where the texture should be It seems only to work with glTexCoord3d(...); Is there another way to combine these two techinques? The second thing is that I want to create a 3d texture form a series of .tga files. And it seems I'm not doing it right either. And I can't find anything useful on this subject on the web... The code is: (based on NeHe .tga loading tutorial) Can anybody see the flaw?
GLubyte TGAheader[12] = {0,0,2,0,0,0,0,0,0,0,0,0};
GLubyte TGAcompare[12];
GLubyte header[6];
GLuint bytesPerPixel;
GLuint imageSize;
GLuint temp;
GLuint type = GL_RGBA;
TextureImage texture;
int HEIGHT;
int WIDTH;
int BPP;
FILE *file1 = fopen(filename1, "rb");
fread(TGAcompare,1,sizeof(TGAcompare),file1);
fread(header,1,sizeof(header),file1);
texture.width = header[1] * 256 + header[0];
texture.height = header[3] * 256 + header[2];
texture.bpp = header[4];
bytesPerPixel = texture.bpp/8;
imageSize = texture.width*texture.height*bytesPerPixel;
texture.imageData=(GLubyte *)malloc(imageSize);
fread(texture.imageData, 1, imageSize, file1);
for(GLuint i=0; i<int(imageSize); i+=bytesPerPixel)
{
temp=texture.imageData;
texture.imageData = texture.imageData[i + 2];
texture.imageData[i + 2] = temp;
}
fclose (file1);
HEIGHT = texture.height;
WIDTH = texture.width;
BPP = texture.bpp;
unsigned char *tex3D = (GLubyte *)malloc(WIDTH * HEIGHT * 4 * BPP);
for(int i = 0 ; i < HEIGHT*WIDTH ; i++)
tex3D[i + WIDTH * HEIGHT * LAYER * BPP] = texture.imageData;
///CUT!
///Here I do just about the same thing, with different files, and
///incrementing the LAYER.
///END CUT!
glGenTextures(1, &Tex);
glBindTexture(GL_TEXTURE_3D, Tex);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
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);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB8, WIDTH, HEIGHT, 4, 0, type, GL_UNSIGNED_BYTE, tex3D);