MedicalVisualization
3D Texturing Example (with LGL)
← 3D Texture Example | ● | 3D Procedural Textures →
3D texture is supposed to be given as texture object with id texid.
// create 3D texture from volume data
int texid = lglCreateTexmap3D(...,data);
...
// bind specific texture
lglTexture3D(texid);
// transfrom texture into world coordinates
lglMatrixMode(LGL_TEXTURE);
lglLoadIdentity();
lglTranslate(0.5,0.5,0.5);
lglMatrixMode(LGL_MODELVIEW);
// render textured geometry
lglColor(1,1,1);
lglBegin(LGL_QUADS);
lglTexCoord(x_0,y_0,z_0);
lglVertex(x_0,y_0,z_0);
lglTexCoord(x_1,y_1,z_1);
lglVertex(x_1,y_1,z_1);
lglTexCoord(x_2,y_2,z_2);
lglVertex(x_2,y_2,z_2);
lglTexCoord(x_3,y_3,z_3);
lglVertex(x_3,y_3,z_3);
lglEnd();
// unbind texture
lglTexture3D(0);
int texid = lglCreateTexmap3D(...,data);
...
// bind specific texture
lglTexture3D(texid);
// transfrom texture into world coordinates
lglMatrixMode(LGL_TEXTURE);
lglLoadIdentity();
lglTranslate(0.5,0.5,0.5);
lglMatrixMode(LGL_MODELVIEW);
// render textured geometry
lglColor(1,1,1);
lglBegin(LGL_QUADS);
lglTexCoord(x_0,y_0,z_0);
lglVertex(x_0,y_0,z_0);
lglTexCoord(x_1,y_1,z_1);
lglVertex(x_1,y_1,z_1);
lglTexCoord(x_2,y_2,z_2);
lglVertex(x_2,y_2,z_2);
lglTexCoord(x_3,y_3,z_3);
lglVertex(x_3,y_3,z_3);
lglEnd();
// unbind texture
lglTexture3D(0);