Hi,
The data you are viewing is in binary format so you cant use a normal text editor to see it (as u r doing here) nor can u see it using an image loading library like DevIL. Normally, the data may be 8-bit or 16-bit CT/MRI data which u would know from the source which gave u this data (and you would know the data dimensions also). Once you have this data, you load it from the file into an array (I am showing u how to do it next) and then pass that array to the glTexImage3D function (shown later). There are two chores here: 1) loading volume data and 2) rendering volume data.
Loading raw binary data from disc to opengl texture
You may use the C filing routines like this to load the data.
//assuming that the data at hand is a 256x256x256 unsigned byte data
int XDIM=256, YDIM=256, ZDIM=256;
const int size = XDIM*YDIM*ZDIM;
bool LoadVolumeFromFile(const char* fileName) {
FILE *pFile = fopen(fileName,"rb");
if(NULL == pFile) {
return false;
}
GLubyte* pVolume=new GLubyte[size];
fread(pVolume,sizeof(GLubyte),size,pFile);
fclose(pFile);
//load data into a 3D texture
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_3D, textureID);
// set the texture parameters
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage3D(GL_TEXTURE_3D,0,GL_INTENSITY,XDIM,YDIM,ZDIM,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,pVolume);
delete [] pVolume;
return true;
}
Volume rendering:
For this, there are numerous algorithms which includes 2d/3d texture slicing, splatting, shear warp, cell projection, iso-surface and raycasting. Currently, the gpu raycasting is the best method for use due to the computational resources available.
For more info on these, see these links
http://www.daimi.au.dk/~trier/?page_id=98
and this book and the accompanying source code is valuable.
http://www.real-time-volume-graphics.org/
Hope this helps you.