Graphics Reference
In-Depth Information
Do not confuse this format with the raw format from Photoshop; that is simply
a list of colors that does not include any dimensions.
If you write code to produce a raw 2D floating point texture file, it should
be organized like this:
int nums, numt;
. . .
fwrite( &nums, 4, 1, fp ); // nums is the S dimension of the file
fwrite( &numt, 4, 1, fp ); // numt is the T dimension of the file
for( int t = 0; t < numt; t++ )
{
for( int s = 0; s < nums; s++ )
{
float red, green, blue, alpha;
. . .
// set red, green, blue, and alpha for the texel at
// (s, t)
fwrite( &red, 4, 1, fp );
fwrite( &green, 4, 1, fp );
fwrite( &blue, 4, 1, fp );
fwrite( &alpha, 4, 1, fp );
}
}
The 3D texture raw format is analogous to this and is just as simple. The
first 12 bytes are three 4-byte integers, declaring the S, T, and P volume dimen-
sions. The following bytes are the RGBA values for each texel. These RGBA
values can be unsigned bytes or floats. Again, glman will look at the size of the
file and do the right thing.
If you write code to produce a raw 3D texture file, it should be organized
like this:
int nums, numt, nump;
. . .
fwrite( &nums, 4, 1, fp ); // S dimension
fwrite( &numt, 4, 1, fp ); // T dimension
fwrite( &nump, 4, 1, fp ); // P dimension
for( int p = 0; p < nump; p++ )
{
for( int t = 0; t < numt; t++ )
{
for( int s = 0; s < nums; s++ )
{
Search WWH ::




Custom Search