Hi,

I'm trying to load a volume data to 3D texture using the code bellow in order to implement a GPU based raycasting render:

#define XDIM 128

#define YDIM 128
#define ZDIM 128



LoadVolumeFromFile(const char* fileName) {


const int size = XDIM*YDIM*ZDIM;
FILE *pFile = fopen(fileName,"rb");
if(NULL == pFile) {
return false;
}
GLubyte* pVolume=new GLubyte[size];
fread(pVolume,sizeof(GLubyte),size,pFile);
fclose(pFile);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glGenTextures(1, &volume_texture);
glBindTexture(GL_TEXTURE_3D, volume_texture);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);
glTexImage3D(GL_TEXTURE_3D, 0,GL_INTENSITY, XDIM, YDIM,ZDIM,0, GL_LUMINANCE,GL_UNSIGNED_BYTE,pVolume);



delete []pVolume;
cout << "volume texture created" << endl;


}

it works well but when I substitute
glTexImage3D(GL_TEXTURE_3D, 0,GL_INTENSITY, XDIM, YDIM,ZDIM,0, GL_LUMINANCE,GL_UNSIGNED_BYTE,pVolume);

to this
glTexImage3D(GL_TEXTURE_3D, 0,GL_RGBA, XDIM, YDIM,ZDIM,0, GL_RGBA,GL_UNSIGNED_BYTE,pVolume);

I get runtime error!

I would really appreciate if someone helps solve this problem.

Thanks in advance